0
0
Selenium Javatesting~10 mins

Custom ExpectedCondition 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 create a custom ExpectedCondition that waits for an element to be visible.

Selenium Java
ExpectedCondition<Boolean> elementIsVisible = driver -> driver.findElement(By.id("myElement")).[1]();
Drag options to blanks, or click blank then click option'
AsendKeys
BisDisplayed
CgetText
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of isDisplayed() causes the condition to fail.
Using getText() returns the element's text, not visibility.
Using sendKeys() is for input, not visibility check.
2fill in blank
medium

Complete the code to wait until the page title contains a specific word.

Selenium Java
ExpectedCondition<Boolean> titleContainsWord = driver -> driver.getTitle().[1]("Dashboard");
Drag options to blanks, or click blank then click option'
AendsWith
BstartsWith
Cequals
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using equals() requires exact match, not partial.
Using startsWith() or endsWith() only checks beginning or end.
3fill in blank
hard

Fix the error in the custom ExpectedCondition that waits for an element's text to be exactly 'Success'.

Selenium Java
ExpectedCondition<Boolean> textIsSuccess = driver -> driver.findElement(By.cssSelector(".status")).getText() [1] "Success";
Drag options to blanks, or click blank then click option'
Aequals
B=
C==
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using == compares object references, not string content.
Using = is an assignment, not a comparison.
4fill in blank
hard

Fill both blanks to create a custom ExpectedCondition that waits for an element's attribute 'disabled' to be 'true'.

Selenium Java
ExpectedCondition<Boolean> attributeIsTrue = driver -> driver.findElement(By.name("submitBtn")).getAttribute("disabled") [1] [2];
Drag options to blanks, or click blank then click option'
Aequals
B==
C"true"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using == compares references, not string content.
Using true without quotes compares boolean to string, causing error.
5fill in blank
hard

Fill the blanks to create a custom ExpectedCondition that waits for an element's text length to be greater than 5.

Selenium Java
ExpectedCondition<Boolean> textLengthGreaterThanFive = driver -> driver.findElement(By.className("message")).getText().[1] [2] 5;
Drag options to blanks, or click blank then click option'
Alength
B>
Clength()
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using length without parentheses causes syntax error.
Using < instead of > checks wrong condition.