navigate back in selenium code example
Example 1: driver navigate to method in selenium
If you use this method for opening URL, it will wait until the page has
fully loaded, that means every element in the page gets loaded before
returning control to your test or script. It only opens the url, but
driver.navigateto() interface also exposes the ability to move
backwards and forwards in browser’s history.
Example 2: back and forth in selenium
We use navigate method (navigate is an abstract method
of Webdriver interface) to navigate back and forth in a browser.
It has methods to move back, forward as well as to refresh a page.
forward, to.. are abstract method of Navigate interface
driver.navigate().to(“url”); –
to launch a new web browser window and navigate to the specified URL
driver.navigate().forward(); –
to navigate to the next web page with reference to the browser’s history
driver.navigate().back(); –
takes back to the previous webpage with reference to the browser’s history
driver.navigate().refresh(); –
to refresh the current web page thereby reloading all the web elements