Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
from selenium.webdriver.support.ui import WebDriverWait

element_id = object

def find_the_element_by_id(driver):
    element = driver.find_element_by_id(element_id)
    if element:
        return element
    else:
        return False

def function_where_test_written():
    global element_id
    
    element_id = "qa"
    qa = WebDriverWait(driver, 1).until(find_the_element_by_id)
    qa.click()

Code explained

Line 1 3 : set up a variable that we can pass the id or whatever the search criteria is into

Line 35-8 10 : create a function that does the query on the DOM using the webdriver that is passed in

...