Challenge - 5 Problems
State Checker Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of isDisplayed() for a hidden element?
Consider a Selenium WebDriver test where the following code is executed:
The element with id "hiddenDiv" exists in the DOM but has CSS style
WebElement hiddenElement = driver.findElement(By.id("hiddenDiv"));
boolean visible = hiddenElement.isDisplayed();
System.out.println(visible);The element with id "hiddenDiv" exists in the DOM but has CSS style
display:none;. What will be printed?Selenium Java
WebElement hiddenElement = driver.findElement(By.id("hiddenDiv"));
boolean visible = hiddenElement.isDisplayed();
System.out.println(visible);Attempts:
2 left
💡 Hint
An element with display:none is present but not visible on the page.
✗ Incorrect
The isDisplayed() method returns false if the element is hidden via CSS like display:none, even if it exists in the DOM.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies a button is enabled?
You want to write a JUnit assertion to check that a button with id "submitBtn" is enabled before clicking it. Which assertion is correct?
Selenium Java
WebElement submitBtn = driver.findElement(By.id("submitBtn"));Attempts:
2 left
💡 Hint
Enabled means the element can be interacted with.
✗ Incorrect
The isEnabled() method returns true if the element is enabled and can be clicked or typed into. The assertion should check for true.
🔧 Debug
advanced2:30remaining
Why does isSelected() return false for a checked checkbox?
Given the code:
The checkbox is visibly checked on the page, but the output is false. What is the most likely cause?
WebElement checkbox = driver.findElement(By.id("agreeTerms"));
boolean selected = checkbox.isSelected();
System.out.println(selected);The checkbox is visibly checked on the page, but the output is false. What is the most likely cause?
Selenium Java
WebElement checkbox = driver.findElement(By.id("agreeTerms"));
boolean selected = checkbox.isSelected();
System.out.println(selected);Attempts:
2 left
💡 Hint
Check if the element found is the actual input element representing the checkbox.
✗ Incorrect
If the locator finds a label or container instead of the input element, isSelected() will return false even if the checkbox is checked.
🧠 Conceptual
advanced1:30remaining
Which Selenium method checks if a radio button is selected?
You want to verify if a radio button is selected in your test. Which method should you use?
Attempts:
2 left
💡 Hint
Think about the state that indicates selection for inputs like radio buttons and checkboxes.
✗ Incorrect
The isSelected() method returns true if a radio button or checkbox is selected.
❓ framework
expert3:00remaining
How to wait until a button is enabled before clicking in Selenium Java?
You want to wait up to 10 seconds until a button with id "saveBtn" becomes enabled before clicking it. Which code snippet correctly implements this using WebDriverWait?
Attempts:
2 left
💡 Hint
Look for a condition that waits for the element to be clickable (visible and enabled).
✗ Incorrect
ExpectedConditions.elementToBeClickable waits until the element is visible and enabled, so it can be clicked safely.