diff --git a/src/org/labkey/test/components/react/BaseReactSelect.java b/src/org/labkey/test/components/react/BaseReactSelect.java index c9037b2747..faa00615fd 100644 --- a/src/org/labkey/test/components/react/BaseReactSelect.java +++ b/src/org/labkey/test/components/react/BaseReactSelect.java @@ -422,6 +422,39 @@ public String getName() return elementCache().input.getAttribute("name"); } + /** + * Determines whether the "Add New" menu footer is present at the bottom of the select's menu area. This item is + * rendered only when the underlying schema/query is registered and configured to support adding new values. + * + * @return true if the "Add New" menu item is visible, otherwise false + */ + public boolean isAddNewVisible() + { + open(); + WebElement addNew = Locators.addEntitiesFooter.findElementOrNull(getComponentElement()); + return addNew != null && addNew.isDisplayed(); + } + + /** + * Clicks the "Add New" menu item at the bottom of the select's menu area. The menu is opened first if it is not + * already expanded. This intentionally returns void: the resulting UI varies by schema/query, so the caller is + * responsible for constructing and interacting with whatever the click produces. + */ + public void clickAddNew() + { + open(); + WebElement addNew = Locators.addEntitiesFooter.waitForElement(getComponentElement(), WAIT_FOR_JAVASCRIPT); + try + { + addNew.click(); + } + catch (WebDriverException wde) // handle the "another element would receive the click" situation + { + getWrapper().scrollIntoView(addNew); + getWrapper().fireEvent(addNew, WebDriverWrapper.SeleniumEvent.click); + } + } + protected T scrollIntoView() { try @@ -515,6 +548,7 @@ private Locators() } public static final Locator.XPathLocator option = Locator.tagWithClass("div", "select-input__option"); + public static final Locator.XPathLocator addEntitiesFooter = Locator.tagWithClass("div", "add-entities-footer"); public static final Locator placeholder = Locator.tagWithClass("div", "select-input__placeholder"); public static final Locator clear = Locator.tagWithClass("div","select-input__clear-indicator"); public static final Locator arrow = Locator.tagWithClass("div","select-input__dropdown-indicator");