3

I'm using Selenium and coding in Python.

After I submit a Javascript form, the page proceeds to load dynamically for results. I am essentially waiting for an element (a specific button link) to appear / finish loading so I can click on it. How do I go about doing this?

Infection
  • 165
  • 1
  • 4
  • 10

1 Answers1

11

You can use WebDriverWait, Documentation here,

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0

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

Also, take a look at a similiar question, How can I make Selenium/Python wait for the user to login before continuing to run?

Community
  • 1
  • 1