Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5cc2f38
Use 'textContent' to pull raw field labels from page
labkey-tchad Apr 21, 2025
ee7cdbf
Don't remove double-spaces
labkey-tchad Apr 21, 2025
afa99fa
Handle "Remove Column" menu
labkey-tchad Apr 22, 2025
9d96388
Create WebElementUtils
labkey-tchad Apr 23, 2025
621d5f9
Fix IDE warning
labkey-tchad Apr 23, 2025
6af3d6c
Trim random names. The server will do this silently
labkey-tchad Apr 23, 2025
d1a9b48
Merge remote-tracking branch 'origin/develop' into fb_doubleSpaces
labkey-tchad Apr 23, 2025
3bef79c
Handle NBSP in textContent
labkey-tchad Apr 23, 2025
074c855
Fix some corner cases
labkey-tchad Apr 24, 2025
8b3e015
Broader double-space testing
labkey-tchad Apr 24, 2025
18d5658
Handle more double-spaces
labkey-tchad Apr 25, 2025
7649975
Yet more
labkey-tchad Apr 25, 2025
230b762
A few more
labkey-tchad Apr 26, 2025
f3bb3da
Handle quotes in column headers
labkey-tchad Apr 29, 2025
c6273dc
Merge remote-tracking branch 'origin/develop' into fb_doubleSpaces
labkey-tchad Apr 29, 2025
bc32a32
Fix some name/fieldKey confusion
labkey-tchad Apr 29, 2025
bfe0276
Remove temporary double-spaces
labkey-tchad Apr 29, 2025
ed3b6cc
Merge remote-tracking branch 'origin/develop' into fb_doubleSpaces
labkey-tchad Apr 30, 2025
48e4281
Fix some name/caption/fieldKey conflation
labkey-tchad Apr 30, 2025
0a20297
More name/caption/fieldKey conflation
labkey-tchad Apr 30, 2025
a4de83e
Fix field key decoding
labkey-tchad May 1, 2025
e274be6
Last couple of errors
labkey-tchad May 1, 2025
523e21a
Merge remote-tracking branch 'origin/develop' into fb_doubleSpaces
labkey-tchad May 1, 2025
cfd0af5
Fix a couple of intermittent failures while I'm in here
labkey-tchad May 1, 2025
7ed2242
Merge remote-tracking branch 'origin/develop' into fb_doubleSpaces
labkey-tchad May 2, 2025
eb63812
Remove some accidental changes
labkey-tchad May 2, 2025
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ project.dependencies {
implementation("commons-io:commons-io:${commonsIoVersion}")
implementation("com.fasterxml.jackson.core:jackson-annotations:${jacksonAnnotationsVersion}")
implementation("org.bouncycastle:bcprov-jdk18on:${bouncycastleVersion}")
implementation("org.apache.commons:commons-csv:${apacheCommonsCsvVersion}")

//api "org.seleniumhq.selenium:selenium-server:${seleniumVersion}"
implementation("org.seleniumhq.selenium:selenium-firefox-driver:${seleniumVersion}")
Expand Down
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
apacheCommonsCsvVersion=1.14.0

aspectjVersion=1.9.23

assertjVersion=3.27.3

awaitilityVersion=4.3.0

lookfirstSardineVersion=5.13

jettyVersion=12.0.18

seleniumVersion=4.27.0

mockserverNettyVersion=5.15.0

labkeySchemasTestVersion=25.3-SNAPSHOT
82 changes: 48 additions & 34 deletions src/org/labkey/test/Locator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.labkey.test.selenium.ReclickingWebElement;
import org.labkey.test.selenium.RefindingWebElement;
import org.labkey.test.util.TestLogger;
import org.labkey.test.util.TextUtils;
import org.labkey.test.util.selenium.WebDriverUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.InvalidSelectorException;
Expand Down Expand Up @@ -185,23 +186,30 @@ protected WebDriver getWebDriver(SearchContext context)
*/
public static WebElement waitForAnyElement(FluentWait<? extends SearchContext> wait, final Locator... locators)
{
return wait.until(new Function<SearchContext, WebElement>()
try
{
@Override
public WebElement apply(SearchContext context)
return wait.until(new Function<SearchContext, WebElement>()
{
return findAnyElementOrNull(context, locators);
}
@Override
public WebElement apply(SearchContext context)
{
return findAnyElementOrNull(context, locators);
}

@Override
public String toString()
{
List<String> locDescriptions = new ArrayList<>();
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
SearchContext searchContext = extractInputFromFluentWait(wait);
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
}
});
@Override
public String toString()
{
List<String> locDescriptions = new ArrayList<>();
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
SearchContext searchContext = extractInputFromFluentWait(wait);
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
}
});
}
catch (TimeoutException e)
{
throw new NoSuchElementException(e.getMessage(), e);
}
}

/**
Expand All @@ -210,28 +218,34 @@ public String toString()
*/
public static List<WebElement> waitForElements(FluentWait<? extends SearchContext> wait, final Locator... locators)
{
return wait.until(new Function<SearchContext, List<WebElement>>()
try
{
@Override
public List<WebElement> apply(SearchContext context)
{
List<WebElement> els = findElements(context, locators);
if (els.size() > 0)
return els;
else
return null;
}

@Override
public String toString()
return wait.until(new Function<SearchContext, List<WebElement>>()
{
List<String> locDescriptions = new ArrayList<>();
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
SearchContext searchContext = extractInputFromFluentWait(wait);
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
}
});
@Override
public List<WebElement> apply(SearchContext context)
{
List<WebElement> els = findElements(context, locators);
if (!els.isEmpty())
return els;
else
return null;
}

@Override
public String toString()
{
List<String> locDescriptions = new ArrayList<>();
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
SearchContext searchContext = extractInputFromFluentWait(wait);
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
}
});
}
catch (TimeoutException e)
{
throw new NoSuchElementException(e.getMessage(), e);
}
}

