0
0
Selenium Javatesting~10 mins

Multi-page navigation flow 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 open the browser and navigate to the homepage URL.

Selenium Java
WebDriver driver = new ChromeDriver();
driver.[1]("https://example.com");
Drag options to blanks, or click blank then click option'
Aopen
Bnavigate
Cload
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'navigate' instead of 'get' causes a compile error.
Using 'open' or 'load' are not valid WebDriver methods.
2fill in blank
medium

Complete the code to click a link that navigates to the next page.

Selenium Java
WebElement nextPageLink = driver.findElement(By.id("nextPage"));
nextPageLink.[1]();
Drag options to blanks, or click blank then click option'
Asubmit
BsendKeys
Cclick
Dselect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'submit' only works on forms, not links.
Using 'sendKeys' is for typing text, not clicking.
3fill in blank
hard

Fix the error in waiting for the next page to load by completing the wait condition.

Selenium Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.[1](By.id("pageTitle")));
Drag options to blanks, or click blank then click option'
AelementToBeClickable
BvisibilityOfElementLocated
CpresenceOfElementLocated
DalertIsPresent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'presenceOfElementLocated' may pass if element is hidden.
Using 'alertIsPresent' is unrelated to page elements.
4fill in blank
hard

Fill both blanks to navigate back to the previous page and verify the title.

Selenium Java
driver.[1]();
String title = driver.[2]();
assertEquals("Home Page", title);
Drag options to blanks, or click blank then click option'
Anavigate().back
BgetTitle
CgetTitle()
Dnavigate().forward
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'navigate().forward' goes forward, not back.
Using 'getTitle' without parentheses is a syntax error.
5fill in blank
hard

Fill all three blanks to extract text from an element, verify it, and then close the browser.

Selenium Java
WebElement message = driver.findElement(By.cssSelector(".alert-success"));
String text = message.[1]();
assertTrue(text.[2]("Success"));
driver.[3]();
Drag options to blanks, or click blank then click option'
AgetText
Bcontains
Cquit
DisDisplayed
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isDisplayed' instead of 'getText' returns a boolean, not text.
Using 'close' instead of 'quit' leaves the browser running.