Navigation Command in Selenium Webdriver

.
Navigation Command in Selenium with Examples

Following are some of the most common browser navigation commands for the Selenium web driver.
  • Navigate to
  • Back 
  • Forward 
  • Refresh 
  • navigate().to(String)
In selenium, Webdriver navigate().to() method is used to load a new webpage in an existing window 
 
driver= new FirefoxDriver();
driver.navigate().to("http://www.google.com");
 
  • navigate().back()
In selenium webdriver navigate().back() navigation command used to click on the back button of the browser window.

driver= new FirefoxDriver();
driver.navigate().to("http://www.google.com");
driver.naviagte().back()
 
  • navigate().forward()
In selenium webdriver navigate().forward() navigation method used to click on the forward button of browser window.

driver= new FirefoxDriver();
driver.navigate().to("http://www.google.com");
driver.naviagte().forward()
 
  • navigate.refresh()
In selenium webdriver navigate().refresh() navigation method used to refresh browser window .

driver= new FirefoxDriver();
driver.navigate().to("http://www.google.com");
driver.naviagte().refresh


 Selenium code for navigation commands using Java
 

package New; 
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class AutomationTesting 
{
 
public static void main(String[] args) 
{
             
System.setProperty("webdriver.chrome.driver","D:\\Sandeep\\Soft\\chromedriver.exe");
              WebDriver driver= new ChromeDriver();
              driver.navigate().to("https://qaacharya.in/");
              driver.manage().window().maximize();
              driver.findElement(By.linkText("Testing Concepts")).click();
              driver.navigate().back();
              driver.navigate().forward();
              driver.navigate().refresh();
              driver.close();
 
       }
}
 

Hope!!! The above tutorial on the navigation method in selenium webdriver is helpful for you ...

Team,
QA acharya


Navigation Method in Selenium Webdriver