
- Selenium - Home
- Selenium - Overview
- Selenium - Components
- Selenium - Automation Testing
- Selenium - Environment Setup
- Selenium - Remote Control
- Selenium - IDE Introduction
- Selenium - Features
- Selenium - Limitations
- Selenium - Installation
- Selenium - Creating Tests
- Selenium - Creating Script
- Selenium - Control Flow
- Selenium - Store Variables
- Selenium - Alerts & Popups
- Selenium - Selenese Commands
- Selenium - Actions Commands
- Selenium - Accessors Commands
- Selenium - Assertions Commands
- Selenium - Assert/Verify Methods
- Selenium - Locating Strategies
- Selenium - Script Debugging
- Selenium - Verification Points
- Selenium - Pattern Matching
- Selenium - JSON Data File
- Selenium - Browser Execution
- Selenium - User Extensions
- Selenium - Code Export
- Selenium - Emitting Code
- Selenium - JavaScript Functions
- Selenium - Plugins
- Selenium WebDriver Tutorial
- Selenium - Introduction
- Selenium WebDriver vs RC
- Selenium - Installation
- Selenium - First Test Script
- Selenium - Driver Sessions
- Selenium - Browser Options
- Selenium - Chrome Options
- Selenium - Edge Options
- Selenium - Firefox Options
- Selenium - Safari Options
- Selenium - Double Click
- Selenium - Right Click
- HTML Report in Python
- Handling Edit Boxes
- Selenium - Single Elements
- Selenium - Multiple Elements
- Selenium Web Elements
- Selenium - File Upload
- Selenium - Locator Strategies
- Selenium - Relative Locators
- Selenium - Finders
- Selenium - Find All Links
- Selenium - User Interactions
- Selenium - WebElement Commands
- Selenium - Browser Interactions
- Selenium - Browser Commands
- Selenium - Browser Navigation
- Selenium - Alerts & Popups
- Selenium - Handling Forms
- Selenium - Windows and Tabs
- Selenium - Handling Links
- Selenium - Input Boxes
- Selenium - Radio Button
- Selenium - Checkboxes
- Selenium - Dropdown Box
- Selenium - Handling IFrames
- Selenium - Handling Cookies
- Selenium - Date Time Picker
- Selenium - Dynamic Web Tables
- Selenium - Actions Class
- Selenium - Action Class
- Selenium - Keyboard Events
- Selenium - Key Up/Down
- Selenium - Copy and Paste
- Selenium - Handle Special Keys
- Selenium - Mouse Events
- Selenium - Drag and Drop
- Selenium - Pen Events
- Selenium - Scroll Operations
- Selenium - Waiting Strategies
- Selenium - Explicit/Implicit Wait
- Selenium - Support Features
- Selenium - Multi Select
- Selenium - Wait Support
- Selenium - Select Support
- Selenium - Color Support
- Selenium - ThreadGuard
- Selenium - Errors & Logging
- Selenium - Exception Handling
- Selenium - Miscellaneous
- Selenium - Handling Ajax Calls
- Selenium - JSON Data File
- Selenium - CSV Data File
- Selenium - Excel Data File
- Selenium - Cross Browser Testing
- Selenium - Multi Browser Testing
- Selenium - Multi Windows Testing
- Selenium - JavaScript Executor
- Selenium - Headless Execution
- Selenium - Capture Screenshots
- Selenium - Capture Videos
- Selenium - Page Object Model
- Selenium - Page Factory
- Selenium - Record & Playback
- Selenium - Frameworks
- Selenium - Browsing Context
- Selenium - DevTools
- Selenium Grid Tutorial
- Selenium - Overview
- Selenium - Architecture
- Selenium - Components
- Selenium - Configuration
- Selenium - Create Test Script
- Selenium - Test Execution
- Selenium - Endpoints
- Selenium - Customizing a Node
- Selenium Reporting Tools
- Selenium - Reporting Tools
- Selenium - TestNG
- Selenium - JUnit
- Selenium - Allure
- Selenium & other Technologies
- Selenium - Java Tutorial
- Selenium - Python Tutorial
- Selenium - C# Tutorial
- Selenium - Javascript Tutorial
- Selenium - Kotlin Tutorial
- Selenium - Ruby Tutorial
- Selenium - Maven & Jenkins
- Selenium - Database Testing
- Selenium - LogExpert Logging
- Selenium - Log4j Logging
- Selenium - Robot Framework
- Selenium - AutoIT
- Selenium - Flash Testing
- Selenium - Apache Ant
- Selenium - Github Tutorial
- Selenium - SoapUI
- Selenium - Cucumber
- Selenium - IntelliJ
- Selenium - XPath
- Selenium Miscellaneous Concepts
- Selenium - IE Driver
- Selenium - Automation Frameworks
- Selenium - Keyword Driven Framework
- Selenium - Data Driven Framework
- Selenium - Hybrid Driven Framework
- Selenium - SSL Certificate Error
- Selenium - Alternatives
Selenium WebDriver - Browser Navigation
Selenium Webdriver provides multiple methods which help to achieve browser navigation which include launching, moving backward, forward on browser history, and refreshing the browser.
Basic Browser Navigation Commands
Some of the browser navigation methods are discussed below −
driver.navigate().to("application url")
This method navigates to an application url.
Syntax
driver.navigate().to("https://www.tutorialspoint.com/index.htm");
driver.get("application url")
This method launches the browser to open an application.
Syntax
driver.get("https://www.tutorialspoint.com/index.htm");
driver.navigate().back()
This method jumps to the previous page as per browser history context.
Syntax
driver.navigate().back();
driver.navigate().forward()
This method jumps forward to the next page as per browser history context.
Syntax
driver.navigate().forward();
driver.navigate().refresh()
This method reloads a web page.
Syntax
driver.navigate().refresh();
Example 1
Let us take an example, where we would first launch an application having the browser title Selenium Practice - Student Registration Form.

