Difference between Webdriver get() and navigate()


In this post,we will see the difference between Webdriver get() and navigate().
We will use Firefox browser in our demos. The same methods will work for all other browsers.
There are 2 ways, you can open the application in the browser.
  1. get() method
  2. navigate() method
get and naviagate

1. get() method: 

After opening the browser, we need to use the below method to open any particular application. This methods requires the URL of the application.
driver.get(“URL of the application”);
Don't Forget Note Means Important Remember Forgetting
URL should start with Http: instead of WWW. If URL starts with ‘WWW’, then selenium does not open it.
e.g. Valid is http://www.gmail.com
Invalid is www.gmail.com
Code for using get method to open Gmail application:

2. navigate() method:
This is another method which can be used to open the application.
driver.navigate().to(“URL of application”);
Code for using navigate function to open application:

What is the difference between get() method and navigate() method?
The difference is that if you use navigate, it allows you to go forth and back into history of the browser,refresh the browser etc. It is not possible if using get() method.
driver.navigate().back(); // Perform backward function of browser
driver.navigate().forward();  // Perform forward function of browser
driver.navigate().refresh(); //refresh the browser

Followers