Hey there! any question in your mind? Ask It Now!.
My Account

Difference Between get and navigate in selenium WebDriver.

+2 votes
1,550 views
asked in QA Automation Testing by Sourabh

Hi , I am automating a website and using .get() to hit URL. there is also a option to hit URL i.e .navigate() . Now I want to know the difference between these methods?

 

driver.get("URL");

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


Does these methods have different- different role?

1 Answer

+2 votes
answered by tester (1,550 points)
edited by Bhartesh
 
Best answer
Get method:

 
Basically, both methods are used for the same purpose, And the purpose is to navigate a URL(a web page). If we talk about getting() method, a URL is passed as a parameter in this method like:

 

driver.get(www.yoursfriends.com);

 

Here when this method is called its navigates to the webpage(yoursfriends.com) if the page is containing the js files or Ajax of the flash file so it would hold the process till then the page is loaded completely then the another action is performed. like

 

Step 1. driver.get();

Step 2. element.click();

 

Here, till then the page is completely loaded click is not to be performed.

 

navigate method:

 

Navigate method is also used to navigate a URL we can navigate to any URL by this method like driver.navigate.to(“ URL”); But here is the benefit that we can go back and forward in the browser history like:

 

driver.navigate().forward();

driver.navigate().back();

 

So we can say that both method do exactly same thing.

I hope it helped you!

Related Questions

Not a Member yet?

Answer Queue Login
131 Folks are online
0 members and 131 guest online