0
0
Selenium Javatesting~10 mins

ExpectedConditions class 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 wait until the element is visible.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.[1](By.id("username")));
Drag options to blanks, or click blank then click option'
AalertIsPresent
BelementToBeClickable
CvisibilityOfElementLocated
DpresenceOfElementLocated
Attempts:
3 left
💡 Hint
Common Mistakes
Using presenceOfElementLocated which only waits for the element to be in the DOM but not necessarily visible.
2fill in blank
medium

Complete the code to wait until the element is clickable.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
wait.until(ExpectedConditions.[1](By.cssSelector("button.submit")));
Drag options to blanks, or click blank then click option'
AelementToBeClickable
BvisibilityOfElementLocated
CframeToBeAvailableAndSwitchToIt
DinvisibilityOfElementLocated
Attempts:
3 left
💡 Hint
Common Mistakes
Using visibilityOfElementLocated which does not guarantee the element is clickable.
3fill in blank
hard

Fix the error in the code to wait for an alert to be present.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.[1]());
Drag options to blanks, or click blank then click option'
AalertPresent
BalertExists
CalertVisible
DalertIsPresent
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like alertPresent or alertVisible.
4fill in blank
hard

Fill both blanks to wait until the frame is available and switch to it.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(20));
wait.until(ExpectedConditions.[1](By.name("[2]")));
Drag options to blanks, or click blank then click option'
AframeToBeAvailableAndSwitchToIt
BframeAvailable
CiframeSwitch
DswitchToFrame
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names or forgetting to switch to the frame.
5fill in blank
hard

Fill all three blanks to wait until the text is present in the element located by id.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.[1](By.id("message"), "[2]"));
String text = driver.findElement(By.id("message")).[3]();
Drag options to blanks, or click blank then click option'
AtextToBePresentInElementLocated
BWelcome
CgetText
DpresenceOfElementLocated
Attempts:
3 left
💡 Hint
Common Mistakes
Using presenceOfElementLocated which does not check for text.
Using incorrect method to get text like getAttribute.