Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/org/labkey/test/components/react/BaseReactSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down