Skip to main content

Below are the difference between driver.get() and driver.navigate().to() method: 

  • Browser History: driver.get(url) does not maintain the browser history and cookies where as driver.navigate.to(url) maintains browser history and cookies.
  • Page Load: driver.get(url) wait till the page fully loaded where as driver.navigate.to(url) does not wait till the page fully loaded.
  • Forward/Backward: We can not move forward/backward between the pages with driver.get() but we can navigate between the pages back, forward and refresh with driver.navigate().
  • Speed: navigate() is faster than get() because navigate() does not wait for the page to load fully or completely.
  • Execution: get() method execute next line of code once the page is completely loaded but  navigate() method does not wait for loading of page, it executes once the url hit into searche-box.

There are Variations of Navigate to() method:

void to(java.lang.String url): Load a new web page in the current browser window. This is done using an HTTP GET operation, and the method will block until the load is complete. This will follow redirects issued either by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, since should the underlying page change whilst your test is executing the results of future calls against this interface will be against the freshly loaded page.

void to(java.net.URL url): Overloaded version of to(String) that makes it easy to pass in a URL.

About

Elix is a premium wordpress theme for portfolio, freelancer, design agencies and a wide range of other design institutions.