Python Selenium: wait until an element is no longer stale?

后端 未结 4 1799
故里飘歌
故里飘歌 2021-01-18 12:19

I have a situation in which I want to wait until an element is no longer STALE i.e. until an elements gets connected to the DOM. Following wait options do not work somehow:<

4条回答
  •  执念已碎
    2021-01-18 13:10

    As you want to pick up the text property once the WebElement is no longer stale, you can use the following :

    wait1 = WebDriverWait(driver, 10)
    wait1.until(expected_conditions.text_to_be_present_in_element((By.ID, "elementID"), "expected_text1"))
    

    OR

    wait2 = WebDriverWait(driver, 10)
    wait2.until(expected_conditions.text_to_be_present_in_element_value((By.ID, "elementID"), "expected_text2"))
    

提交回复
热议问题