嗨,這裏的場景是我想在頁面的文本字段中輸入一些值,在此之前我需要使用xpath來查找文本字段。Selenium - 如何從Excel表格中獲取數據並將其寫入網頁?
所以,我在這裏有excel工作表中這些字段的值和xpaths。我如何獲得上面的代碼工作?這兩個片段都不起作用或顯示任何錯誤。
Cell cells = null;
Cell idcell=null;
if (checking.equalsIgnoreCase("xxxxxxxxxxxxx")){
System.out.println("Checking xxxxxxxxxxxx");
if (checking.equalsIgnoreCase("yyyyyyyyyyyy")){
for (int cols = 0; cols < sheet.getColumns(); cols++) {
cells = sheet.getCell(cols, rows);
idcell=sheet.getCell(cols,rows);
WebElement element_BuyCategory = driver.findElement(By.xpath(idcell.getContents()));
element_BuyCategory.sendKeys(cells.getContents());
System.out.println("xpath ok");
}
迴應將不勝感激。
請發佈[SSCCE](http://www.sscce.org)。沒有任何錯誤信息或能夠重現問題,沒有人能夠幫助你。 –