How Do You Navigate to the Previous Page in Selenium?

Timothy Joseph | August 23, 2021
How Do You Navigate to the Previous Page in Selenium?

During QA automation, there are instances when you need to go back to the previous page or move forward to the next page in browser history. WebDriver provides some basic browser navigation commands that allow the user to move backward or forward in the browser's history.

We can access the navigation methods provided by WebDriver by typing driver.navigate() in the Eclipse panel.

The first thing you will want to do after launching a browser is to open your website. This can be done with a single line of code:

driver.navigate().to(" ");

If you want to navigate to the previous page, you can simply use the below line of code:


It is just like pressing the browser’s back button. In WebDriver, this method enables the web browser to click on the back button in the existing browser window. It neither accepts anything nor returns anything. Using the inbuilt methods, you may enhance the software quality assurance services in the field of automation testing.

Need help with Selenium test automation?


This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment