我使用了明确的等待,我有警告:
org.openqa.selenium.WebDriverException:元素在点(36,72)处不可点击.其他元素将收到点击:...命令持续时间或超时:393毫秒
如果我使用Thread.sleep(2000)我没有收到任何警告.
@Test(dataProvider = "menuData")
public void Main(String btnMenu, String TitleResultPage, String Text) throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, 10);
driver.findElement(By.id("navigationPageButton")).click();
try {
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(btnMenu)));
} catch (Exception e) {
System.out.println("Oh");
}
driver.findElement(By.cssSelector(btnMenu)).click();
Assert.assertEquals(driver.findElement(By.cssSelector(TitleResultPage)).getText(), Text);
}
Run Code Online (Sandbox Code Playgroud)