@@ -403,4 +403,142 @@ void shouldReturnButtonWithDeeperSrcText() {
403403 assertThat (loginLinks .size (), is (equalTo (1 )));
404404 assertThat (loginLinks .get (0 ).getAttributeValue ("custom" ), is (equalTo ("test" )));
405405 }
406+
407+ @ TestTemplate
408+ void shouldReturnSimpleWdRoleButton (WebDriver wd ) {
409+ // Given
410+ pageContent =
411+ () ->
412+ """
413+ <h1>Heading</h1>
414+ <a href="#link1">Link 1</a>
415+ <a href="#link2">Link 2</a>
416+ <a href="#link3">Link 3</a>
417+ <div role="button" custom="test">Sign in</div>
418+ <div/>
419+ """ ;
420+ wd .get (url );
421+ // When
422+ List <WebElement > loginLinks =
423+ LoginLinkDetector .getLoginLinks (wd , AuthUtils .LOGIN_LABELS_P1 );
424+
425+ // Then
426+ assertThat (loginLinks .size (), is (equalTo (1 )));
427+ assertThat (loginLinks .get (0 ).getDomAttribute ("custom" ), is (equalTo ("test" )));
428+ }
429+
430+ @ Test
431+ void shouldReturnSimpleWdRoleButton () {
432+ // Given
433+ String html =
434+ """
435+ <h1>Heading</h1>
436+ <a href="#link1">Link 1</a>
437+ <a href="#link2">Link 2</a>
438+ <a href="#link3">Link 3</a>
439+ <div role="button" custom="test">Sign in</div>
440+ <div/>
441+ """ ;
442+ // When
443+ List <Element > loginLinks =
444+ LoginLinkDetector .getLoginLinks (new Source (html ), AuthUtils .LOGIN_LABELS_P1 );
445+
446+ // Then
447+ assertThat (loginLinks .size (), is (equalTo (1 )));
448+ assertThat (loginLinks .get (0 ).getAttributeValue ("custom" ), is (equalTo ("test" )));
449+ }
450+
451+ @ TestTemplate
452+ void shouldReturnMultipleSimpleWdRoleButtons (WebDriver wd ) {
453+ // Given
454+ pageContent =
455+ () ->
456+ """
457+ <h1>Heading</h1>
458+ <a href="#link1">Link 1</a>
459+ <div role="button" custom="test1">Sign in</div>
460+ <a href="#link2">Link 2</a>
461+ <div role="button" custom="test2">Log In</div>
462+ <a href="#link3">Link 3</a>
463+ <div role="button" custom="test3">Log Out</div>
464+ <div/>
465+ """ ;
466+ wd .get (url );
467+ // When
468+ List <WebElement > loginLinks =
469+ LoginLinkDetector .getLoginLinks (wd , AuthUtils .LOGIN_LABELS_P1 );
470+
471+ // Then
472+ assertThat (loginLinks .size (), is (equalTo (2 )));
473+ assertThat (loginLinks .get (0 ).getDomAttribute ("custom" ), is (equalTo ("test1" )));
474+ assertThat (loginLinks .get (1 ).getDomAttribute ("custom" ), is (equalTo ("test2" )));
475+ }
476+
477+ @ Test
478+ void shouldReturnMultipleSimpleSrcRoleButtons () {
479+ // Given
480+ String html =
481+ """
482+ <h1>Heading</h1>
483+ <a href="#link1">Link 1</a>
484+ <div role="button" custom="test1">Sign in</div>
485+ <a href="#link2">Link 2</a>
486+ <div role="button" custom="test2">Log In</div>
487+ <a href="#link3">Link 3</a>
488+ <div role="button" custom="test3">Log Out</div>
489+ <div/>
490+ """ ;
491+ // When
492+ List <Element > loginLinks =
493+ LoginLinkDetector .getLoginLinks (new Source (html ), AuthUtils .LOGIN_LABELS_P1 );
494+
495+ // Then
496+ assertThat (loginLinks .size (), is (equalTo (2 )));
497+ assertThat (loginLinks .get (0 ).getAttributeValue ("custom" ), is (equalTo ("test1" )));
498+ assertThat (loginLinks .get (1 ).getAttributeValue ("custom" ), is (equalTo ("test2" )));
499+ }
500+
501+ @ TestTemplate
502+ void shouldReturnRoleButtonWithDeeperWdText (WebDriver wd ) {
503+ // Given
504+ pageContent =
505+ () ->
506+ """
507+ <h1>Heading</h1>
508+ <a href="#link1">Link 1</a>
509+ <a href="#link2">Link 2</a>
510+ <div role="button" custom="test"><div><div></div><div><div>Log in</div></div></div>
511+ <a href="#link3">Link 3</a>
512+ <div/>
513+ """ ;
514+ wd .get (url );
515+ // When
516+ List <WebElement > loginLinks =
517+ LoginLinkDetector .getLoginLinks (wd , AuthUtils .LOGIN_LABELS_P1 );
518+
519+ // Then
520+ assertThat (loginLinks .size (), is (equalTo (1 )));
521+ assertThat (loginLinks .get (0 ).getDomAttribute ("custom" ), is (equalTo ("test" )));
522+ }
523+
524+ @ Test
525+ void shouldReturnRoleButtonWithDeeperSrcText () {
526+ // Given
527+ String html =
528+ """
529+ <h1>Heading</h1>
530+ <a href="#link1">Link 1</a>
531+ <a href="#link2">Link 2</a>
532+ <div role="button" custom="test"><div><div></div><div><div>Log in</div></div></div></div>
533+ <a href="#link3">Link 3</a>
534+ <div/>
535+ """ ;
536+ // When
537+ List <Element > loginLinks =
538+ LoginLinkDetector .getLoginLinks (new Source (html ), AuthUtils .LOGIN_LABELS_P1 );
539+
540+ // Then
541+ assertThat (loginLinks .size (), is (equalTo (1 )));
542+ assertThat (loginLinks .get (0 ).getAttributeValue ("custom" ), is (equalTo ("test" )));
543+ }
406544}
0 commit comments