public static List<WebElement> findElements(SearchContext context, final Locator... locators)
Expand Down Expand Up @@ -984,7 +998,7 @@ public static String xq(String value)
*/
private static String ns(String value)
{
return value.replaceAll("\\s+", " ").trim();
return TextUtils.normalizeSpace(value);
}

public static String cq(String value)
Expand Down
5 changes: 3 additions & 2 deletions src/org/labkey/test/components/domain/DomainFieldRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.labkey.test.pages.core.admin.BaseSettingsPage.TIME_FORMAT;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.util.LabKeyExpectedConditions;
import org.labkey.test.util.selenium.WebElementUtils;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.SearchContext;
Expand Down Expand Up @@ -1795,8 +1796,8 @@ public WebElement hitSelectionCriteriaButton()

public List<String> hitSelectionCriteria()
{
return getWrapper().getTexts(Locator.tagWithClass("li", "hit-criteria-renderer__field-value")
.findElements(this));
return Locator.tagWithClass("li", "hit-criteria-renderer__field-value")
.findElements(this).stream().map(WebElementUtils::getTextContent).toList();
}

public RadioButton aliquotOption(ExpSchema.DerivationDataScopeType option)
Expand Down
11 changes: 3 additions & 8 deletions src/org/labkey/test/components/domain/HitSelectionDialog.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package org.labkey.test.components.domain;

import org.labkey.test.Locator;
import org.labkey.test.components.Component;
import org.labkey.test.components.WebDriverComponent;
import org.labkey.test.components.bootstrap.ModalDialog;
import org.labkey.test.components.html.Input;
import org.labkey.test.components.ui.search.FilterExpressionPanel;
import org.labkey.test.pages.LabKeyPage;
import org.labkey.test.util.selenium.WebElementUtils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

import static org.labkey.test.components.html.Input.Input;


public class HitSelectionDialog extends ModalDialog
{
Expand All @@ -23,9 +18,9 @@ public HitSelectionDialog(WebDriver driver)
super(new ModalDialogFinder(driver));
}

public List<String> getAvailableFields()
public List<String> getAvailableFieldLabels()
{
return getWrapper().getTexts(elementCache().findFieldOptions());
return elementCache().findFieldOptions().stream().map(WebElementUtils::getTextContent).toList();
}

public FilterExpressionPanel selectField(String fieldName)
Expand Down
13 changes: 9 additions & 4 deletions src/org/labkey/test/components/react/BaseReactSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
Expand Down Expand Up @@ -365,7 +366,7 @@ public List<WebElement> getOptionElements()
*
* @return List of strings for the values in the list.
*/
public List<String> getOptions()
public List<String> getOptions(Function<WebElement, String> optionMapper)
{

boolean alreadyOpened = isExpanded();
Expand All @@ -374,16 +375,20 @@ public List<String> getOptions()
if (!alreadyOpened)
open();

List<WebElement> selectedItems = Locators.listItems.findElements(getComponentElement());
List<String> rawItems = getWrapper().getTexts(selectedItems);
List<WebElement> optionElements = Locators.listItems.findElements(getComponentElement());
List<String> rawItems = optionElements.stream().map(optionMapper).toList();

// If it wasn't open before close it, otherwise leave it in the open state.
if (!alreadyOpened)
close();

return rawItems.stream().map(String::trim).collect(Collectors.toList());
return rawItems;
}

public List<String> getOptions()
{
return getOptions(el -> el.getText().trim());
}

public String getName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public FilteringReactSelect filterSelect(String value, Locator elementToWaitFor)
return this;
}

private List<WebElement> setFilter(String value)
public List<WebElement> setFilter(String value)
{
open();
elementCache().input.sendKeys(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public EntityBulkUpdateDialog(WebDriver driver, UpdatingComponent updatingCompon
{
super(new ModalDialogFinder(driver).withTitle("Update "));
_updatingComponent = updatingComponent;
getWrapper().mouseOver(elementCache().title); // avoid accidentally triggering tooltips
}

/**
Expand Down Expand Up @@ -212,9 +213,8 @@ public List<String> getFieldNames()
{
List<WebElement> labels = Locator.tagWithClass("label", "control-label").withAttribute("for")
.waitForElements(elementCache(), 2_000);
List<String> columns = new ArrayList<>();
labels.forEach(a -> columns.add(a.getDomAttribute("for")));
return columns;

return labels.stream().map(a -> EscapeUtil.fieldKeyDecodePart(a.getDomAttribute("for"))).toList();
}

public EntityBulkUpdateDialog waitForFieldsToBe(List<String> expectedFieldNames, int waitMilliseconds)
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/components/ui/grids/DetailTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Map;

import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
import static org.labkey.test.util.selenium.WebElementUtils.getTextContent;

/**
* This is a 'special' table that has only two columns, and no header. An example of this table can be seen in the
Expand Down Expand Up @@ -155,7 +156,7 @@ public Map<String, String> getTableDataByLabel()
{
List<WebElement> tds = tableRow.findElements(By.tagName("td"));

tableData.put(tds.get(0).getText(), tds.get(1).getText());
tableData.put(getTextContent(tds.get(0)), tds.get(1).getText());
}

return tableData;
Expand Down
Loading