-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavigation.java
More file actions
62 lines (48 loc) · 1.87 KB
/
Navigation.java
File metadata and controls
62 lines (48 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package basics;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
/**
* Created by jfarrier on 25/10/2016.
*/
public class Navigation {
public static void main(String[] args){
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver webdriver = new ChromeDriver();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
/*
When opening a url you can use either webdriver.navigate.to or webdriver.get. Both do the same thing.
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.
*/
webdriver.navigate().to("http://google.com");
//the webpage needs to include the http:// or https:// prefix.
//webdriver.navigate().to("http://www.google.com");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
webdriver.get("http://www.stackoverflow.com");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
webdriver.navigate().back();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
webdriver.navigate().forward();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
webdriver.navigate().refresh();
}
}