Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97762

Selenium Java Chrome: Stale exception

$
0
0

Here is a code fragment:

    System.setProperty(Constants.WEBDRIVER_CHROME_DRIVER_PROP, Constants.WEBDRIVER_CHROME_DRIVER_PATH);

    m_chromeWebdriver = new ChromeDriver();
    m_chromeWebdriver.get("mysite.org");

    WebElement arrowElement = m_chromeWebdriver.findElement(By.cssSelector(_ARROW_NEXT_DAY));
    arrowElement.click();

    WebElement elmMainTable = m_chromeWebdriver.findElement(By.className("table-main"));

    List<WebElement> allRows = elmMainTable.findElements(By.tagName("tr"));

    for (WebElement row : allRows) {

        List<WebElement> cells = row.findElements(By.tagName("td"));
        for (WebElement cell : cells) {
            System.out.println(cell.getText());
        }
    }
    m_chromeWebdriver.quit();

At the last line I get an

"stale element reference: element is not attached to the page document"

exception.

Why and how can I solve that? I use Chromdriver 2.2.9.

Thanks


Viewing all articles
Browse latest Browse all 97762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>