-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelloSelenium.java
45 lines (36 loc) · 1 KB
/
HelloSelenium.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
35
36
37
38
39
40
41
42
43
44
45
package com.selenium.learn;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class HelloSelenium {
WebDriver driver;
String url = "https://www.google.com/";
@Before
public void setUp() {
//Set the key/value property according to the browser you are using.
System.setProperty("webdriver.chrome.driver","/home/ruthra/Selenium_Setup/chromedriver");
//Open browser instance
driver = new ChromeDriver();
//Open the AUT
driver.get(url);
}
@Test
public void test() throws InterruptedException {
//Fetch the page title
String pageTitle = driver.getTitle();
System.out.println("Page title: " + pageTitle);
//Hey Google
driver.findElement(By.name("q")).sendKeys("Hey World");
Thread.sleep(3000);
driver.findElement(By.name("btnK")).click();
Thread.sleep(5000);
}
@After
public void tearDown() {
//Close the browser
driver.close();
}
}