Monday 11 May 2015

Difference between Webdriver get() and Webdriver navigate() method in selenumn web driver API



Difference between Webdriver get() and Webdriver navigate() method in selenumn web driver API

The first thing is that you want to know that WebDriver is navigate to a page. The normal way to do this is by calling get method.
driver.get("http://silenumnmisc.blogspot.com ");
Webdriver API 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 API is loading then webdriver API may not know when it has loaded completely. If you need to make sure such pages are fully loaded then you can use waits.
Earlier, we had covered navigating to a page using the get command (driver.get("http://silenumnmisc.blogspot.com”))
 As you have seen, webdriver API 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 API interface, but it is simply a synonym to:
driver.navigate().to("http://silenumnmisc.blogspot.com ");
navigate().to() and get() do exactly the same one. Ounces just a lot easier to type than the other.
Navigate interface also has the ability to move backwards and forwards in your browser history:
driver.navigate().refresh();
driver.navigate().forward();
driver.navigate().back();
You can also use Actions class of WebDriver  API to perform page refresh with keyboard operation
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();

No comments:

Post a Comment