3030import org .openqa .selenium .By ;
3131import org .openqa .selenium .NoSuchElementException ;
3232import org .openqa .selenium .WebElement ;
33- import org .openqa .selenium .environment .webserver .Page ;
3433import org .openqa .selenium .testing .JupiterTestBase ;
3534
3635class RelativeLocatorTest extends JupiterTestBase {
@@ -82,7 +81,7 @@ void shouldBeAbleToFindElementsBelowAnother() {
8281
8382 List <WebElement > elements = driver .findElements (with (tagName ("p" )).below (midpoint ));
8483 List <String > ids =
85- elements .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
84+ elements .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
8685
8786 assertThat (ids ).containsExactly ("below" );
8887 }
@@ -196,7 +195,7 @@ void shouldBeAbleToCombineFilters() {
196195 driver .get (appServer .whereIs ("relative_locators.html" ));
197196
198197 List <WebElement > seen =
199- driver .findElements (with (tagName ("td" )).above (By .id ("center" )).toRightOf (By .id ("top" )));
198+ driver .findElements (with (tagName ("td" )).above (By .id ("center" )).toRightOf (By .id ("top" )));
200199
201200 List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
202201
@@ -220,8 +219,7 @@ void shouldBeAbleToCombineFiltersWithCssSelector() {
220219 driver .get (appServer .whereIs ("relative_locators.html" ));
221220
222221 List <WebElement > seen =
223- driver .findElements (
224- with (cssSelector ("td" )).above (By .id ("center" )).toRightOf (By .id ("top" )));
222+ driver .findElements (with (cssSelector ("td" )).above (By .id ("center" )).toRightOf (By .id ("top" )));
225223
226224 List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
227225
@@ -244,19 +242,20 @@ void exerciseNearLocatorWithTagName() {
244242 // 5-8. Diagonally close (pythagoras sorting, with top row first
245243 // because of DOM insertion order)
246244 List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
247- assertThat (ids ). containsExactly (
248- "top" , "bottom" , "left" , "right" , "topLeft" , "topRight" , "bottomLeft" , "bottomRight"
249- );
245+ assertThat (ids )
246+ . containsExactly (
247+ "top" , "bottom" , "left" , "right" , "topLeft" , "topRight" , "bottomLeft" , "bottomRight" );
250248 }
251249
252250 @ Test
253251 void shouldBeAbleToCombineStraightFilters () {
254252 driver .get (appServer .whereIs ("relative_locators.html" ));
255253
256- List <WebElement > seen = driver .findElements (with (tagName ("td" ))
257- .straightBelow (By .id ("topRight" ))
258- .straightRight (By .id ("bottomLeft" ))
259- );
254+ List <WebElement > seen =
255+ driver .findElements (
256+ with (tagName ("td" ))
257+ .straightBelow (By .id ("topRight" ))
258+ .straightRight (By .id ("bottomLeft" )));
260259
261260 List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
262261
@@ -280,9 +279,9 @@ void exerciseNearLocatorWithXpath() {
280279 // because of DOM insertion order)
281280 List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
282281
283- assertThat (ids ). containsExactly (
284- "top" , "bottom" , "left" , "right" , "topLeft" , "topRight" , "bottomLeft" , "bottomRight"
285- );
282+ assertThat (ids )
283+ . containsExactly (
284+ "top" , "bottom" , "left" , "right" , "topLeft" , "topRight" , "bottomLeft" , "bottomRight" );
286285 }
287286
288287 @ Test
@@ -301,9 +300,9 @@ void exerciseNearLocatorWithCssSelector() {
301300 // 5-8. Diagonally close (pythagoras sorting, with top row first
302301 // because of DOM insertion order)
303302 List <String > ids = seen .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .toList ());
304- assertThat (ids ). containsExactly (
305- "top" , "bottom" , "left" , "right" , "topLeft" , "topRight" , "bottomLeft" , "bottomRight"
306- );
303+ assertThat (ids )
304+ . containsExactly (
305+ "top" , "bottom" , "left" , "right" , "topLeft" , "topRight" , "bottomLeft" , "bottomRight" );
307306 }
308307
309308 @ Test
@@ -316,9 +315,10 @@ void ensureNoRepeatedElements() {
316315 WebElement a = driver .findElement (By .id ("a" ));
317316 WebElement b = driver .findElement (By .id ("b" ));
318317
319- assertThat (cells ).describedAs (
320- cells .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .joining (", " ))
321- ).isEqualTo (List .of (b , a ));
318+ assertThat (cells )
319+ .describedAs (
320+ cells .stream ().map (e -> e .getAttribute ("id" )).collect (Collectors .joining (", " )))
321+ .isEqualTo (List .of (b , a ));
322322 }
323323
324324 @ Test
@@ -338,7 +338,7 @@ void nearLocatorShouldNotFindFarElements() {
338338 WebElement rect3 = driver .findElement (By .id ("rect3" ));
339339
340340 assertThatExceptionOfType (NoSuchElementException .class )
341- .isThrownBy (() -> driver .findElement (with (By .id ("rect4" )).near (rect3 )))
342- .withMessageContaining ("Cannot locate an element using" );
341+ .isThrownBy (() -> driver .findElement (with (By .id ("rect4" )).near (rect3 )))
342+ .withMessageContaining ("Cannot locate an element using" );
343343 }
344344}
0 commit comments