Recall & Review
beginner
What does the
is_displayed() method check in Selenium?It checks if a web element is visible to the user on the page. If the element is hidden or not rendered, it returns
False.Click to reveal answer
beginner
How do you verify if a button is enabled using Selenium in Python?
Use the
is_enabled() method on the button element. It returns True if the button can be clicked, otherwise False.Click to reveal answer
beginner
What does the
is_selected() method check for in Selenium?It checks if an element like a checkbox or radio button is selected (checked). Returns
True if selected, otherwise False.Click to reveal answer
intermediate
Why is it important to check element state before interacting with it in tests?
Checking state helps avoid errors like clicking hidden or disabled elements. It ensures the test interacts only with elements ready for action, making tests more reliable.
Click to reveal answer
beginner
Example: How to assert a checkbox is selected using Selenium Python?
Use
assert checkbox.is_selected(). This will pass if the checkbox is checked, otherwise the test fails.Click to reveal answer
Which Selenium method checks if an element is visible on the page?
✗ Incorrect
The
is_displayed() method returns true if the element is visible to the user.What does
is_enabled() return if a button is disabled?✗ Incorrect
is_enabled() returns false if the element is disabled and cannot be interacted with.Which element state method would you use to check if a radio button is selected?
✗ Incorrect
is_selected() checks if checkboxes or radio buttons are selected.Why should tests check element states before clicking?
✗ Incorrect
Checking states prevents errors by ensuring elements are ready for interaction.
What will
assert checkbox.is_selected() do if the checkbox is not checked?✗ Incorrect
The assertion fails if the checkbox is not selected, indicating a test failure.
Explain how to check if a web element is visible, enabled, and selected using Selenium in Python.
Think about how you decide if a button or checkbox is ready to use.
You got /4 concepts.
Describe a real-life situation where checking element state before interaction can prevent test failures.
Imagine clicking a button that is invisible or disabled.
You got /3 concepts.