Java 显式等待给定操作(错误)-Selenium Webdriver
大家早上好 我在使用SeleniumWebDriver(JAVA)进行自动化时遇到问题。 首先,系统(界面)使用AJAX,好吗 我不得不多次点击同一个按钮。此按钮保留相同的元素 为了避免错误(ElementClickInterceptedException和/或StaleElementReferenceException),我最初添加了一个WebdriverWait,异常为“ElementToBickable”。 然而,即使等待,错误仍然存在 然后我决定添加FluentWait。我添加了异常、时间等,但也保留了错误 我发现唯一可行的方法是著名的“线程.睡眠”(400ms) 但是我不想在我的代码中添加thread.sleep,因为我发现这是一种不好的做法 有人有什么想法吗 下面是一些代码片段 命令: driver.findElement(By.xpath(“//tr[1]/td[8]/button”))。点击() 已使用的等待: 1: 2: 3: 有人能帮我吗?Java 显式等待给定操作(错误)-Selenium Webdriver,java,selenium,selenium-webdriver,automation,automated-tests,Java,Selenium,Selenium Webdriver,Automation,Automated Tests,大家早上好 我在使用SeleniumWebDriver(JAVA)进行自动化时遇到问题。 首先,系统(界面)使用AJAX,好吗 我不得不多次点击同一个按钮。此按钮保留相同的元素 为了避免错误(ElementClickInterceptedException和/或StaleElementReferenceException),我最初添加了一个WebdriverWait,异常为“ElementToBickable”。 然而,即使等待,错误仍然存在 然后我决定添加FluentWait。我添加了异常、时
提前非常感谢 你能把应用程序的html源代码和你的问题一起上传吗?还要检查按钮元素是否在任何iframe标记内,如果是,则必须实现driver.switchTo().frame(iframe) 请更新您的相关Html?@KunduK,我不明白,对不起!你想要什么?
wait.until (ExpectedConditions.elementToBeClickable (By.xpath ("// tr / td [8] / button")));
wait.until (ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath ("// tr / td [8] / button")));
.withTimeout (10, TimeUnit.SECONDS)
.pollingEvery (1, TimeUnit.SECONDS)
.ignoring (NoSuchElementException.class)
.ignoring (StaleElementReferenceException.class)
.ignoring (ElementClickInterceptedException.class);
waitFluent.until (ExpectedConditions.elementToBeClickable (By.xpath ("// tr / td [8] / button")));