Skip to content

Commit e4cbf7c

Browse files
Make the inventory location search results more reliable.
Avoid using stale elements when dealing with the status menu.
1 parent b39236e commit e4cbf7c

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/org/labkey/test/components/ui/navigation/NavBar.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public String getUserAvatarSource()
9595
*/
9696
public ServerNotificationMenu getNotificationMenu()
9797
{
98-
return elementCache().notificationsMenu;
98+
return elementCache().notificationsMenu();
9999
}
100100

101101
public ProductMenu getProductMenu()
@@ -130,6 +130,9 @@ protected abstract class ElementCache extends Component<ElementCache>.ElementCac
130130
public Input searchBox = Input.Input(Locator.tagWithClass("input", "navbar__search-input"), getDriver()).refindWhenNeeded(this);
131131
public MultiMenu searchMenu = new MultiMenu.MultiMenuFinder(getDriver()).withButtonClass("navbar__find-and-search-button").refindWhenNeeded(this);
132132
public final ProductMenu productMenu = ProductMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this);
133-
public final ServerNotificationMenu notificationsMenu = ServerNotificationMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this);
133+
public final ServerNotificationMenu notificationsMenu()
134+
{
135+
return ServerNotificationMenu.finder(getDriver()).timeout(1000).refindWhenNeeded(this);
136+
}
134137
}
135138
}

src/org/labkey/test/components/ui/notifications/ServerNotificationMenu.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public boolean isMarkAllVisible()
139139
protected boolean isExpanded()
140140
{
141141
boolean ariaExpanded = "true".equals(elementCache().toggle.getAttribute("aria-expanded"));
142-
boolean menuContentDisplayed = elementCache().menuContent.isDisplayed();
142+
boolean menuContentDisplayed = elementCache().menuContent().isDisplayed();
143143

144144
return ariaExpanded && menuContentDisplayed;
145145
}
@@ -201,16 +201,14 @@ private WebElement waitForNotificationList()
201201

202202
// Wait for the listing container to show up. The listing container is in the open menu, scope the search to that.
203203
Locator notificationsContainerLocator = Locator.tagWithClass("div", "server-notifications-listing-container");
204-
WebDriverWrapper.waitFor(()-> notificationsContainerLocator.refindWhenNeeded(elementCache().menuContent).isDisplayed(),
204+
WebDriverWrapper.waitFor(()-> notificationsContainerLocator.areAnyVisible(elementCache().menuContent()),
205205
"List container did not render.", 500);
206206

207207
// Find again (lambda requires a final reference to the component).
208-
WebElement listContainer = notificationsContainerLocator.refindWhenNeeded(elementCache().menuContent);
208+
WebElement listContainer = notificationsContainerLocator.refindWhenNeeded(elementCache().menuContent());
209209

210210
// It may be a moment before any notifications show up.
211-
WebDriverWrapper.waitFor(()-> Locator.tagWithClass("ul", "server-notifications-listing")
212-
.refindWhenNeeded(listContainer)
213-
.isDisplayed(),
211+
WebDriverWrapper.waitFor(()-> Locator.tagWithClass("ul", "server-notifications-listing").areAnyVisible(listContainer),
214212
"There are no notifications in the drop down.", 1_000);
215213

216214
// 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()
223221

224222
// Find the container again, don't return listContainer WebElement previously found. If the list was slow to
225223
// update with the most recent notification the old reference will be stale.
226-
return notificationsContainerLocator.refindWhenNeeded((elementCache().menuContent));
224+
return notificationsContainerLocator.refindWhenNeeded((elementCache().menuContent()));
227225
}
228226

229227
/**
@@ -282,7 +280,10 @@ protected ServerNotificationMenu.ElementCache newElementCache()
282280

283281
protected class ElementCache extends Component<?>.ElementCache
284282
{
285-
public final WebElement menuContent = Locator.byClass("navbar-menu__content").refindWhenNeeded(this);
283+
public final WebElement menuContent()
284+
{
285+
return Locator.byClass("navbar-menu__content").refindWhenNeeded(this);
286+
}
286287

287288
public final WebElement toggle = Locator.byClass("navbar-menu-button").refindWhenNeeded(this);
288289

@@ -293,14 +294,14 @@ public final WebElement statusIcon()
293294

294295
public final WebElement noNotificationsElement()
295296
{
296-
return Locator.tagWithClass("div", "server-notifications-footer").refindWhenNeeded(elementCache().menuContent);
297+
return Locator.tagWithClass("div", "server-notifications-footer").refindWhenNeeded(elementCache().menuContent());
297298
}
298299

299300
public final WebElement markAll()
300301
{
301302
return Locator.tagWithClass("h3", "navbar-menu-header")
302303
.child(Locator.byClass("clickable-text"))
303-
.refindWhenNeeded(elementCache().menuContent);
304+
.refindWhenNeeded(elementCache().menuContent());
304305
}
305306

306307
public final WebElement viewAllLink()

0 commit comments

Comments
 (0)