Copy from Excel and paste it

Hello Every one
I have an excel file where I have to copy e.g name and paste it field , so How can I do it ?

Although you probably could use the Robot to Copy and Paste from Excel, how about just Read and Write from it instead. You will be able to find the below on this forum in a lot of places.
As an example:

import org.apache.poi.xssf.usermodel.XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook

FileInputStream fis = new FileInputStream (gPathWayToExcel);
XSSFWorkbook workbook = new XSSFWorkbook (fis);

XSSFSheet sheet = workbook.getSheet("Sheet1");
// cell A2
Row row = sheet.getRow(1);
Cell cell = row.getCell(0);
exampleName = cell.getStringCellValue();


WebUI.setText(findTestObject(...), exampleName)
WebUI.verifyElementAttributeValue(findTestObject(...), "value", exampleName, 10)

Edit: If you have a lot of things to read and write, then you should look into having a Data File attached to your test.

1 Like