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
59 changes: 17 additions & 42 deletions src/org/labkey/test/components/ui/grids/GridBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public void clickButton(String buttonText)
btn.click(); // awaits being enabled, for example by selecting grid items
}

public void doMenuAction(String buttonText, List<String> menuActions)
private MultiMenu getMultiMenu(String buttonText)
{
MultiMenu multiMenu = null;
boolean found = false;
int tries = 1;

// Sometimes the grid and query bar will load, and even the menu button will render but the text will
// take just a few ms to render, so if at first you don't succeed try again.
while(!found && tries <= 3)
while (!found && tries <= 3)
{
try
{
Expand All @@ -194,15 +194,22 @@ public void doMenuAction(String buttonText, List<String> menuActions)
}
}

// If the button still wasn't found try the 'More' button.
if(!found)
// If the button still wasn't found, try the 'More' button.
if (!found)
{
multiMenu = elementCache().findMenu("More");
Assert.assertTrue(String.format("Could not find a menu button '%s' or 'More', don't know what to click.", buttonText),
multiMenu.getComponentElement().isDisplayed());
getWrapper().log(String.format("Couldn't find menu button '%s', clicking the 'More' menu button.", buttonText));
}

return multiMenu;
}

public void doMenuAction(String buttonText, List<String> menuActions)
{
MultiMenu multiMenu = getMultiMenu(buttonText);

if (menuActions.size() == 1)
multiMenu.doMenuAction(menuActions.get(0));
else if (menuActions.size() == 2)
Expand All @@ -211,6 +218,12 @@ else if (menuActions.size() == 2)
throw new IllegalArgumentException("There should be either 1 or 2 menu actions, but was:" + menuActions);
}

public boolean isMenuItemDisabled(String buttonText, String menuItem)
{
MultiMenu multiMenu = getMultiMenu(buttonText);
return multiMenu.isMenuItemDisabled(menuItem);
}

public List<String> getMenuButtonsText()
{
// Because this is not a search for a specific menu button let's pause for a moment to give the buttons a
Expand Down Expand Up @@ -257,42 +270,6 @@ public List<String> getMenuText(String buttonText)
throw new NoSuchElementException("Couldn't find menu button with text '" + buttonText + "'.");
}

/**
* Private helper function that will get the text of the aliquot view button. This can be used to determine the
* current view. Asserts that the button is present.
*
* @return Text of the aliquot view button.
*/
private String currentAliquotViewText()
{
Assert.assertTrue("There is no 'Aliquot View' button on this grid.",
elementCache().aliquotView.getComponentElement().isDisplayed());

return elementCache().aliquotView.getComponentElement().getText();
}

/**
* Get the current view selected in the aliquot view button. This asserts that the button is present.
*
* @return A {@link AliquotViewOptions} item.
*/
public AliquotViewOptions getCurrentAliquotView()
{
String text = currentAliquotViewText().toLowerCase();

if(text.contains("all samples"))
return AliquotViewOptions.ALL;

// If the current page is the sources page the text would be 'Derived Samples Only', so this should still work.
if(text.contains("samples only"))
return AliquotViewOptions.SAMPLES;

if(text.contains("aliquots only"))
return AliquotViewOptions.ALIQUOTS;

return null;
}

public GridBar searchFor(String searchStr)
{

Expand Down Expand Up @@ -354,8 +331,6 @@ protected MultiMenu findMenu(String buttonText)
return menus.get(buttonText);
}

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