Challenge - 5 Problems
Hidden Element Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium Java code snippet?
Consider the following Selenium Java code that tries to click a hidden button. What will happen when this code runs?
Selenium Java
WebElement hiddenButton = driver.findElement(By.id("hiddenBtn")); hiddenButton.click(); System.out.println("Clicked hidden button");
Attempts:
2 left
💡 Hint
Hidden elements cannot be clicked directly by Selenium WebDriver.
✗ Incorrect
Selenium throws ElementNotInteractableException when trying to click an element that is present but not visible or interactable.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies an element is hidden?
You want to assert that a web element with id 'secret' is hidden on the page. Which assertion is correct?
Attempts:
2 left
💡 Hint
Use isDisplayed() to check visibility.
✗ Incorrect
isDisplayed() returns false if the element is hidden. So assertFalse on isDisplayed() confirms hidden state.
🔧 Debug
advanced2:00remaining
Why does this Selenium code fail to click a hidden element?
This code tries to click a hidden element but fails. Identify the reason.
Selenium Java
WebElement hidden = driver.findElement(By.cssSelector(".hidden-class"));
hidden.click();Attempts:
2 left
💡 Hint
Hidden elements cannot be clicked directly.
✗ Incorrect
The element is found but hidden, so Selenium cannot interact with it and throws ElementNotInteractableException.
❓ framework
advanced2:00remaining
Which Selenium approach handles clicking hidden elements safely?
You need to click a hidden element reliably in Selenium Java. Which approach is best?
Attempts:
2 left
💡 Hint
JS can click elements even if hidden.
✗ Incorrect
JavaScriptExecutor can click hidden elements by running JS directly, bypassing visibility restrictions.
🧠 Conceptual
expert2:00remaining
What is the main risk of clicking hidden elements in automated tests?
Why should automated tests avoid clicking hidden elements directly?
Attempts:
2 left
💡 Hint
Think about user experience vs test behavior.
✗ Incorrect
Clicking hidden elements can make tests pass even though real users cannot interact with those elements, hiding UI bugs.