diff --git a/src/org/labkey/test/components/ui/navigation/NavBar.java b/src/org/labkey/test/components/ui/navigation/NavBar.java index 35b6de009c..fa50f83ebe 100644 --- a/src/org/labkey/test/components/ui/navigation/NavBar.java +++ b/src/org/labkey/test/components/ui/navigation/NavBar.java @@ -95,7 +95,7 @@ public String getUserAvatarSource() */ public ServerNotificationMenu getNotificationMenu() { - return elementCache().notificationsMenu; + return elementCache().notificationsMenu(); } public ProductMenu getProductMenu() @@ -130,6 +130,9 @@ protected abstract class ElementCache extends Component.ElementCac public Input searchBox = Input.Input(Locator.tagWithClass("input", "navbar__search-input"), getDriver()).refindWhenNeeded(this); public MultiMenu searchMenu = new MultiMenu.MultiMenuFinder(getDriver()).withButtonClass("navbar__find-and-search-button").refindWhenNeeded(this); public final ProductMenu productMenu = ProductMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this); - public final ServerNotificationMenu notificationsMenu = ServerNotificationMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this); + public final ServerNotificationMenu notificationsMenu() + { + return ServerNotificationMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this); + } } } diff --git a/src/org/labkey/test/components/ui/notifications/ServerNotificationMenu.java b/src/org/labkey/test/components/ui/notifications/ServerNotificationMenu.java index 896dc89d26..fd35d3a3d5 100644 --- a/src/org/labkey/test/components/ui/notifications/ServerNotificationMenu.java +++ b/src/org/labkey/test/components/ui/notifications/ServerNotificationMenu.java @@ -139,7 +139,7 @@ public boolean isMarkAllVisible() protected boolean isExpanded() { boolean ariaExpanded = "true".equals(elementCache().toggle.getAttribute("aria-expanded")); - boolean menuContentDisplayed = elementCache().menuContent.isDisplayed(); + boolean menuContentDisplayed = elementCache().menuContent().isDisplayed(); return ariaExpanded && menuContentDisplayed; } @@ -201,16 +201,14 @@ private WebElement waitForNotificationList() // Wait for the listing container to show up. The listing container is in the open menu, scope the search to that. Locator notificationsContainerLocator = Locator.tagWithClass("div", "server-notifications-listing-container"); - WebDriverWrapper.waitFor(()-> notificationsContainerLocator.refindWhenNeeded(elementCache().menuContent).isDisplayed(), + WebDriverWrapper.waitFor(()-> notificationsContainerLocator.areAnyVisible(elementCache().menuContent()), "List container did not render.", 500); // Find again (lambda requires a final reference to the component). - WebElement listContainer = notificationsContainerLocator.refindWhenNeeded(elementCache().menuContent); + WebElement listContainer = notificationsContainerLocator.refindWhenNeeded(elementCache().menuContent()); // It may be a moment before any notifications show up. - WebDriverWrapper.waitFor(()-> Locator.tagWithClass("ul", "server-notifications-listing") - .refindWhenNeeded(listContainer) - .isDisplayed(), + WebDriverWrapper.waitFor(()-> Locator.tagWithClass("ul", "server-notifications-listing").areAnyVisible(listContainer), "There are no notifications in the drop down.", 1_000); // Just wait for a moment in case the list is slow to update with the most recent notification. @@ -223,7 +221,7 @@ private WebElement waitForNotificationList() // Find the container again, don't return listContainer WebElement previously found. If the list was slow to // update with the most recent notification the old reference will be stale. - return notificationsContainerLocator.refindWhenNeeded((elementCache().menuContent)); + return notificationsContainerLocator.refindWhenNeeded((elementCache().menuContent())); } /** @@ -282,7 +280,10 @@ protected ServerNotificationMenu.ElementCache newElementCache() protected class ElementCache extends Component.ElementCache { - public final WebElement menuContent = Locator.byClass("navbar-menu__content").refindWhenNeeded(this); + public final WebElement menuContent() + { + return Locator.byClass("navbar-menu__content").refindWhenNeeded(this); + } public final WebElement toggle = Locator.byClass("navbar-menu-button").refindWhenNeeded(this); @@ -293,14 +294,14 @@ public final WebElement statusIcon() public final WebElement noNotificationsElement() { - return Locator.tagWithClass("div", "server-notifications-footer").refindWhenNeeded(elementCache().menuContent); + return Locator.tagWithClass("div", "server-notifications-footer").refindWhenNeeded(elementCache().menuContent()); } public final WebElement markAll() { return Locator.tagWithClass("h3", "navbar-menu-header") .child(Locator.byClass("clickable-text")) - .refindWhenNeeded(elementCache().menuContent); + .refindWhenNeeded(elementCache().menuContent()); } public final WebElement viewAllLink()