33
33
import org .openqa .selenium .WebElement ;
34
34
import org .openqa .selenium .htmlunit .WebDriverTestCase ;
35
35
import org .openqa .selenium .htmlunit .junit .BrowserRunner ;
36
+ import org .openqa .selenium .htmlunit .junit .BrowserRunner .Alerts ;
37
+ import org .openqa .selenium .htmlunit .junit .BrowserRunner .HtmlUnitNYI ;
36
38
37
39
/**
38
40
* Tests for RelativeLocator.
43
45
public class RelativeLocatorTest extends WebDriverTestCase {
44
46
45
47
@ Test
48
+ @ Alerts ({"2" , "mid" , "above" })
49
+ @ HtmlUnitNYI (CHROME = {"1" , "above" , "above" },
50
+ EDGE = {"1" , "above" , "above" },
51
+ FF = {"1" , "above" , "above" },
52
+ FF_ESR = {"1" , "above" , "above" })
46
53
public void shouldBeAbleToFindElementsAboveAnotherWithTagName () throws Exception {
47
54
final String html = getFileContent ("relative_locators.html" );
48
55
final WebDriver driver = loadPage2 (html );
@@ -52,12 +59,17 @@ public void shouldBeAbleToFindElementsAboveAnotherWithTagName() throws Exception
52
59
final List <WebElement > seen = driver .findElements (with (tagName ("p" )).above (lowest ));
53
60
final List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
54
61
55
- assertEquals (2 , ids .size ());
56
- assertTrue (ids .contains ("mid" ));
57
- assertTrue (ids .contains ("above" ));
62
+ assertEquals (Integer . parseInt ( getExpectedAlerts ()[ 0 ]) , ids .size ());
63
+ assertTrue (ids .contains (getExpectedAlerts ()[ 1 ] ));
64
+ assertTrue (ids .contains (getExpectedAlerts ()[ 2 ] ));
58
65
}
59
66
60
67
@ Test
68
+ @ Alerts ({"2" , "fourth" , "first" })
69
+ @ HtmlUnitNYI (CHROME = {"1" , "first" , "first" },
70
+ EDGE = {"1" , "first" , "first" },
71
+ FF = {"1" , "first" , "first" },
72
+ FF_ESR = {"1" , "first" , "first" })
61
73
public void shouldBeAbleToFindElementsAboveAnotherWithXpath () throws Exception {
62
74
final String html = getFileContent ("relative_locators.html" );
63
75
final WebDriver driver = loadPage2 (html );
@@ -67,12 +79,17 @@ public void shouldBeAbleToFindElementsAboveAnotherWithXpath() throws Exception {
67
79
final List <WebElement > seen = driver .findElements (with (xpath ("//td[1]" )).above (lowest ));
68
80
final List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
69
81
70
- assertEquals (2 , ids .size ());
71
- assertTrue (ids .contains ("fourth" ));
72
- assertTrue (ids .contains ("first" ));
82
+ assertEquals (Integer . parseInt ( getExpectedAlerts ()[ 0 ]) , ids .size ());
83
+ assertTrue (ids .contains (getExpectedAlerts ()[ 1 ] ));
84
+ assertTrue (ids .contains (getExpectedAlerts ()[ 2 ] ));
73
85
}
74
86
75
87
@ Test
88
+ @ Alerts ({"2" , "mid" , "above" })
89
+ @ HtmlUnitNYI (CHROME = {"1" , "above" , "above" },
90
+ EDGE = {"1" , "above" , "above" },
91
+ FF = {"1" , "above" , "above" },
92
+ FF_ESR = {"1" , "above" , "above" })
76
93
public void shouldBeAbleToFindElementsAboveAnotherWithCssSelector () throws Exception {
77
94
final String html = getFileContent ("relative_locators.html" );
78
95
final WebDriver driver = loadPage2 (html );
@@ -82,12 +99,13 @@ public void shouldBeAbleToFindElementsAboveAnotherWithCssSelector() throws Excep
82
99
final List <WebElement > seen = driver .findElements (with (cssSelector ("p" )).above (lowest ));
83
100
final List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
84
101
85
- assertEquals (2 , ids .size ());
86
- assertTrue (ids .contains ("mid" ));
87
- assertTrue (ids .contains ("above" ));
102
+ assertEquals (Integer . parseInt ( getExpectedAlerts ()[ 0 ]) , ids .size ());
103
+ assertTrue (ids .contains (getExpectedAlerts ()[ 1 ] ));
104
+ assertTrue (ids .contains (getExpectedAlerts ()[ 2 ] ));
88
105
}
89
106
90
107
@ Test
108
+ @ Alerts ({"1" , "third" })
91
109
public void shouldBeAbleToCombineFilters () throws Exception {
92
110
final String html = getFileContent ("relative_locators.html" );
93
111
final WebDriver driver = loadPage2 (html );
@@ -96,11 +114,12 @@ public void shouldBeAbleToCombineFilters() throws Exception {
96
114
with (tagName ("td" )).above (By .id ("center" )).toRightOf (By .id ("second" )));
97
115
final List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
98
116
99
- assertEquals (1 , ids .size ());
100
- assertTrue (ids .contains ("third" ));
117
+ assertEquals (Integer . parseInt ( getExpectedAlerts ()[ 0 ]) , ids .size ());
118
+ assertTrue (ids .contains (getExpectedAlerts ()[ 1 ] ));
101
119
}
102
120
103
121
@ Test
122
+ @ Alerts ({"1" , "fourth" })
104
123
public void shouldBeAbleToCombineFiltersWithXpath () throws Exception {
105
124
final String html = getFileContent ("relative_locators.html" );
106
125
final WebDriver driver = loadPage2 (html );
@@ -109,11 +128,12 @@ public void shouldBeAbleToCombineFiltersWithXpath() throws Exception {
109
128
with (xpath ("//td[1]" )).below (By .id ("second" )).above (By .id ("seventh" )));
110
129
final List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
111
130
112
- assertEquals (1 , ids .size ());
113
- assertTrue (ids .contains ("fourth" ));
131
+ assertEquals (Integer . parseInt ( getExpectedAlerts ()[ 0 ]) , ids .size ());
132
+ assertTrue (ids .contains (getExpectedAlerts ()[ 1 ] ));
114
133
}
115
134
116
135
@ Test
136
+ @ Alerts ({"1" , "third" })
117
137
public void shouldBeAbleToCombineFiltersWithCssSelector () throws Exception {
118
138
final String html = getFileContent ("relative_locators.html" );
119
139
final WebDriver driver = loadPage2 (html );
@@ -122,8 +142,8 @@ public void shouldBeAbleToCombineFiltersWithCssSelector() throws Exception {
122
142
with (cssSelector ("td" )).above (By .id ("center" )).toRightOf (By .id ("second" )));
123
143
final List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
124
144
125
- assertEquals (1 , ids .size ());
126
- assertTrue (ids .contains ("third" ));
145
+ assertEquals (Integer . parseInt ( getExpectedAlerts ()[ 0 ]) , ids .size ());
146
+ assertTrue (ids .contains (getExpectedAlerts ()[ 1 ] ));
127
147
}
128
148
129
149
@ Test
0 commit comments