How do I wait for a JavaScript __doPostBack call through Selenium and WebDriver

前端 未结 2 1673
予麋鹿
予麋鹿 2020-11-29 12:55

I am facing a rare kind of issue while Automating through Selenium/Python while trying to fill out two fields on a website. My script fills out the first field i.e. ORIG

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 13:25

    @PixelEinstein 's Answer is the working and accepted Answer as his idea to wait for the element that is affected by the load to go stale or not be found did the trick. Finally I have arrived to a solution through a much simpler way then it was expected. I had to simply wait for the DELIVER ADDRESS field to go stale and then invoke 'send_keys("XYZ")' again on DELIVER ADDRESS field as follows :

    driver.get("https://www.avis.co.in")
    mySelect = Select(driver.find_element_by_id("DrpCity"))
    mySelect.select_by_visible_text("Pune")
    WebDriverWait(driver, 10).until(EC.staleness_of(driver.find_element_by_xpath("//input[@id='txtPickUp']")))
    driver.find_element_by_xpath("//input[@id='txtPickUp']").send_keys("XYZ")
    

    The discussion How to wait on the __doPostBack method to complete in javascript? was helpful to understand __doPostBack()

    tl;dr

    Sys.WebForms.PageRequestManager endRequest Event

提交回复
热议问题