i

Selenium Step By Step Guide

Browser Navigation Methods

Browser Navigation methods are a set of methods to control the browser forward, backward, and refresh browser features. In some cases, we need to perform such operations to go forward or backward of a web page or to refresh the entire page. Selenium provides a set of methods to handle these situations.

Selenium Navigation Method:

Navigation method can be accessed by driver object, and further navigation methods can be called by from the Navigation Interface by putting a dot after the navigation method as shown below:

Here we can see a few methods are Object types; these are called from Object class of java and can be accessed from every object of java program. The only methods which are Navigation type are the navigation methods. Let us see these navigation methods in detail.

Navigate To Command:

This command is achieved by using the to() method of Navigation interface. This method opens a new URL, which is provided as a parameter into to() method.

driver.navigate().to("https://selflearning.io/");

This method is quite similar to "driver.get()" as both of them are used to load the URL of a web site.

Navigate Forward command:

This method of navigation interface helps us to achieve the click on the “Forward button” of a web browser.

driver.navigate().forward();

Navigate Back Command:

This method helps us to go back to the previous page. The same is done by the "Back arrow Button" of the browser.

driver.navigate().back();

Navigate Refresh Command:

Navigate refresh method helps us to do the refresh on a web page as it happens when we click on the reload or refresh button of a web page.

driver.navigate().refresh();