11package manytools ;
22
33import aquality .selenium .browser .AqualityServices ;
4+ import aquality .selenium .core .elements .ElementState ;
45import aquality .selenium .core .utilities .IActionRetrier ;
56import aquality .selenium .elements .interfaces .IButton ;
67import aquality .selenium .elements .interfaces .ILabel ;
1213
1314public abstract class ManyToolsForm <T extends ManyToolsForm <T >> extends Form {
1415 private static final String BASE_URL = "https://manytools.org/" ;
15- private final ILabel lblValue = getFormLabel ().findChildElement (By .xpath (".//code" ), getName (), ILabel .class );
16- private final IButton btnAgree = getElementFactory ().getButton (By .xpath ("//button[@mode='primary']" ), "Agree" );
16+ private final ILabel lblValue = getFormLabel ().findChildElement (By .xpath (".//code" ), getName (), ILabel .class , ElementState .EXISTS_IN_ANY_STATE );
17+ private final ILabel lblConsentDialog = getElementFactory ().getLabel (By .id ("cmpwrapper" ), "Cookie consent dialog" , ElementState .EXISTS_IN_ANY_STATE );
18+ private final IButton btnDecline = lblConsentDialog .findElementInShadowRoot (By .id ("cmpbntnotxt" ), "Decline cookies" , IButton .class );
1719
1820 protected ManyToolsForm (String name ) {
1921 super (By .id ("maincontent" ), name );
@@ -25,7 +27,13 @@ protected ManyToolsForm(String name) {
2527 public T open () {
2628 AqualityServices .get (IActionRetrier .class ).doWithRetry (() -> {
2729 AqualityServices .getBrowser ().goTo (BASE_URL + getUrlPart ());
30+ state ().waitForDisplayed ();
2831 }, Collections .singletonList (TimeoutException .class ));
32+
33+ if (lblConsentDialog .state ().isExist () && btnDecline .state ().isDisplayed ()) {
34+ btnDecline .click ();
35+ lblConsentDialog .state ().waitForNotDisplayed ();
36+ }
2937 return (T ) this ;
3038 }
3139
0 commit comments