0
0
Selenium Pythontesting~10 mins

Why advanced patterns solve real challenges in Selenium Python - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to open a browser and navigate to a URL using Selenium.

Selenium Python
driver = webdriver.Chrome()
driver.[1]('https://example.com')
Drag options to blanks, or click blank then click option'
Astart
Bopen
Cnavigate
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'open' or 'navigate' instead of 'get' causes errors.
2fill in blank
medium

Complete the code to find an element by its ID using Selenium.

Selenium Python
element = driver.find_element(By.[1], 'submit-button')
Drag options to blanks, or click blank then click option'
ANAME
BID
CCLASS_NAME
DTAG_NAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using NAME or CLASS_NAME when the element has an ID.
3fill in blank
hard

Fix the error in the code to wait until an element is clickable before clicking.

Selenium Python
wait = WebDriverWait(driver, 10)
element = wait.until(EC.[1]((By.ID, 'submit')))
element.click()
Drag options to blanks, or click blank then click option'
Aelement_to_be_clickable
Bpresence_of_element_located
Cvisibility_of_element_located
Dalert_is_present
Attempts:
3 left
💡 Hint
Common Mistakes
Using presence_of_element_located does not guarantee clickability.
4fill in blank
hard

Fill both blanks to create a Page Object method that clicks a button after waiting for it.

Selenium Python
def click_submit(self):
    wait = WebDriverWait(self.driver, 10)
    button = wait.until(EC.[1]((By.[2], 'submit-btn')))
    button.click()
Drag options to blanks, or click blank then click option'
Aelement_to_be_clickable
BID
Cpresence_of_element_located
DCLASS_NAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using presence_of_element_located instead of element_to_be_clickable.
5fill in blank
hard

Fill all three blanks to define a test that asserts the page title after navigation.

Selenium Python
def test_page_title(self):
    self.driver.[1]('https://example.com')
    title = self.driver.[2]
    assert title [3] 'Example Domain'
Drag options to blanks, or click blank then click option'
Aget
Btitle
C==
Dcurrent_url
Attempts:
3 left
💡 Hint
Common Mistakes
Using current_url instead of title, or wrong comparison operator.