Skip to content
76 changes: 46 additions & 30 deletions src/org/labkey/test/pages/assay/plate/PlateDesignerPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -37,55 +38,65 @@ public void createWellGroup(String type, String name)
{
selectTypeTab(type);

WebElement nameField = Locator.tagWithName("input", "wellGroupName")
.withAttribute("data-type", type)
.findElement(getDriver());
setFormElement(nameField, name);
fireEvent(nameField, SeleniumEvent.change);
// Wait for the create row to be visible (canAdd must be true for this type)
WebElement newNameInput = Locator.css(".group-types-panel__new-name-input")
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);

if ("input".equalsIgnoreCase(newNameInput.getTagName()))
{
setFormElement(newNameInput, name);
}
else
{
new Select(newNameInput).selectByVisibleText(name);
}

clickButton("Create", 0);
waitForElement(Locator.tagContainingText("label", name));
waitForElement(Locator.css(".group-types-panel__group-name").withText(name));
}

public void selectTypeTab(String name)
{
Locator.tagWithClass("div", "gwt-Label").withText(name).waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT).click();
Locator.css(".group-types-panel__tab").withText(name)
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT).click();
}

public void selectGroup(String name)
{
Locator.css(".group-types-panel__group-name").withText(name)
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT).click();
}

public void selectWellsForWellgroup(String type, String wellGroup, String startLocation, String endLocation)
{
selectTypeTab(type);
waitForElement(Locator.tagWithText("label", wellGroup));

Locator start = Locator.css(".Cell-"+startLocation);
Locator end = Locator.css(".Cell-"+endLocation);
if (wellGroup != null & !"".equals(wellGroup))
if (wellGroup != null && !wellGroup.isEmpty())
{
if (!getText(Locator.css(".gwt-TabBarItem-selected")).equals(type))
{
Locator.css(".gwt-Label").withText(type).findElement(getDriver()).click();
//want for switch
}
if (!isChecked(Locator.xpath("//input[@name='wellGroup' and following-sibling::label[text()='"+wellGroup+"']]")))
click(Locator.xpath("//input[@name='wellGroup' and following-sibling::label[text()='"+wellGroup+"']]"));
if (!getAttribute(start, "style").contains("rgb(255, 255, 255)"))
click(start);
}
else
{
Locator.tagWithClass("*", "gwt-Label").withText(type).findElement(getDriver()).click();
//select no group in order to clear area
selectGroup(wellGroup);
}
WebElement fromEl = start.findElement(getDriver());
WebElement toEl = end.findElement(getDriver());

// Cells are <td> elements with aria-label matching the location (e.g. "A1" or "A1: Specimen 1")
WebElement fromEl = Locator.css(".template-grid__cell[aria-label^='" + startLocation + "']")
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
WebElement toEl = Locator.css(".template-grid__cell[aria-label^='" + endLocation + "']")
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);

Actions builder = new Actions(getDriver());
builder.clickAndHold(fromEl).moveToElement(toEl).release().build().perform();
}

public void setWellGroupProperty(String propertyKey, String value)
{
WebElement input = Locator.tag("input").withAttribute("aria-label", propertyKey)
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
setFormElement(input, value);
}

public void setName(String name)
{
Locator nameField = Locator.id("templateName");
waitForElement(nameField, WAIT_FOR_JAVASCRIPT);
WebElement nameField = Locator.css(".plate-template-designer__name-input")
.waitForElement(getDriver(), WAIT_FOR_JAVASCRIPT);
setFormElement(nameField, name);
fireEvent(nameField, SeleniumEvent.change);
}
Expand All @@ -100,13 +111,18 @@ public void save()
clickButton("Save", 0);
}

public void cancel()
{
clickButton("Cancel");
}

@Override
protected ElementCache newElementCache()
{
return new ElementCache();
}

protected class ElementCache extends LabKeyPage.ElementCache
protected class ElementCache extends LabKeyPage<?>.ElementCache
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ protected void createTemplate()
plateDesigner.selectTypeTab("CONTROL");

clickButton("Create", 0);
waitForElement(Locator.tagWithText("label", "Background Wells"));
waitForElement(Locator.tagWithText("span", "Background Wells"));

