Thursday, July 7, 2016
Sample webdriver scripts to Navigate url
Two
methods:
Method
1:
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
public
class goTo {
public
static void main(String[] args) {
//
TODO Auto-generated method stub
WebDriver
driver = new ChromeDriver();
driver.get("https://www.google.com");
}
}
Method
2:
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
public
class goTo {
public
static void main(String[] args) {
//
TODO Auto-generated method stub
WebDriver
driver = new ChromeDriver();
driver.navigate().to("https://www.google.com");
}
}
Differences
between navigate().to() and get()
Webdriver
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 is loading then webdriver 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 covered navigating to a page using the get command
(driver.get("http://www.example.com"))
As you have 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:
Subscribe to:
Posts (Atom)