-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathMultiChoiceBoxTests.java
More file actions
105 lines (79 loc) · 3.48 KB
/
MultiChoiceBoxTests.java
File metadata and controls
105 lines (79 loc) · 3.48 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package tests.integration.elements;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import tests.BaseTest;
import w3schools.W3SchoolsPage;
import w3schools.forms.SelectMultipleForm;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class MultiChoiceBoxTests extends BaseTest {
private final SelectMultipleForm selectMultipleForm = new SelectMultipleForm();
@BeforeMethod
@Override
public void beforeMethod() {
getBrowser().goTo(W3SchoolsPage.SELECT_MULTIPLE.getAddress());
getBrowser().waitForPageToLoad();
getBrowser().setWindowSize(defaultSize.width, defaultSize.height);
selectMultipleForm.acceptCookies();
selectMultipleForm.switchToResultFrame();
}
@Test
public void testSelectAll() {
List<String> allTexts = selectMultipleForm.getAllTexts();
selectMultipleForm.selectAll();
List<String> selected = selectMultipleForm.getSelectedTexts();
Assert.assertEquals(allTexts, selected, "Not all texts were selected");
selected = selectMultipleForm.getSelectedValues();
selectMultipleForm.submit();
Assert.assertEquals(selectMultipleForm.getValuesFromResult(), selected);
}
@Test
public void testDeselectByValue() {
List<String> valuesToRemove = Stream.of("volvo", "saab").collect(Collectors.toList());
selectMultipleForm.selectAll();
List<String> remaining = selectMultipleForm.deselectByValue(valuesToRemove);
selectMultipleForm.submit();
Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining);
}
@Test
public void testDeselectByContainingValue() {
List<String> valuesToRemove = Stream.of("saa", "ope").collect(Collectors.toList());
selectMultipleForm.selectAll();
List<String> remaining = selectMultipleForm.deselectByContainingValue(valuesToRemove);
selectMultipleForm.submit();
Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining);
}
@Test
public void testDeselectByText() {
List<String> valuesToRemove = Stream.of("Opel").collect(Collectors.toList());
selectMultipleForm.selectAll();
List<String> remaining = selectMultipleForm.deselectByText(valuesToRemove);
selectMultipleForm.submit();
Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining);
}
@Test
public void testDeselectByContainingText() {
List<String> valuesToRemove = Stream.of("Au", "Vol").collect(Collectors.toList());
selectMultipleForm.selectAll();
List<String> remaining = selectMultipleForm.deselectByContainingText(valuesToRemove);
selectMultipleForm.submit();
Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining);
}
@Test
public void testDeselectByIndex() {
List<Integer> valuesToRemove = Stream.of(2, 3).collect(Collectors.toList());
selectMultipleForm.selectAll();
List<String> remaining = selectMultipleForm.deselectByIndex(valuesToRemove);
selectMultipleForm.submit();
Assert.assertEquals(selectMultipleForm.getValuesFromResult(), remaining);
}
@Test
public void testDeselectAll() {
selectMultipleForm.selectAll();
selectMultipleForm.deselectAll();
selectMultipleForm.submit();
Assert.assertTrue(selectMultipleForm.getValuesFromResult().isEmpty());
}
}