Jer*_*org 8 java selenium google-chrome click selenium-webdriver
我有一些点击选项卡的测试,但并不总是执行点击.
xpath是正确的,因为测试工作的大多数时间
这不是一个计时问题,因为我使用了thread.sleep()和其他方法来确保在单击之前元素是可见的
测试认为它正在执行点击,因为它不会在"执行"点击时抛出ElementNotFoundException或任何其他异常.由于选项卡内容不会更改,因此稍后在单击后测试失败.
进一步的信息我使用Selenium 2.44.0来实现在Chrome 44.0.2403.107 m上运行的Java测试.
我还能做些什么,或者这可能成为硒的问题?
ale*_*cxe 21
您可以尝试以下几种方法:
显性elementToBeClickable等待:
WebDriverWait wait = new WebDriverWait(webDriver, 10);
WebElement button = wait.until(ExpectedConditions.elementToBeClickable(By.id("myid")));
button.click()
Run Code Online (Sandbox Code Playgroud)在点击之前移动到元素:
Actions actions = new Actions(driver);
actions.moveToElement(button).click().build().perform();
Run Code Online (Sandbox Code Playgroud)通过javascript进行点击:
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", button);
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
8052 次 |
| 最近记录: |