Browser Navigation in Selenium

Let’s see how can you perform Browser Navigation in Selenium. In software testing, Many times we need to navigate through browser i.e browser back, browser forward, refresh.

To support this testing, Selenium provides browser navigation method. Using this method we can navigate on the browser.


Let’s take see how these methods are helpful in Testing. In these days, many websites provide the online payment functionality. In online payment, it is prohibited to browser back or refresh. So these kind of testing these methods are very useful.

Let’s see the Browser Navigation methods with the example.


Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.


Open URL in Browser in Selenium“URL”) method Loads a new web page in the current browser window. It accepts a String parameter and returns nothing.

It does exactly the same thing as the driver.get(web URL) method. Where app URL is the website address to load.

The above Test will open the SeleniumBix in the browser window.


Browser Back in Selenium

 Navigate.Back() – This command lets the user navigate to the previous web page. And it will not perform any action if you are on the first page viewed.


Browser Forward in Selenium

Navigate.Forward() – This command lets the user navigate to the next web page with reference to the browser’s history. And it will not perform any action if we are on the latest page viewed.

In Example we are opening the Facebook, Visit Forgot Password page then we will execute the Browser Back so this will end on Home Page. Now perform Navigate Forward so, You will navigate on Forgot Password page on facebook.


Refresh Browser in Selenium

 Navigate.Refresh() – This command lets the user refresh the current web page thereby reloading all the web elements. We can perform browser refresh testing on payment gateways or we need to check if the data is getting cleared once when the page refreshes.

And for few websites, it will display an alert when the user tries to refresh the page without saving the form which user has entered data.

Let’s open the FaceBook enter the Username and Password and refresh the page to verify that entered username & password are getting cleared on page refresh or not.


We have seen all navigation methods and their uses in selenium. You can practice these in your project and prepare a stable and good test script.

0 Comment

Leave a Reply