-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindCheckBoxes.java
More file actions
62 lines (46 loc) · 1.42 KB
/
findCheckBoxes.java
File metadata and controls
62 lines (46 loc) · 1.42 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
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.util.ArrayList;
import java.util.List;
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.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class findCheckBoxes {
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 testCheckedLanguages() {
driver.get("http://localhost:8080/workspace/xpath.html");
List<WebElement> languages = driver.findElements(By.cssSelector(
"#languages li input:checked ~ label"));
String[] expected = {"English", "Spanish"};
List<String> actual = new ArrayList();
for(WebElement language:languages) {
actual.add(language.getText());
}
assertArrayEquals(expected,actual.toArray());
}
@Test
public void testCheckedSkills() {
driver.get("http://localhost:8080/workspace/xpath.html");
List<WebElement> skills = driver.findElements(By.cssSelector(
"#skills li input:checked~p"));
String[] expected = {"Java", "C#"};
List<String> actual = new ArrayList();
for(WebElement skill:skills) {
actual.add(skill.getText());
}
assertArrayEquals(expected,actual.toArray());
}
}