Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown Menus #1804

Merged
merged 8 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/org/labkey/test/components/html/BootstrapMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected WebElement findVisibleMenuItemOrNull(String text)

protected WebElement findDisabledMenuItemOrNull(String text)
{
Locator.XPathLocator loc= Locator.xpath("./li/a").withText(text).parent().withClass("disabled");
Locator.XPathLocator loc = Locator.xpath("./li/a").withText(text).parent().withClass("disabled");
return loc.findElementOrNull(findVisibleMenuPanel());
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/org/labkey/test/components/react/MultiMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static abstract class Locators
{
static public Locator.XPathLocator menuContainer()
{
return Locator.tagWithClass("*", "dropdown");
return Locator.XPathLocator.union(Locator.byClass("dropdown"), Locator.byClass("dropup"));
}

static public Locator.XPathLocator menuContainer(String text)
Expand Down Expand Up @@ -254,6 +254,13 @@ public MultiMenuFinder withButtonIcon(String iconClass)
_locator = Locators.menuContainer().withChild(BootstrapMenu.Locators.dropdownToggle().withChild(Locator.byClass(iconClass)));
return this;
}

public MultiMenuFinder withClass(String cls)
{
_locator = MultiMenu.Locators.menuContainer().withClass(cls);
return this;
}

@Override
protected MultiMenuFinder getThis()
{
Expand Down
5 changes: 2 additions & 3 deletions src/org/labkey/test/components/ui/Pager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ public int getPageSize() // only works on GridPanel
// Changing the jumpToDropdown button from the deprecated DropdownButtonGroup class to a MultiMenu type has changed
// the way that various text from the control is gathered. Getting the current page size now requires that the dropdown
// be expanded and the selected page size found in the list.

elementCache().jumpToDropdown.expand();

// Find the selected li element in the page size list (//div[@class='grid-panel__button-bar']//ul[contains(@aria-labelledby,'current-page-drop')]//li[@class='active'])
WebElement activeLi = Locator.tagWithAttributeContaining("ul", "aria-labelledby", "current-page-drop").childTag("li").withAttribute("class", "active").findElement(this);
// Find the selected li element in the page size list
WebElement activeLi = Locator.byClass("active").findElement(elementCache().jumpToDropdown);

int size = Integer.parseInt(activeLi.getText());
elementCache().jumpToDropdown.collapse();
Expand Down
3 changes: 1 addition & 2 deletions src/org/labkey/test/components/ui/grids/GridBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ protected MultiMenu findMenu(String buttonText)
return menus.get(buttonText);
}

protected final BootstrapMenu aliquotView = BootstrapMenu.finder(getDriver()).locatedBy(
Locator.tagWithAttributeContaining("button", "id", "aliquotviewselector").parent()).findWhenNeeded(this);
protected final MultiMenu aliquotView = new MultiMenu.MultiMenuFinder(getDriver()).withButtonClass("aliquot-view-selector").findWhenNeeded(this);

protected final Input searchBox = Input.Input(Locator.tagWithClass("input", "grid-panel__search-input"), getDriver()).findWhenNeeded(this);
protected final WebElement clearSearchButton = Locator.byClass("fa-remove").findWhenNeeded(this);
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/components/ui/navigation/NavBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected abstract class ElementCache extends Component<ElementCache>.ElementCac
public WebElement userIcon = Locator.tagWithAttribute("img", "alt", "User Avatar").findWhenNeeded(this);
public WebElement projectNameDisplay = Locator.tagWithClass("span", "project-name").findWhenNeeded(this);
public Input searchBox = Input.Input(Locator.tagWithClass("input", "navbar__search-input"), getDriver()).findWhenNeeded(this);
public MultiMenu searchMenu = new MultiMenu.MultiMenuFinder(getDriver()).withButtonId("find-and-search-menu").findWhenNeeded(this);
public MultiMenu searchMenu = new MultiMenu.MultiMenuFinder(getDriver()).withButtonClass("navbar__find-and-search-button").findWhenNeeded(this);
public final ProductMenu productMenu = ProductMenu.finder(getDriver()).timeout(1000).findWhenNeeded(this);
}
}
6 changes: 3 additions & 3 deletions src/org/labkey/test/components/ui/navigation/UserMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
public abstract class UserMenu extends BootstrapMenu
{
private static final String MENU_ID = "user-menu-dropdown";
private static final String MENU_CLASS = "user-dropdown";

protected UserMenu(WebElement element, WebDriver driver)
{
Expand All @@ -23,7 +23,7 @@ protected UserMenu(WebElement element, WebDriver driver)

protected static <U extends UserMenu> SimpleWebDriverComponentFinder<U> baseMenuFinder(WebDriver driver, BiFunction<WebElement, WebDriver, U> factory)
{
return new MultiMenu.MultiMenuFinder(driver).withButtonId(MENU_ID).wrap(factory);
return new MultiMenu.MultiMenuFinder(driver).withClass(MENU_CLASS).wrap(factory);
}

// TODO: Placeholder for product update
Expand All @@ -47,6 +47,6 @@ protected LabKeyPage<?> logout()
*/
public static Locator appUserMenu()
{
return Locator.tagWithId("a", MENU_ID);
return Locator.byClass(MENU_CLASS).childTag("a");
}
}
23 changes: 8 additions & 15 deletions src/org/labkey/test/components/ui/search/SampleFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.labkey.test.components.Component;
import org.labkey.test.components.WebDriverComponent;
import org.labkey.test.components.html.BootstrapMenu;
import org.labkey.test.components.react.MultiMenu;
import org.labkey.test.components.ui.grids.TabbedGridPanel;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
Expand Down Expand Up @@ -137,12 +138,12 @@ public List<FilterCard> getSearchCards()

public SavedSearchesMenu getSaveSearchMenu()
{
return new SavedSearchesMenu(elementCache().savedViewsMenu().getComponentElement(), getDriver(), elementCache().saveViewsDropdown());
return new SavedSearchesMenu(elementCache().savedSearchesContainer, getDriver(), elementCache().savedSearchesButton);
}

public BootstrapMenu getSaveSearchDropdownBtn()
public MultiMenu getSaveSearchDropdownBtn()
{
return elementCache().saveViewDropdownBtn;
return elementCache().saveDropdown;
}

/**
Expand Down Expand Up @@ -233,21 +234,13 @@ FilterCard findFilterCard(String queryName)

final TabbedGridPanel resultsGrid = new TabbedGridPanel.TabbedGridPanelFinder(getDriver()).findWhenNeeded(this);

final BootstrapMenu savedViewsMenu()
{
return BootstrapMenu.finder(getDriver())
.locatedBy(Locator.tagWithAttributeContaining("button", "id", "samplefinder-savedsearch-menu").parent())
.waitFor(this);
}
final MultiMenu saveDropdown = new MultiMenu.MultiMenuFinder(getDriver()).withClass("split-button-dropdown").findWhenNeeded(this);

final BootstrapMenu saveViewDropdownBtn = BootstrapMenu.finder(getDriver()).locatedBy(
Locator.tagWithAttributeContaining("button", "id", "save-finderview-dropdown").parent()).findWhenNeeded(this);
final Locator.XPathLocator savedSearchesButtonLoc = Locator.byClass("search-selector");

final WebElement saveViewsDropdown()
{
return Locator.tagWithAttributeContaining("button", "id", "samplefinder-savedsearch-menu").findElement(this);
}
final WebElement savedSearchesButton = savedSearchesButtonLoc.findWhenNeeded(this);

final WebElement savedSearchesContainer = Locator.byClass("dropdown").withChild(savedSearchesButtonLoc).refindWhenNeeded(this);
}

public class SavedSearchesMenu extends BootstrapMenu
Expand Down