[英]Selenium WebDriver NoSuchElementException for a checkbox
The thing is my test works great when i run it(by the way, its based on IE8), but when its run from Bamboo, it doesn't find an element, even though its not hidden and it is there on the page. 事情是我的测试(顺便说一句,它基于IE8)运行时我的测试效果很好,但是当它从Bamboo运行时,它找不到一个元素,即使它没有被隐藏并且也位于页面上。 I use this to get the elements: 我用它来获取元素:
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;
}
My element is just a simple checkbox in a table. 我的元素只是表格中的一个简单复选框。 Every time in normal conditions it finds it, but for a strange reason on the Bamboo it doesnt find it The windows is XP and driver version 2.37, .I think 每次在正常情况下都可以找到它,但是由于Bamboo上的一个奇怪原因,它找不到它。Windows是XP和驱动程序版本2.37,我认为。
My question is, is there a way I can force retrieve the element or tell the webdriver to refresh the table that contains the element? 我的问题是,有什么办法可以强制检索元素或告诉Webdriver刷新包含该元素的表?
您可以尝试使用Javascript查找元素。
WebElement element = (WebElement) ((JavascriptExecutor)driver).executeScript("return document.getElementById('myCheckbox')");
This may help you: 这可以帮助您:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id(>someid>)));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.