0
0
Selenium Javatesting~10 mins

Checking state (isDisplayed, isEnabled, isSelected) in Selenium Java - 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 button is visible on the page.

Selenium Java
boolean visible = button.[1]();
Drag options to blanks, or click blank then click option'
AisDisplayed
Bclick
CisSelected
DgetText
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of isDisplayed()
Using getText() which returns text, not visibility
Using isSelected() which checks selection state, not visibility
2fill in blank
medium

Complete the code to verify if the checkbox is enabled for interaction.

Selenium Java
boolean enabled = checkbox.[1]();
Drag options to blanks, or click blank then click option'
Asubmit
BisSelected
CisDisplayed
DisEnabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using isSelected() which checks if checkbox is checked
Using isDisplayed() which checks visibility only
Using submit() which triggers form submission
3fill in blank
hard

Fix the error in the code to check if the radio button is selected.

Selenium Java
boolean selected = radioButton.[1]();
Drag options to blanks, or click blank then click option'
AisDisplayed
BisEnabled
CisSelected
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using isEnabled() which checks if element is active
Using isDisplayed() which checks visibility
Using click() which performs an action instead of checking state
4fill in blank
hard

Fill both blanks to check if the element is visible and enabled before clicking.

Selenium Java
if (element.[1]() && element.[2]()) {
    element.click();
}
Drag options to blanks, or click blank then click option'
AisDisplayed
BisSelected
CisEnabled
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Using isSelected() instead of isEnabled()
Using submit() which is not a state check
Reversing the order of checks
5fill in blank
hard

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

Selenium Java
if (checkbox.[1]() && checkbox.[2]() && checkbox.[3]()) {
    System.out.println("Checkbox is ready and selected.");
}
Drag options to blanks, or click blank then click option'
AisDisplayed
BisEnabled
CisSelected
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of a state check method
Checking isSelected() before isDisplayed() or isEnabled()
Missing one of the state checks