Python Forum

Full Version: Ajax and Selenium
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to automate filling a form on a website. There are two dropdowns like Country and States. Based on the Country selected in first drop down, the values in second drop down are loaded using Ajax.I am able to select Country in first drop down using Selenium Webdriver, but then it is not able to select State from second drop down.. Rather it gives following error :

selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <select id="ctl00_ContentPlaceHolder1_ReportViewer1_ctl04_ctl05_ddValue" class="aspNetDisabled" name="ctl00$ContentPlaceHolder1$ReportViewer1$ctl04$ctl05$ddValue"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
What is the website so we can tinker with it? And your code so we can just run it.

A couple of things to try in the meantime based on searching....

A StaleElementReferenceException is thrown when the element you were interacting is destroyed and then recreated.
wait.until(ExpectedConditions.stalenessOf(whatever element));
or
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("whatever elemnt")))
Other responses seem to be accessing the problematic element in a loop before throwing the exception
I am getting this error now:

AttributeError: 'module' object has no attribute 'stalenessOf'
Problem solved now by using fuction staleness_of()