Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public WebDriver getDriver()
public CategoryEditRow setDescription(String value)
{
elementCache().descriptionInput.set(value);
getWrapper().waitFor(()-> elementCache().descriptionInput.get() == value, 2000);
WebDriverWrapper.waitFor(()-> value.equals(elementCache().descriptionInput.get()), 2000);
return this;
}

Expand All @@ -80,7 +80,7 @@ public boolean getIsActive()
public void delete()
{
getWrapper().fireEvent(elementCache().deleteLI, WebDriverWrapper.SeleniumEvent.mouseover);
getWrapper().waitFor(()-> elementCache().deleteLI.isEnabled() && elementCache().deleteLI.isSelected(), 2000);
WebDriverWrapper.waitFor(()-> elementCache().deleteLI.isEnabled() && elementCache().deleteLI.isSelected(), 2000);
elementCache().deleteLI.click();
}

Expand All @@ -90,7 +90,7 @@ protected ElementCache newElementCache()
return new ElementCache();
}

protected class ElementCache extends Component.ElementCache
protected class ElementCache extends Component<?>.ElementCache
{
Input descriptionInput = Input(Locators.descriptionEdit(), getDriver()).timeout(4000).findWhenNeeded(this);
Checkbox activeCheckBox = Checkbox.Checkbox(
Expand Down
49 changes: 26 additions & 23 deletions snd/test/src/org/labkey/test/components/snd/SuperPackageRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,41 @@ public boolean isSelected()
public SuperPackageRow select() // note: this 'selection' behavior is expressed among assigned packages, not among available packages
{
if (!isSelected())
newElementCache().desc.click();
getWrapper().waitFor(()-> isSelected(),
elementCache().desc.click();
WebDriverWrapper.waitFor(this::isSelected,
"row item never became selected",2000);
return this;
}

public String getLabel()
{
return newElementCache().desc.getText();
return elementCache().desc.getText();
}

public SuperPackageRow clickMenuItem(String menuText)
{
getWrapper().fireEvent(newElementCache().menuToggle, WebDriverWrapper.SeleniumEvent.mouseover);
newElementCache().menuToggle.click();
// wait for the menu to expand
getWrapper().waitFor(()-> newElementCache().menuToggle.getAttribute("class").contains("open"), 1000);
Locator menuItem = Locator.tagWithAttribute("li", "role", "presentation")
.child(Locator.tagWithAttribute("a", "role", "menuitem")
.containing(menuText));
WebElement itemToClick = menuItem.waitForElement(getComponentElement(), 2000);
getWrapper().fireEvent(newElementCache().menuToggle, WebDriverWrapper.SeleniumEvent.mouseover);
getWrapper().waitFor(()-> itemToClick.isEnabled(), 2000);
itemToClick.click();
// wait for the menu to collapse (or disappear, if 'remove' was the action')
getWrapper().waitFor(()-> {
try
{
return newElementCache().menuToggle.getAttribute("aria-expanded").equals("false");
}catch (StaleElementReferenceException sere){return true;}
}, 1000);
return this;
getWrapper().mouseOver(this.getComponentElement());
elementCache().menuToggle.click();
// wait for the menu to expand
WebDriverWrapper.waitFor(() -> elementCache().menuToggle.getAttribute("aria-expanded").equals("true"), () -> "Menu didn't open: " + getLabel(), 1000);
Locator menuItem = Locator.tagWithAttribute("li", "role", "presentation")
.child(Locator.tagWithAttribute("a", "role", "menuitem")
.containing(menuText));
WebElement itemToClick = menuItem.waitForElement(getComponentElement(), 2000);
WebDriverWrapper.waitFor(itemToClick::isEnabled, () -> "Menu item not enabled: " + menuText, 2000);
itemToClick.click();
// wait for the menu to collapse (or disappear, if 'remove' was the action')
WebDriverWrapper.waitFor(() -> {
try
{
return elementCache().menuToggle.getAttribute("aria-expanded").equals("false");
}
catch (StaleElementReferenceException sere)
{
return true;
}
}, "Menu didn't close", 1000);
return this;
}

@Override
Expand All @@ -101,7 +104,7 @@ protected ElementCache newElementCache()
return new ElementCache();
}

protected class ElementCache extends Component.ElementCache
protected class ElementCache extends Component<?>.ElementCache
{
public WebElement menuToggle = Locator.tagWithClassContaining("div", "btn-group") // sometimes dropdown, dropup
.child(Locator.id("superpackage-actions"))
Expand Down
32 changes: 24 additions & 8 deletions snd/test/src/org/labkey/test/pages/snd/EditCategoriesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import org.labkey.test.Locator;
import org.labkey.test.WebDriverWrapper;
import org.labkey.test.WebTestHelper;
import org.labkey.test.components.bootstrap.ModalDialog;
import org.labkey.test.components.snd.CategoryEditRow;
import org.labkey.test.pages.LabKeyPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.util.List;

Expand Down Expand Up @@ -73,18 +75,32 @@ public List<CategoryEditRow> getAllCategories()

public EditCategoriesPage clickSave()
{
waitFor(()-> elementCache().saveButton.getAttribute("disabled")==null,
"'Save' button is disabled", 2000);
elementCache().saveButton.click();
sleep(1000); // todo: wait for save button to detatch/unmount before re-mounting into next page view
return clickSave(false);
}

public EditCategoriesPage clickSaveAndConfirmDelete()
{
return clickSave(true);
}

public EditCategoriesPage clickSave(boolean confirmDelete)
{
shortWait().until(ExpectedConditions.elementToBeClickable(elementCache().saveButton)).click();
if (confirmDelete)
{
new ModalDialog.ModalDialogFinder(getDriver())
.withBodyTextContaining("Are you sure you want to delete row").find()
.dismiss("Submit Changes");
}
shortWait().until(ExpectedConditions.stalenessOf(elementCache().saveButton));
clearCache();
return new EditCategoriesPage(getDriver());
}

public PackageListPage clickCancel()
{
waitFor(()-> elementCache().cancelButton.getAttribute("disabled")==null,
"'Cancel' button is disabled", 2000);
elementCache().cancelButton.click();
shortWait().until(ExpectedConditions.elementToBeClickable(elementCache().cancelButton)).click();
shortWait().until(ExpectedConditions.stalenessOf(elementCache().cancelButton));
return new PackageListPage(getDriver());
}

Expand All @@ -98,7 +114,7 @@ protected class ElementCache extends LabKeyPage.ElementCache
{
// TODO: Add other elements that are on the page
WebElement addCategoriesBtn = Locator.tag("div").containing("Add Category")
.withChild(Locator.tagWithClass("i", "fa fa-plus-circle"))
.withChild(Locator.tagWithClass("i", "fa-plus-circle"))
.findWhenNeeded(getDriver()).withTimeout(4000);
WebElement cancelButton = Locator.button("Cancel").findWhenNeeded(getDriver()).withTimeout(4000);
WebElement saveButton = Locator.button("Save").findWhenNeeded(getDriver()).withTimeout(4000);
Expand Down
Loading