Skip to content
CodeKruPro

Visit two pages one after another

Automation taskEasyAsked in: Accenture, Infosys, TCS, Wipro

Interviewers ask: "Open the login page, then the dashboard, and print each title." The task shows you know that a navigation call, by default, returns only after the page has loaded, so no extra wait is needed between the two visits.

Navigate Between Pages

Video walkthrough

Watch on YouTube

Navigate Between Pages

You can navigate to multiple pages in a single script. Selenium provides two ways:

  • driver.get(url) - navigates to a URL
  • driver.navigate().to(url) - also navigates to a URL

Task:

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Print the title
  3. Navigate to https://testkru.com/Elements/Buttons
  4. Print the title

Expected output:

Page 1: Text Fields
Page 2: Buttons