0
0
Selenium Pythontesting~10 mins

Click actions in Selenium Python - Interactive Code Practice

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

Complete the code to click on the button with id 'submit-btn'.

Selenium Python
driver.find_element(By.ID, '[1]').click()
Drag options to blanks, or click blank then click option'
Asubmit-btn
Bsubmit_button
Cbutton-submit
DsubmitBtn
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong id string causes NoSuchElementException.
Misspelling the id attribute.
2fill in blank
medium

Complete the code to click on the first link with the class name 'nav-link'.

Selenium Python
driver.find_element(By.CLASS_NAME, '[1]').click()
Drag options to blanks, or click blank then click option'
Anavlink-class
Bnavlink
Cnav_link
Dnav-link
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores instead of hyphens.
Using partial class names.
3fill in blank
hard

Fix the error in the code to click the button with xpath '//button[@name="confirm"]'.

Selenium Python
driver.find_element(By.XPATH, '[1]').click()
Drag options to blanks, or click blank then click option'
A//button[@name=confirm]
B//button[name='confirm']
C//button[@name='confirm']
D//button[@name="confirm"]
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes around attribute value.
Using incorrect XPath syntax.
4fill in blank
hard

Fill both blanks to click the checkbox with id 'agree' only if it is not already selected.

Selenium Python
checkbox = driver.find_element(By.[1], '[2]')
if not checkbox.is_selected():
    checkbox.click()
Drag options to blanks, or click blank then click option'
AID
Bagree
CNAME
Daccept
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.NAME instead of By.ID.
Clicking without checking if already selected.
5fill in blank
hard

Fill all three blanks to click the button with CSS selector '.btn-primary' after waiting until it is clickable.

Selenium Python
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, [1])
button = wait.until(EC.element_to_be_clickable((By.[2], '[3]')))
button.click()
Drag options to blanks, or click blank then click option'
A10
BCSS_SELECTOR
C.btn-primary
DID
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong locator type like By.ID.
Not waiting before clicking.
Incorrect CSS selector string.