简体   繁体   English

Selenium WebDriver NoSuchElementException的复选框

[英]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.

相关问题 在Selenium WebDriver中实现InternetExplorerDriver期间发生NoSuchElementException - NoSuchElementException is occurred during implementation of InternetExplorerDriver in Selenium WebDriver org.openqa.selenium.NoSuchElementException WebDriver是否在Java中? - org.openqa.selenium.NoSuchElementException WebDriver in Java? Selenium Webdriver:切换窗口后获取NoSuchElementException - Selenium Webdriver : Getting NoSuchElementException after switching window Selenium Webdriver:处理 NoSuchElementException 的最佳实践 - Selenium Webdriver: best practice to handle a NoSuchElementException selenium webdriver中的复选框选择 - Checkbox selection in selenium webdriver Selenium Webdriver-可以通过萤火虫来定位元素,但是在Webdriver上没有nosuchelementexception - Selenium Webdriver - Able to locate elements through firebug, but getting nosuchelementexception at Webdriver 使用Selenium WebDriver选择复选框 - select checkbox using selenium webdriver Selenium Webdriver Java:单击复选框 - Selenium Webdriver java: click on a checkbox Selenium Webdriver为什么看不到网页上的元素? (NoSuchElementException) - Why can't selenium webdriver see the elements on the webpage? (NoSuchElementException) Selenium: JUnit4: WebDriver: IE: 使用 IE 时出现 NoSuchElementException - Selenium: JUnit4: WebDriver: IE: NoSuchElementException when using IE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM