Java 复选框的Selenium WebDriver NoTouchElementException
顺便说一句,当我运行它时,我的测试非常有效,它基于IE8,但是当它从竹子运行时,它找不到元素,即使它没有隐藏并且在页面上。 我用它来获取元素:Java 复选框的Selenium WebDriver NoTouchElementException,java,selenium,Java,Selenium,顺便说一句,当我运行它时,我的测试非常有效,它基于IE8,但是当它从竹子运行时,它找不到元素,即使它没有隐藏并且在页面上。 我用它来获取元素: public WebElement getElementWhenVisible(By locator, int timeout) { WebElement element = null; WebDriverWait wait = new WebDriverWait(driver, timeout); log
public WebElement getElementWhenVisible(By locator, int timeout) {
WebElement element = null;
WebDriverWait wait = new WebDriverWait(driver, timeout);
log.info("Getting element with locator {}", locator);
element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
return element;
}
我的元素只是表中的一个简单复选框。在正常情况下,它每次都能找到它,但由于一个奇怪的原因,它在竹子上找不到它
windows是XP和驱动程序版本2.37。我想
我的问题是,有没有一种方法可以强制检索元素或告诉webdriver刷新包含该元素的表?您可以尝试使用Javascript查找该元素
WebElement element = (WebElement) ((JavascriptExecutor)driver).executeScript("return document.getElementById('myCheckbox')");
这可能会帮助您:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id(>someid>)));