Invy Invy - 3 months ago 44
Java Question

Difference between webdriver.get() and webdriver.navigate()

What is the difference between get() and navigate() methods?
Does any of this or maybe another method waits for page content to load?
What do I really need is somehing likeselenium`s 1.0 WaitForPageToLoad but for using via webdriver. Any suggestions?



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:


WebDriver will wait until the page has fully loaded (that is, the onload event has fired) before returning control to your test or script. It’s worth noting that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded. If you need to ensure such pages are fully loaded then you can use waits.

Navigation: History and Location

Earlier, we covered navigating to a page using the get command (driver.get("")) As you’ve 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:


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

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


(Emphasis added)