Skip to content

Commit

Permalink
fix: Fix Closing Sidebar Drawer - Meeds-io/MIPs#175 (#308)
Browse files Browse the repository at this point in the history
Prior to this change, the Sidebar drawer overlay was relying on generic overlay only. With Site Layout changes, the overlay can be provided from Sidebar App too. This change is changing the algorithm for searching for
opened overlay to consider both cases.
  • Loading branch information
boubaker authored and exo-swf committed Feb 6, 2025
1 parent 9d4df65 commit 42fb1f6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/main/java/io/meeds/qa/ui/pages/BasePageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ public void attachImageToFileInput(ElementFacade fileInput, String fileName) {
waitForProgressBar();
}

public void pressEscape() {
findByXPathOrCSS("//body").sendKeys(Keys.ESCAPE);
}

private void closeDrawer() {
closeDrawer(MAX_WAIT_RETRIES);
}
Expand All @@ -703,10 +707,6 @@ private void closeDrawer(int i) {
}
}

private void pressEscape() {
findByXPathOrCSS("//body").sendKeys(Keys.ESCAPE);
}

private WebElementFacade getWebElementFacadeByXPathOrCSS(String xpathOrCss) {
if (StringUtils.contains(xpathOrCss, "//")) {
return find(By.xpath(xpathOrCss));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/meeds/qa/ui/pages/GenericPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ private ElementFacade messageElement(String message) {
}

private ElementFacade messageElementInPage(String message) {
return findByXPathOrCSS(String.format("//*[@id = 'UIPage']//*[contains(text(), '%s') and not (@role)]", message));
return findByXPathOrCSS(String.format("//*[@id = 'UIPage' or contains(@class, 'layout-page-parent')]//*[contains(text(), '%s') and not (@role)]",
message));
}

private ElementFacade translationButton(int index) {
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/io/meeds/qa/ui/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,17 @@ public void clickOnHamburgerMenu() {
}

public void clickOutsideHamburgerMenu() {
getDrawerOverlay().click();
ElementFacade drawerOverlay = getDrawerOverlay();
if (drawerOverlay.isCurrentlyVisible()) {
drawerOverlay.click();
} else {
drawerOverlay = getHamburgerMenuDrawerOverlay();
if (drawerOverlay.isCurrentlyVisible()) {
drawerOverlay.click();
} else {
pressEscape();
}
}
}

public void closeHamburgerMenu() {
Expand Down Expand Up @@ -694,6 +704,10 @@ private ElementFacade getDrawerOverlay() {
return findByXPathOrCSS("#drawers-overlay .v-overlay--active");
}

private ElementFacade getHamburgerMenuDrawerOverlay() {
return findByXPathOrCSS("#HamburgerNavigationMenu .v-overlay--active");
}

private ElementFacade getSiteBody() {
return findByXPathOrCSS("#UISiteBody");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/meeds/qa/ui/pages/UnifiedSearchPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private ElementFacade getUserSearchTitle(String user) {
}

private TextBoxElementFacade searchInputElement() {
return findTextBoxByXPathOrCSS("//*[@id='SearchApplication']//input[@id = 'searchInput']");
return findTextBoxByXPathOrCSS("//*[@id='searchDialog']//input[@id='searchInput']");
}

private ElementFacade shipFormAllElement() {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/meeds/qa/ui/hook/TestInitHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ private void loginAsAdmin() {
throw new IllegalStateException("Couldn't login with admin");
}
genericSteps.disableTermsAndConditions();
genericSteps.goToPage("/");
}

private void loginAsRandomAdmin() {
Expand Down
7 changes: 1 addition & 6 deletions src/test/java/io/meeds/qa/ui/steps/GenericSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,7 @@ public void disablePwa() {
}

public void disableTermsAndConditions() {
WebDriverWait wait = new WebDriverWait(Serenity.getDriver(),
Duration.ofSeconds(10),
Duration.ofMillis(SHORT_WAIT_DURATION_MILLIS));
wait.until(driver -> ((JavascriptExecutor) driver).executeAsyncScript(DISABLE_TERMS_SCRIPT)
.toString()
.equals("true"));
((JavascriptExecutor) Serenity.getDriver()).executeAsyncScript(DISABLE_TERMS_SCRIPT);
}

public void goToPage(String link) {
Expand Down

0 comments on commit 42fb1f6

Please sign in to comment.