0
0
Selenium Javatesting~10 mins

Handling hidden elements 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 find a hidden element by its ID.

Selenium Java
WebElement hiddenElement = driver.findElement(By.[1]("hiddenElementId"));
Drag options to blanks, or click blank then click option'
Aid
Bname
CclassName
DtagName
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.name or By.className when the element's ID is known.
Trying to interact with the element before locating it.
2fill in blank
medium

Complete the code to check if a hidden element is displayed.

Selenium Java
boolean isVisible = driver.findElement(By.id("hiddenElementId")).[1]();
Drag options to blanks, or click blank then click option'
AisDisplayed
BisSelected
CisEnabled
DisVisible
Attempts:
3 left
💡 Hint
Common Mistakes
Using isEnabled() which checks if the element is enabled, not visible.
Using isSelected() which is for selectable elements like checkboxes.
3fill in blank
hard

Fix the error in the code to click a hidden element using JavaScript executor.

Selenium Java
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('hiddenElementId').[1]();");
Drag options to blanks, or click blank then click option'
AclickIt
BclickElement
CclickOn
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent JavaScript methods like clickElement().
Forgetting to cast the driver to JavascriptExecutor.
4fill in blank
hard

Fill both blanks to wait until a hidden element becomes visible using WebDriverWait.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.[1](By.[2]("hiddenElementId")));
Drag options to blanks, or click blank then click option'
AvisibilityOfElementLocated
BpresenceOfElementLocated
Cid
Dxpath
Attempts:
3 left
💡 Hint
Common Mistakes
Using presenceOfElementLocated which does not guarantee visibility.
Using By.xpath when the ID locator is simpler and more reliable.
5fill in blank
hard

Fill both blanks to scroll to a hidden element and click it using JavaScript executor.

Selenium Java
WebElement element = driver.findElement(By.[1]("hiddenElementId"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo(0, arguments[0].[2]);", element);
js.executeScript("arguments[0].click();", element);
Drag options to blanks, or click blank then click option'
Aid
BoffsetTop
CscrollHeight
DscrollTop
Attempts:
3 left
💡 Hint
Common Mistakes
Using scrollHeight which is the total height, not the element's position.
Using incorrect locator strategies.