Skip to content

Commit d4e3abb

Browse files
committed
Stabilize ManyTools site navigation and waits
1 parent 0391d22 commit d4e3abb

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/test/java/manytools/ManyToolsForm.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package manytools;
22

33
import aquality.selenium.browser.AqualityServices;
4+
import aquality.selenium.core.elements.ElementState;
45
import aquality.selenium.core.utilities.IActionRetrier;
56
import aquality.selenium.elements.interfaces.IButton;
67
import aquality.selenium.elements.interfaces.ILabel;
@@ -12,8 +13,9 @@
1213

1314
public 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

src/test/java/manytools/RequestHeadersForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public String getValue() {
2323
}
2424

2525
public String getNullableValue(String headerName) {
26-
getFormLabel().state().waitForDisplayed();
26+
getHeaderValueLabel.apply("Accept").state().waitForDisplayed();
2727
ILabel valueLabel = getHeaderValueLabel.apply(headerName);
2828
return valueLabel.state().isDisplayed() ? valueLabel.getText() : null;
2929
}

0 commit comments

Comments
 (0)