Navigation Method in Selenium Webdriver

Navigation Methods in Webdriver with Examples

Following are some of most common browser navigation command for selenium webdriver .
  • Navigate to
  • Back 
  • Forward 
  • Refresh 
  • navigate().to(String)
In selenium Webdriver navigate().to() method used to load a new webpage in 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 back button of 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 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 command 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 of navigation method in selenium webdriver helpful for you ...
Team
QA acharya


Tags :Navigation command in selenium ,Webdriver navigation method , types of navigation methods in selenium , navigate in selenium 


Navigation Method in Selenium Webdriver