Skip to content

Commit

Permalink
Update ChooseAssayTypePage to use Tabs component (#1858)
Browse files Browse the repository at this point in the history
Also update finder locator for `ConceptInfoTabs`
  • Loading branch information
labkey-tchad authored Mar 15, 2024
1 parent 99b7164 commit ddf8c8a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/org/labkey/test/components/react/Tabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ protected ElementCache newElementCache()

protected class ElementCache extends Component<?>.ElementCache
{
final WebElement tabList = Locator.xpath("./ul").withClass("nav-tabs").findWhenNeeded(this);
final WebElement tabList = Locator.xpath("(ul|div/ul)").withClass("nav-tabs").findWhenNeeded(this);
final Map<String, WebElement> tabMap = new HashMap<>();
final List<WebElement> tabs = new ArrayList<>();
private final Locator.XPathLocator tabLoc = Locator.tag("a").withAttribute("role", "tab");
final WebElement tabContent = Locator.xpath("./div").withClass("tab-content").findWhenNeeded(this);
final WebElement tabContent = Locator.xpath("(div|div/div)").withClass("tab-content").findWhenNeeded(this);

public ElementCache()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ List<WebElement> alternateConceptPathParts(WebElement pathInformationPane)

public static class ConceptInfoTabsFinder extends WebDriverComponentFinder<ConceptInfoTabs, ConceptInfoTabsFinder>
{
private final XPathLocator _baseLocator = Locator.id("concept-information-tabs");
private final XPathLocator _baseLocator = Locator.byClass("concept-information-tabs");

public ConceptInfoTabsFinder(WebDriver driver)
{
Expand Down
61 changes: 13 additions & 48 deletions src/org/labkey/test/pages/assay/ChooseAssayTypePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import org.labkey.test.Locator;
import org.labkey.test.WebDriverWrapper;
import org.labkey.test.WebTestHelper;
import org.labkey.test.components.react.Tabs;
import org.labkey.test.components.ui.files.FileUploadPanel;
import org.labkey.test.pages.LabKeyPage;
import org.labkey.test.pages.ReactAssayDesignerPage;
import org.labkey.test.pages.pipeline.PipelineStatusDetailsPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.io.File;

Expand All @@ -33,19 +34,13 @@ public static ChooseAssayTypePage beginAt(WebDriverWrapper webDriverWrapper, Str
@Override
protected void waitForPage()
{
waitFor(() -> elementCache().stdAssayTabLocator().existsIn(getDriver()) &&
elementCache().specialtyAssayTabLocator().existsIn(getDriver()), WAIT_FOR_PAGE);
waitFor(() -> elementCache().assayTypeTabs.getTabText().size() > 1, WAIT_FOR_PAGE);
}


public ReactAssayDesignerPage selectStandardAssay()
{
elementCache().stdAssayTab.click();

WebElement standardPanel = elementCache().stdAssayPaneLocator().waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
waitFor(()-> standardPanel.getAttribute("class") != null &&
standardPanel.getAttribute("class").contains("active"),
"took too long to select the standard assay panel", 2000);
elementCache().assayTypeTabs.selectTab("Standard Assay");

clickSelectButton();
return new ReactAssayDesignerPage(getDriver());
Expand All @@ -57,14 +52,11 @@ public ReactAssayDesignerPage selectAssayType(String name)
return selectStandardAssay();
}

elementCache().specialtyAssayTab.click();
WebElement specialtyPanel = elementCache().specialtyAssayPaneLocator().waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
waitFor(()-> specialtyPanel.getAttribute("class") != null &&
specialtyPanel.getAttribute("class").contains("active"),
"took too long to select the specialty assay panel", 2000);
WebElement activeTab = elementCache().assayTypeTabs.selectTab("Specialty Assays");

waitForElementToBeVisible(elementCache().specialtySelectLocator);
selectOptionByText(elementCache().specialtySelect, name);
WebElement specialtySelect = Locator.id("specialty-assay-type-select").findWhenNeeded(activeTab);
shortWait().until(ExpectedConditions.visibilityOf(specialtySelect));
selectOptionByText(specialtySelect, name);

waitFor(()->
elementCache().selectButton.getText().toLowerCase().contains(name.toLowerCase()),
Expand All @@ -76,7 +68,7 @@ public ReactAssayDesignerPage selectAssayType(String name)

public ChooseAssayTypePage goToImportAssayDesignTab()
{
elementCache().importAssayTab.click();
elementCache().assayTypeTabs.selectTab("Import Assay Design");
return this;
}

Expand All @@ -99,42 +91,15 @@ protected ElementCache newElementCache()
return new ElementCache();
}

protected class ElementCache extends LabKeyPage.ElementCache
protected class ElementCache extends LabKeyPage<?>.ElementCache
{
public final WebElement cancelButton = Locator.button("Cancel").findWhenNeeded(getDriver());
// selectButton's text changes depending upon which assay is selected- it can be 'Choose Standard Assay' or 'Choose x Assay'
public final WebElement selectButton = Locator.tagWithClass("button", "pull-right").findWhenNeeded(getDriver());

public final WebElement specialtyPanel = Locator.byClass("tab-pane").index(1).findWhenNeeded(this);

public final WebElement stdAssayTab = stdAssayTabLocator().findWhenNeeded(this);
public final WebElement specialtyAssayTab = specialtyAssayTabLocator().findWhenNeeded(this);
public final WebElement importAssayTab = Locator.tagContainingText("a", "Import Assay Design").findWhenNeeded(this);

public final WebElement containerSelect = Locator.tagWithId("select", "assay-type-select-container").findWhenNeeded(this);
public final Tabs assayTypeTabs = new Tabs.TabsFinder(getDriver())
.locatedBy(Locator.XPathLocator.union(Locator.id("assay-picker-tabs"), Locator.byClass("lk-tabs")))
.findWhenNeeded(this);

public final Locator specialtySelectLocator = Locator.tagWithId("select", "specialty-assay-type-select");
public final WebElement specialtySelect = specialtySelectLocator.findWhenNeeded(specialtyPanel);

protected Locator.XPathLocator buttonPanelLocator()
{
return Locator.byClass("assay-designer-section");
}
public Locator.XPathLocator stdAssayTabLocator()
{
return Locator.tagWithText("a", "Standard Assay");
}
public Locator.XPathLocator stdAssayPaneLocator()
{
return Locator.byClass("tab-pane").index(0);
}
public Locator.XPathLocator specialtyAssayTabLocator()
{
return Locator.tagWithText("a", "Specialty Assays");
}
public Locator.XPathLocator specialtyAssayPaneLocator()
{
return Locator.byClass("tab-pane").index(1);
}
}
}

0 comments on commit ddf8c8a

Please sign in to comment.