-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSample1.java
34 lines (26 loc) · 989 Bytes
/
Sample1.java
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
package selenium.sample;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Sample1 {
static String libWithDriversLocation = System.getProperty("user.dir") + "\\lib\\";
@Test
public void goToHomepage() throws Exception {
//define driver
System.setProperty("webdriver.chrome.driver", libWithDriversLocation + "chromedriver.exe");
WebDriver driver = new ChromeDriver();
//open test homepage
driver.get("https://google.com");
driver.get("https://kristinek.github.io/site/");
System.out.println(driver.findElement(By.id("h1")).getText());
//get title of page
System.out.println(driver.getTitle());
//get URL of current page
System.out.println(driver.getCurrentUrl());
//Sleep for 10 seconds
Thread.sleep(10000);
//Close browser
driver.quit();
}
}