Skip to content
Open
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/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public void attemptSignIn(String email, String password)
assertElementPresent(Locator.tagWithName("form", "login"));
setFormElement(Locator.id("email"), email);
setFormElement(Locator.id("password"), password);
WebElement signInButton = Locator.lkButton("Sign In").findElement(getDriver());
WebElement signInButton = Locator.button("Sign In").findElement(getDriver());
doAndMaybeWaitForPageToLoad(10_000, () -> {
signInButton.click();
shortWait().until(ExpectedConditions.invisibilityOfElementLocated(Locator.byClass("signing-in-msg")));
Expand Down
19 changes: 7 additions & 12 deletions src/org/labkey/test/components/react/BaseReactSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,21 +612,16 @@ public BaseReactSelectFinder<Select> withLabelForNamedInput(String label)
return this;
}

/* use this to find a reactSelect when the label text is contained within a label/span*/
public BaseReactSelectFinder<Select> withLabelwithSpan(String labelSpanText)
/* use this to find a reactSelect when the label text is contained within a span/span*/
public BaseReactSelectFinder<Select> withSpanLabel(String spanText)
{
return followingLabelWithSpan(labelSpanText);
}

public BaseReactSelectFinder<Select> followingLabelWithSpan(String labelText)
{
_locator = Locators.containerWithDescendant(Locator.tag("label").withChild(Locator.tagWithText("span", labelText)));
_locator = Locators.containerWithDescendant(Locator.tagWithClassContaining("span", "control-label").withDescendant(Locator.tag("span").withText(spanText)));
return this;
}

public BaseReactSelectFinder<Select> followingLabelWithClass(String cls)
public BaseReactSelectFinder<Select> followingSpanWithClass(String cls)
{
_locator = Locators.containerWithDescendant(Locator.tagWithClass("label", cls));
_locator = Locators.containerWithDescendant(Locator.tagWithClass("span", cls));
return this;
}

Expand All @@ -639,15 +634,15 @@ public BaseReactSelectFinder<Select> followingLabelWithClass(String cls)
public BaseReactSelectFinder<Select> withinFormGroup(String labelText)
{
_locator = Locator.tagWithClass("div", "form-group")
.withChild(Locator.tag("label").withPredicate("text() = " + Locator.xq(labelText)))
.withChild(Locator.byClass("control-label").withPredicate("text() = " + Locator.xq(labelText)))
.descendant(Locators.selectContainer());
return this;
}

public BaseReactSelectFinder<Select> withinFormGroupSkipSelect(String labelText)
{
_locator = Locator.tagWithClass("div", "form-group")
.withChild(Locator.tag("label").withChild(Locator.tagWithText("span", labelText)));
.withChild(Locator.byClass("control-label").withChild(Locator.tagWithText("span", labelText)));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ protected abstract class ElementCache extends ModalDialog.ElementCache
*/
public abstract WebElement formRow(CharSequence fieldIdentifier);

// For composite fields (e.g. StoredAmount + Units) that render a <div> label instead of <label for="...">,
// For composite fields (e.g. StoredAmount + Units) that render a <span> label instead of <label for="...">,
private WebElement formRowByControlLabel(String fieldLabel)
{
return _rows.computeIfAbsent(fieldLabel, k ->
Locator.tagWithClass("div", "row")
.withChild(Locator.tagWithClass("div", "control-label").withText(fieldLabel))
.withChild(Locator.tagWithClass("span", "control-label").withText(fieldLabel))
.waitForElement(this, WAIT_FOR_JAVASCRIPT));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public WebElement formRow(CharSequence fieldIdentifier)
return _rows.computeIfAbsent(fieldKey, fk ->
Locator.tagWithClass("div", "row")
// TODO: Shouldn't need to be case-insensitive. Parent/source lookups have weird casing
.withDescendant(Locator.tagWithAttributeIgnoreCase("label", "for", fieldKey))
.withDescendant(Locator.tagWithAttributeIgnoreCase("span", "data-fieldkey", fieldKey))
.findElement(this));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.FieldKey;
import org.labkey.test.util.AuditLogHelper;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
Expand All @@ -26,6 +27,7 @@
import java.io.File;
import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -325,15 +327,29 @@ public String getWarningAlertText()

public List<String> getFieldNames()
{
List<WebElement> labels = Locator.tagWithClass("label", "control-label").withAttribute("for")
.waitForElements(elementCache(), 2_000);
List<WebElement> controlLabels = Locator.byClass("control-label").waitForElements(elementCache(), 2_000);
List<String> names = new ArrayList<>();
for (WebElement label : controlLabels)
{
if (label.getAttribute("data-fieldkey") == null)
try
{
label = label.findElement(Locator.tagWithAttribute("span", "data-fieldkey"));
}
catch (NoSuchElementException e)
{
throw new RuntimeException("Could not find field key for label: " + label.getText(), e);
}
String attribute = label.getAttribute("data-fieldkey");
names.add(FieldKey.fromFieldKey(attribute).getFullName());
}

// Amount and Units is an example that has a "hide-label" for StoredAmount
List<WebElement> hiddenLabels = Locator.tagWithClass("label", "hide-label").withAttribute("for")
.findElements(elementCache());
labels.addAll(hiddenLabels);
names.addAll(hiddenLabels.stream().map(a -> FieldKey.fromFieldKey(a.getDomAttribute("for")).getFullName()).toList());

return labels.stream().map(a -> FieldKey.fromFieldKey(a.getDomAttribute("for")).getFullName()).toList();
return names;
}

public EntityBulkUpdateDialog waitForFieldsToBe(List<String> expectedFieldNames, int waitMilliseconds)
Expand Down Expand Up @@ -425,7 +441,7 @@ public WebElement formRow(CharSequence fieldIdentifier)
{
String fieldKey = FieldKey.fromName(fieldIdentifier).toString();
return Locator.tagWithClass("div", "row")
.withDescendant(Locator.tagWithAttribute("label", "for", fieldKey))
.withDescendant(Locator.tagWithAttribute("span", "data-fieldkey", fieldKey))
.waitForElement(this, WAIT_TIMEOUT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public ReactSelect getEntityTypeByPosition(int index)
public ReactSelect getDisabledEntityTypeByLabel(String typeName)
{
return ReactSelect.finder(getDriver())
.followingLabelWithSpan(typeName)
.withSpanLabel(typeName)
.waitFor(elementCache());
}

Expand All @@ -300,7 +300,7 @@ public ReactSelect getEntityType(String entityName)
*/
public List<String> getEntityTypeNames()
{
List<WebElement> labels = Locator.tagWithClass("label", "entity-insert--type-select").findElements(elementCache());
List<WebElement> labels = Locator.tagWithClass("span", "entity-insert--type-select").findElements(elementCache());
return labels.stream().map(WebElement::getText).toList();
}

Expand All @@ -312,7 +312,7 @@ public List<String> getEntityTypeNames()
public List<ReactSelect> getAllEntityTypes()
{
return ReactSelect.finder(getDriver())
.followingLabelWithClass("entity-insert--type-select")
.followingSpanWithClass("entity-insert--type-select")
.findAll(elementCache());
}

Expand Down Expand Up @@ -340,7 +340,7 @@ public FilteringReactSelect getParent(String typeName)
public List<FilteringReactSelect> getAllParents()
{
return FilteringReactSelect.finder(getDriver())
.followingLabelWithClass("entity-insert--parent-select")
.followingSpanWithClass("entity-insert--parent-select")
.findAll(elementCache());
}

Expand Down
4 changes: 2 additions & 2 deletions src/org/labkey/test/tests/SecurityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public void loginSelfRegistrationEnabledTest()
}
assertTitleContains(SIGN_IN_TEXT);
assertElementPresent(Locator.tagWithName("form", "login"));
clickAndWait(Locator.lkButton("Register"));
clickAndWait(Locator.linkWithText("Register"));

assertTitleContains("Register");
assertElementPresent(Locator.tagWithName("form", "register"));
Expand Down Expand Up @@ -542,7 +542,7 @@ public void loginSelfRegistrationDisabledTest()
clickAndWait(Locator.linkWithText(SIGN_IN_TEXT));
}
assertTitleContains(SIGN_IN_TEXT);
WebElement link = Locator.button("Register").findElementOrNull(getDriver());
WebElement link = Locator.linkWithText("Register").findElementOrNull(getDriver());
assertFalse("Self-registration button is visible", link != null && link.isDisplayed());

beginAt(buildURL("login", "register"));
Expand Down