logo
down
shadow

Python Selenium: Stale Element Reference Exception Error


Python Selenium: Stale Element Reference Exception Error

By : Miftaqul Huda
Date : November 23 2020, 03:01 PM
With these it helps Once page refreshed after you call submit() webElements inside allelements are no more valid
Instead of
code :
allelements = driver.find_elements_by_xpath("//a[text()='xml']")

for element in allelements:
    element.click()
allelements = len(driver.find_elements_by_xpath("//a[text()='xml']"))

for index in range(allelements):
    driver.find_elements_by_xpath("//a[text()='xml']")[index].click()


Share : facebook icon twitter icon
Selenium WebDriver Stale Element Reference Exception for GWT

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

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

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

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

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();
}
Related Posts Related Posts :
  • How to calculate each single element of a numpy array based on conditions
  • How do I change the width of Jupyter notebook's cell's left part?
  • Measure distance between lat/lon coordinates and utm coordinates
  • Installing megam for NLTK on Windows
  • filter dataframe on each value of a samn column have a specific value of another column in Panda\Python
  • Threading with pubsub throwing AssertionError: 'callableObj is not callable' in wxPython
  • Get grouped data from 2 dataframes with condition
  • How can I import all of sklearns regressors
  • How to take all elements except the first k
  • Whats wrong with my iteration list of lists from csv
  • Tensorflow Estimator API save image summary in eval mode
  • How to Pack with PyQt - how to make QFrame/Layout adapt to content
  • How do I get certain Time Range in Python
  • python doubly linked list - insertAfter node
  • Open .h5 file in Python
  • Joining a directory name with a binary file name
  • python, sort list with two arguments in compare function
  • Is it possible to print from Python using non-ANSI colors?
  • Pandas concat historical data using date minus some number of days
  • CV2: Import Error in Python OpenCV
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org