selenium tutorial testing tools

Difference between Webdriver get() and Webdriver navigate()

driver.get("URL")
The first thing you’ll want to do with WebDriver is navigate to a page. The normal way to do this is by calling get:

driver.get("http://www.google.com");

Webdriver will wait until the page has fully loaded before returning the control to test or script. If there many ajax calls in the current page which webdriver is loading then webdriver may not know when it has loaded completely. If you need to make sure such pages are fully loaded then you can use waits.

driver.navigate().to("URL")

Earlier, we covered navigating to a page using the get command (driver.get("http://www.example.com")) As you have seen, webdriver has a number of smaller, task-focused interfaces, and navigation is a useful task. Because loading a page is such a fundamental requirement, the method to do this lives on the main Webdriver interface, but it’s simply a synonym to:

driver.navigate().to("http://www.google.com");

navigate().to() and get() do exactly the same thing. One's just a lot easier to type than the other!

The navigate interface also has the ability to move backwards and forwards in your browser’s history:

driver.navigate().refresh();
driver.navigate().forward();
driver.navigate().back();

We can also use Actions class of WebDriver to perform page refresh

Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();

Check here for examples on Navigation methods in webdriver
For more information please refer Selenium Docs

Selenium Tutorials: 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.