Selenium - wait until element is present, visible and interactable

前端 未结 4 2013
旧时难觅i
旧时难觅i 2020-11-22 01:41

I have a selenium script (python) that clicks a reply button to make the class anonemail appear. The time it takes for the class anonemail to appear varies. Because of that

4条回答
  •  旧时难觅i
    2020-11-22 02:33

    You can use waits. Check for more info on this link: selenium waits

    On the example bellow we are waiting 10 seconds for the element to be visible, using the function visibility_of_element_located.

    driver = webdriver.Firefox()
    driver.get("http://somedomain/url_that_delays_loading")
    try:
        element = WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located((By.ID, "myDynamicElement"))
        )
    finally:
        driver.quit()
    

提交回复
热议问题