plateDesigner.selectWellsForWellgroup("CONTROL", "Background Wells", "A1", "B3");
plateDesigner.selectWellsForWellgroup("CONTROL", "Background Wells", "C4", "D6");
Expand Down
26 changes: 10 additions & 16 deletions src/org/labkey/test/tests/nab/NabAssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,22 @@ public void runUITests()
.setAssayType("NAb")
.setTemplateType("single-plate")));

setFormElement(Locator.inputById("templateName"), PLATE_TEMPLATE_NAME);
PlateDesignerPage designerPage = new PlateDesignerPage(getDriver());
designerPage.setName(PLATE_TEMPLATE_NAME);
designerPage.selectTypeTab("SPECIMEN");

// select the specimen wellgroup tab
click(Locator.tagWithText("div", "SPECIMEN"));
designerPage.selectGroup("Specimen 1");
designerPage.setWellGroupProperty("ReverseDilutionDirection", "true");

// select the first specimen group
click(Locator.tagWithText("label", "Specimen 1"));
// set reversed dilution direction to true:
setFormElement(Locator.inputById("property-ReverseDilutionDirection"), "true");
designerPage.selectGroup("Specimen 2");
designerPage.setWellGroupProperty("ReverseDilutionDirection", "false");

// select the second specimen group
click(Locator.tagWithText("label", "Specimen 2"));
// set reversed dilution direction to false:
setFormElement(Locator.inputById("property-ReverseDilutionDirection"), "false");

// select the third specimen group
click(Locator.tagWithText("label", "Specimen 3"));
designerPage.selectGroup("Specimen 3");
// set reversed dilution direction to a nonsense value:
setFormElement(Locator.inputById("property-ReverseDilutionDirection"), "invalid boolean value");
designerPage.setWellGroupProperty("ReverseDilutionDirection", "invalid boolean value");

// note that we're intentionally leaving the fourth and fifth direction specifiers null, which should default to 'false'
clickButton("Save & Close");
designerPage.saveAndClose();

assertTextPresent(PLATE_TEMPLATE_NAME, "NAb: 5 specimens in duplicate");

Expand Down
17 changes: 6 additions & 11 deletions src/org/labkey/test/tests/nab/NabHighThroughputAssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,9 @@ protected void doInit()
.setAssayType("NAb")
.setTemplateType("high-throughput (single plate dilution)")));

Locator.IdLocator nameField = Locator.id("templateName");
waitForElement(nameField, WAIT_FOR_JAVASCRIPT);
setFormElement(nameField, PLATE_TEMPLATE_NAME);
fireEvent(nameField, SeleniumEvent.change);

clickButton("Save & Close");
PlateDesignerPage designerPage = new PlateDesignerPage(getDriver());
designerPage.setName(PLATE_TEMPLATE_NAME);
designerPage.saveAndClose();
assertTextPresent(PLATE_TEMPLATE_NAME);

// create the cross plate dilution template
Expand All @@ -103,11 +100,9 @@ protected void doInit()
.setAssayType("NAb")
.setTemplateType("high-throughput (cross plate dilution)")));

waitForElement(nameField, WAIT_FOR_JAVASCRIPT);
setFormElement(nameField, CPD_PLATE_TEMPLATE_NAME);
fireEvent(nameField, SeleniumEvent.change);

clickButton("Save & Close");
designerPage = new PlateDesignerPage(getDriver());
designerPage.setName(CPD_PLATE_TEMPLATE_NAME);
designerPage.saveAndClose();
assertTextPresent(CPD_PLATE_TEMPLATE_NAME);

_containerHelper.createSubfolder(getProjectName(), TEST_ASSAY_FLDR_NAB);
Expand Down
7 changes: 3 additions & 4 deletions src/org/labkey/test/tests/nab/NabMultiVirusPlateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ private void doCreateSteps()
.setAssayType("NAb")
.setTemplateType("multi-virus plate")));

waitForElement(Locator.xpath("//input[@id='templateName']"), WAIT_FOR_JAVASCRIPT);
setFormElement(Locator.xpath("//input[@id='templateName']"), PLATE_TEMPLATE_NAME);

clickButton("Save & Close");
PlateDesignerPage designerPage = new PlateDesignerPage(getDriver());
designerPage.setName(PLATE_TEMPLATE_NAME);
designerPage.saveAndClose();

goToProjectHome();

Expand Down
Loading