0
0
Selenium Pythontesting~10 mins

Checking element state (displayed, enabled, selected) 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 check if the element is visible on the page.

Selenium Python
element = driver.find_element(By.ID, "submit-btn")
if element.[1]():
    print("Button is visible")
Drag options to blanks, or click blank then click option'
Ais_selected
Bis_enabled
Cis_displayed
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_enabled() instead of is_displayed()
Trying to call click() instead of checking state
2fill in blank
medium

Complete the code to check if the checkbox is selected.

Selenium Python
checkbox = driver.find_element(By.NAME, "agree")
if checkbox.[1]():
    print("Checkbox is checked")
Drag options to blanks, or click blank then click option'
Ais_displayed
Bsubmit
Cis_enabled
Dis_selected
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_displayed() which checks visibility
Using is_enabled() which checks if element can be interacted with
3fill in blank
hard

Fix the error in the code to check if the button is enabled.

Selenium Python
button = driver.find_element(By.CLASS_NAME, "btn-primary")
if button.[1]():
    print("Button is clickable")
Drag options to blanks, or click blank then click option'
Ais_selected
Bis_enabled
Cis_displayed
Dclickable
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_displayed() which only checks visibility
Using a non-existent method 'clickable'
4fill in blank
hard

Fill both blanks to create a dictionary of element states for a checkbox.

Selenium Python
checkbox = driver.find_element(By.ID, "subscribe")
states = {
    "visible": checkbox.[1](),
    "enabled": checkbox.[2]()
}
Drag options to blanks, or click blank then click option'
Ais_displayed
Bis_selected
Cis_enabled
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_selected() for visibility
Using click() which is an action, not a state check
5fill in blank
hard

Fill all three blanks to create a test that checks if a radio button is visible, enabled, and selected.

Selenium Python
radio = driver.find_element(By.CSS_SELECTOR, "input[type='radio']")
if radio.[1]() and radio.[2]() and radio.[3]():
    print("Radio button is ready and selected")
Drag options to blanks, or click blank then click option'
Ais_displayed
Bis_enabled
Cis_selected
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of a state check
Mixing up enabled and selected methods