Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The method isDisplayed() checks if the element is visible on the page, which is required for this ExpectedCondition.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using equals() requires exact match, not partial.
Using startsWith() or endsWith() only checks beginning or end.
✗ Incorrect
The contains() method checks if the title string contains the specified word.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using == compares object references, not string content.
Using = is an assignment, not a comparison.
✗ Incorrect
In Java, string equality must be checked with equals(), not == or =.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using == compares references, not string content.
Using true without quotes compares boolean to string, causing error.
✗ Incorrect
The getAttribute method returns a String, so we compare it with equals("true").
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using length without parentheses causes syntax error.
Using < instead of > checks wrong condition.
✗ Incorrect
We call length() on the string, then check if it is greater than 5.