-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindCssChildren.java
More file actions
40 lines (33 loc) · 1.05 KB
/
FindCssChildren.java
File metadata and controls
40 lines (33 loc) · 1.05 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
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class FindCssChildren {
private WebDriver driver;
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver");
driver = new ChromeDriver();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void testFindUserName() {
driver.get("http://localhost:8080/workspace/xpath.html");
WebElement username =
driver.findElement(By.cssSelector("form input:first-of-type"));
assertEquals("username2307", username.getAttribute("name"));
}
@Test(expected = NoSuchElementException.class)
public void testNotFindUserName() {
driver.get("http://localhost:8080/workspace/xpath.html");
driver.findElement(By.cssSelector("form input:first-child"));
}
}