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
15 changes: 5 additions & 10 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 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 @@ -26,6 +26,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 +326,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)
{
String attribute = label.getAttribute("for");
if (attribute != null)
names.add(FieldKey.fromFieldKey(attribute).getFullName());
else // Select inputs have spans in the label column to prevent orphaned labels for accessibility
{
attribute = label.getAttribute("data-fieldkey");
if (attribute != null)
names.add(FieldKey.fromFieldKey(attribute).getFullName());
else
throw new RuntimeException("Could not find field name for label: " + label.getText());
}
}

// 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 +440,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
2 changes: 1 addition & 1 deletion 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.button("Register"));

assertTitleContains("Register");
assertElementPresent(Locator.tagWithName("form", "register"));
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/tests/core/login/PasswordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public String userInitiatePasswordReset(String username)
{
signOut();
goToHome();
clickAndWait(Locator.linkWithText("Sign In"));
clickAndWait(Locator.button("Sign In"));
clickAndWait(Locator.linkContainingText("Forgot password"));
setFormElement(Locator.id("email"), username);
clickButtonContainingText("Reset", 0);
Expand Down
Loading