简体   繁体   中英

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. 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
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?

您可以尝试使用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>)));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM