Selenium WebDriver Stale Element Reference Exception for GWT
By : Alan Kapow
Date : March 29 2020, 07:55 AM
wish of those help I had problems, that the implicit wait only works for real page reloads, when the page is dynamicaly reloaded (like ajax) , then this will fail. You can try expected conditions to wait for for items, they are nice and easy to use and robust. You can configure them to ignore certain exceptions, so you can try to locate an element for a given time and then fail. This works even with ajax code :
protected <T> T waitForPageToLoad(ExpectedCondition<T> condition, String errorMessage) {
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(MAX_WAITING_TIME, SECONDS).ignoring(StaleElementReferenceException.class).ignoring(NoSuchElementException.class).pollingEvery(100, MILLISECONDS).withMessage(errorMessage);
T result = wait.until(condition);
return result;
}
public static final ExpectedCondition<Boolean> WAIT_FOR_BASKET = ExpectedConditions.visibilityOfElementLocated(By.cssSelector("c-menuimage"));
WebElement elem = waitForPageToLoad(waitForPageToLoad);
elem.click();
|
Stale Element Reference Exception c# Selenium Webdriver
By : B Diaz
Date : March 29 2020, 07:55 AM
To fix this issue What @Rameshwar told is true.Submit button is detached from DOM. Solution: Don't click the submit button directly,instead find till the element found and then click. code :
{
Password.SendKeys(Base64Decode(ConfigurationManager.AppSettings["Password"]));
Click(By.Id("login-submit"));
}
public bool Click(By by)
{
bool status = false;
int i = 0;
while (i==0)
try
{
driver.FindElement(by).Click();
status = true;
break;
}
catch (StaleElementReferenceException e)
{
}
return status;
}
|
Exception: org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the p
By : user3676030
Date : March 29 2020, 07:55 AM
Hope this helps The movement you click on 'Login Now' (x) element the references to x & y will be refreshed. So you can't use the x & y that are pointing to the old references and that will lead to the Statle Element exception. The solution would be to get the element each time you want to click on the x & y so that you will have the latest reference to the elements.
|
Selenium with Python: Stale Element Reference Exception
By : ddu69
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Working from Test Driven Development with Python, and I'm currently encountering a 'StaleElementReferenceException' when running the functional test immediately after migration. Here's the full text of the error: , Add these imports:
|
Selenium Stale Element Reference Exception
By : yogie bca
Date : March 29 2020, 07:55 AM
I hope this helps . I guess, you are trying to double click on a element. You can use actions class as given below instead of clicking twice on a element. code :
private void selectAndClickRow(String elementName, boolean doubleClick) {
try {
String elementXpath = "//tr//td//div[contains(text(),'" + elementName + "')]";
new WebDriverWait(Init.getWebDriver(), Init.getTimeOutInSeconds()).until(ExpectedConditions.visibilityOf(Init.getDriverExtensions().waitUntilElementAppearsInDom(By.xpath(elementXpath))));
WebElement row = table.findElements(By.xpath(elementXpath)).get(0);
new Actions(driver).doubleClick(row).perform();
} catch (StaleElementReferenceException e) {
//freeze(1);
//selectAndClickRow(elementName, doubleClick);
}
waitToLoad();
}
|