0
0
Selenium Pythontesting~10 mins

Why element interaction drives test scenarios 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 click a button using Selenium.

Selenium Python
button = driver.find_element(By.ID, '[1]')
button.click()
Drag options to blanks, or click blank then click option'
Asubmit-btn
Bpassword
Cusername
Dlogin-form
Attempts:
3 left
💡 Hint
Common Mistakes
Using an ID that belongs to a different element like username or password fields.
2fill in blank
medium

Complete the code to enter text into a username field.

Selenium Python
username_field = driver.find_element(By.NAME, '[1]')
username_field.send_keys('testuser')
Drag options to blanks, or click blank then click option'
Asubmit
Bpassword
Cusername
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password' or 'submit' which are not the username field.
3fill in blank
hard

Fix the error in the code to correctly find a checkbox by its CSS selector.

Selenium Python
checkbox = driver.find_element(By.CSS_SELECTOR, '[1]')
checkbox.click()
Drag options to blanks, or click blank then click option'
Ainput[type='checkbox']
B#checkbox input[type='checkbox']
Ccheckbox input[type='checkbox']
D.checkbox input[type='checkbox']
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid or incomplete CSS selectors that cause errors.
4fill in blank
hard

Fill both blanks to select a dropdown option by visible text.

Selenium Python
from selenium.webdriver.support.ui import Select
select_element = Select(driver.find_element(By.[1], '[2]'))
select_element.select_by_visible_text('Option 1')
Drag options to blanks, or click blank then click option'
AID
Bname
Cclass_name
Ddropdown-menu
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.ID or By.CLASS_NAME when the element uses a name attribute.
5fill in blank
hard

Fill all three blanks to assert the page title contains expected text after clicking a link.

Selenium Python
link = driver.find_element(By.[1], '[2]')
link.click()
assert '[3]' in driver.title
Drag options to blanks, or click blank then click option'
ALINK_TEXT
Bpartial_link_text
CWelcome
DHome Page
Attempts:
3 left
💡 Hint
Common Mistakes
Using partial_link_text when full link text is needed.
Asserting wrong title text.