1
My test code using Selenium/Webdriver stops running after reading Apache Poi data.
Can anyone tell me why?
//poi
WebElement searchbox = driver.findElement(By.name("simcard"));
try {
FileInputStream file = new FileInputStream(new File("C:\\paulo.xls"));
HSSFWorkbook workbook = new HSSFWorkbook(file);
HSSFSheet sheet = workbook.getSheetAt(0);
for (int i=1; i <= sheet.getLastRowNum(); i++){
String simcard = sheet.getRow(i).getCell(0).getStringCellValue();
searchbox.sendKeys(simcard);
searchbox.submit();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.MILLISECONDS);
}
workbook.close();
file.close();
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
The next step:
driver.findElement(By.xpath("/html/body/table/tbody/tr[4]/td/div/form/table/tbody/tr[2]/td/center/table/tbody/tr[19]/td/a[1]/img")).click();
Hello Paulo! What is "Data Driven" in your code? Do you really want to search each line of the spreadsheet and wait 10 seconds between each search? The component
searchbox
should receive both the text to be searched as well as thesubmit
? Wouldn’t have a button?– utluiz
Luiz, I’m new to programming, I copied this code and tried to adapt in my... I really want him to open the spreadsheet, take a value and put it in the input, do not need to wait 10 seconds and do not scan the spreadsheet... Can you reconstruct this code snippet for me, please?
– Paulo Roberto