我的代码:
WebElement objSearchBy = wait.until(
ExpectedConditions.presenceOfElementLocated(
By.xpath("//html/body/div[I]/div[2]/form/div[2]/label[I]")
)
);
HTML代码:
获得以下输出:
线程“main”中的异常org.openqa.selenium.TimeoutException:预期条件失败:等待位于以下位置的元素的存在:By.xpath:// html / body / div [I] / div [2] / form / div [2] / label [I](尝试30秒,间隔500 MILLISECONDS)
答案 0 :(得分:0)
展开SELECT标记并查看其下的可用选项。基于此代码的第二行所需的选项更新。
Select dropdown = new Select(driver.findElement(By.id("loc_code")));
dropdown.selectByVisibleText("your option text");
或
Select dropdown = new Select(driver.findElement(By.id("loc_code")));
dropdown.selectByValue("option2");
或
dropdown.selectByIndex(2);
答案 1 :(得分:0)
请检查xpath正确性:如果是自动生成的,则值div[I]
和label[I]
是否正确?
尝试在此处#loc_code
使用有意义的路径或精确标识符