Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ajax and Selenium
#1
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
Reply
#2
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
Recommended Tutorials:
Reply
#3
I am getting this error now:

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Retrieve data from ajax pthon3 0 1,161 May-29-2022, 10:32 PM
Last Post: pthon3
  POST Reply to Ajax/jQuery (mostly an HTML question) gw1500se 5 2,606 Nov-18-2021, 02:44 PM
Last Post: gw1500se
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,823 Aug-14-2020, 10:13 AM
Last Post: kashcode
  Flask SelectField using Ajax noah_f 0 2,495 Mar-23-2020, 04:03 PM
Last Post: noah_f
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,584 Nov-03-2017, 08:41 PM
Last Post: metulburr
  AJAX: readyState not as expected pleriche 2 3,370 Aug-08-2017, 08:55 AM
Last Post: pleriche

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020