Then we would click on the Login link, once clicked, we would be navigated to another page having the browser title Selenium Practice - Login.

Next, we would navigate back to the browser history, and get the browser title as Selenium Practice - Student Registration Form.
Finally, we would navigate forward to the browser history, and get the browser title as Selenium Practice - Login. We would also refresh the browser, and obtain the browser title as Selenium Practice - Login.
Code Implementation
package org.example; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class BrowNavigation { public static void main(String[] args) throws InterruptedException { // Initiate the Webdriver WebDriver driver = new ChromeDriver(); // adding implicit wait of 15 secs driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); // launching a browser and open a URL driver.get("https://www.tutorialspoint.com/selenium/practice/selenium_automation_practice.php"); // Getting browser title after launch System.out.println("Getting browser title after launch: " + driver.getTitle()); // identify the link then click WebElement l = driver.findElement(By.xpath("//*[@id='collapseTwo']/div/ul/li[2]/a")); l.click(); // Getting browser title after clicking link System.out.println("Getting browser title after clicking link: " + driver.getTitle()); // navigate back to browser history driver.navigate().back(); // Getting browser title after navigating back System.out.println("Getting browser title after navigating back: " + driver.getTitle()); // navigate forward to browser history driver.navigate().forward(); // Getting browser title after navigating forward System.out.println("Getting browser title after navigating forward: " + driver.getTitle()); // refresh browser driver.navigate().refresh(); // Getting browser title after browser refresh System.out.println("Getting browser title after browser refresh: " + driver.getTitle()); // Closing browser driver.quit(); } }
Output
Getting browser title after launch: Selenium Practice - Student Registration Form Getting browser title after clicking link: Selenium Practice - Login Getting browser title after navigating back: Selenium Practice - Student Registration Form Getting browser title after navigating forward: Selenium Practice - Login Getting browser title after browser refresh: Selenium Practice - Login
In the above example, we had launched a URL in the opened browser and obtained the browser title with the message in the console - Getting browser title after launch: Selenium Practice - Student Registration Form. We had then clicked on the Login link and received the browser title of the navigated page with the message in the console - Getting browser title after clicking link: Selenium Practice - Login.
Next, we had moved back in browser history and obtained the browser title with the message in the console - Getting browser title after navigating back: Selenium Practice - Student Registration Form. Again, we navigated forward in browser history and retrieved the browser title with the message in the console - Getting browser title after navigating forward: Selenium Practice - Login. Finally, we refreshed the browser and got its title with the message in the console - Getting browser title after browser refresh: Selenium Practice - Login.
Example 2
Let us take an example, where we would first launch an application having the URL as −
https://www.tutorialspoint.com/selenium/practice/login.php.

Then we would click on the Register link, once clicked, we would be navigated to another page having the URL as −
https://www.tutorialspoint.com/selenium/practice/register.php.

Next, we would navigate back to the browser history, and get the URL as −
https://www.tutorialspoint.com/selenium/practice/login.php.
Finally, we would navigate forward to the browser history, and get the URL as −
https://www.tutorialspoint.com/selenium/practice/register.php.
We would also refresh the browser, after which we would obtain the URL as
https://www.tutorialspoint.com/selenium/practice/register.php.
Code Implementation
package org.example; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class BrowNavigationTo { public static void main(String[] args) throws InterruptedException { // Initiate the Webdriver WebDriver driver = new ChromeDriver(); // adding implicit wait of 15 secs driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); // launching a browser and navigate to a URL driver.navigate().to("https://www.tutorialspoint.com/selenium/practice/login.php"); // Getting browser title after launch System.out.println("Getting current URL after launch: " + driver.getCurrentUrl()); // identify a link then click WebElement l = driver.findElement(By.xpath("//*[@id='collapseTwo']/div/ul/li[3]/a")); l.click(); // Getting browser title after clicking link System.out.println("Getting current URL after clicking link: " + driver.getCurrentUrl()); // navigate back to browser history driver.navigate().back(); // Getting browser title after navigating back System.out.println ("Getting current URL after navigating back: " + driver.getCurrentUrl()); // navigate forward to browser history driver.navigate().forward(); // Getting browser title after navigating forward System.out.println("Getting current URL after navigating forward: " + driver.getCurrentUrl()); // refresh browser driver.navigate().refresh(); // Getting browser title after browser refresh System.out.println("Getting current URL after browser refresh: " + driver.getCurrentUrl()); // Closing browser driver.quit(); } }
Output
Getting current URL after launch: https://www.tutorialspoint.com/selenium/practice/login.php Getting current URL after clicking link: https://www.tutorialspoint.com/selenium/practice/register.php Getting current URL after navigating back: https://www.tutorialspoint.com/selenium/practice/login.php Getting current URL after navigating forward: https://www.tutorialspoint.com/selenium/practice/register.php Getting current URL after browser refresh: https://www.tutorialspoint.com/selenium/practice/register.php
In the above example, we had launched a URL in the opened browser and obtained the current URLwith the message in the console - Getting current URL after launch: https://www.tutorialspoint.com/selenium/practice/login.php.
We had then clicked on the Register link and received the current URL after navigation with the message in the console - Getting current URL after clicking link: https://www.tutorialspoint.com/selenium/practice/register.php.
Next, we had moved back in browser history and obtained the current URL after navigation with the message in the console - Getting current URL after navigating back: https://www.tutorialspoint.com/selenium/practice/login.php.
Again, we navigated forward in browser history and received the current URL after navigation with the message in the console - Getting current URL after navigating forward: https://www.tutorialspoint.com/selenium/practice/register.php.
Finally, we refreshed the browser and received the current URL with the message in the console - Getting current URL after browser refresh: https://www.tutorialspoint.com/selenium/practice/register.php.
Thus, in this tutorial, we had discussed how to perform browser navigation using the Selenium Webdriver.