Skip to content

Commit f5455a0

Browse files
Merge branch 'develop' into fb_allowFileExtensionAutoTest
2 parents ec58d43 + 4eb3518 commit f5455a0

27 files changed

Lines changed: 443 additions & 258 deletions

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ project.dependencies {
2626
implementation("commons-io:commons-io:${commonsIoVersion}")
2727
implementation("com.fasterxml.jackson.core:jackson-annotations:${jacksonAnnotationsVersion}")
2828
implementation("org.bouncycastle:bcprov-jdk18on:${bouncycastleVersion}")
29+
implementation("org.apache.commons:commons-csv:${apacheCommonsCsvVersion}")
2930

3031
//api "org.seleniumhq.selenium:selenium-server:${seleniumVersion}"
3132
implementation("org.seleniumhq.selenium:selenium-firefox-driver:${seleniumVersion}")

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
apacheCommonsCsvVersion=1.14.0
2+
13
aspectjVersion=1.9.23
4+
25
assertjVersion=3.27.3
6+
37
awaitilityVersion=4.3.0
48

59
lookfirstSardineVersion=5.13
10+
611
jettyVersion=12.0.18
12+
713
seleniumVersion=4.27.0
14+
815
mockserverNettyVersion=5.15.0
916

1017
labkeySchemasTestVersion=25.3-SNAPSHOT

src/org/labkey/test/Locator.java

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.labkey.test.selenium.ReclickingWebElement;
2626
import org.labkey.test.selenium.RefindingWebElement;
2727
import org.labkey.test.util.TestLogger;
28+
import org.labkey.test.util.TextUtils;
2829
import org.labkey.test.util.selenium.WebDriverUtils;
2930
import org.openqa.selenium.By;
3031
import org.openqa.selenium.InvalidSelectorException;
@@ -185,23 +186,30 @@ protected WebDriver getWebDriver(SearchContext context)
185186
*/
186187
public static WebElement waitForAnyElement(FluentWait<? extends SearchContext> wait, final Locator... locators)
187188
{
188-
return wait.until(new Function<SearchContext, WebElement>()
189+
try
189190
{
190-
@Override
191-
public WebElement apply(SearchContext context)
191+
return wait.until(new Function<SearchContext, WebElement>()
192192
{
193-
return findAnyElementOrNull(context, locators);
194-
}
193+
@Override
194+
public WebElement apply(SearchContext context)
195+
{
196+
return findAnyElementOrNull(context, locators);
197+
}
195198

196-
@Override
197-
public String toString()
198-
{
199-
List<String> locDescriptions = new ArrayList<>();
200-
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
201-
SearchContext searchContext = extractInputFromFluentWait(wait);
202-
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
203-
}
204-
});
199+
@Override
200+
public String toString()
201+
{
202+
List<String> locDescriptions = new ArrayList<>();
203+
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
204+
SearchContext searchContext = extractInputFromFluentWait(wait);
205+
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
206+
}
207+
});
208+
}
209+
catch (TimeoutException e)
210+
{
211+
throw new NoSuchElementException(e.getMessage(), e);
212+
}
205213
}
206214

207215
/**
@@ -210,28 +218,34 @@ public String toString()
210218
*/
211219
public static List<WebElement> waitForElements(FluentWait<? extends SearchContext> wait, final Locator... locators)
212220
{
213-
return wait.until(new Function<SearchContext, List<WebElement>>()
221+
try
214222
{
215-
@Override
216-
public List<WebElement> apply(SearchContext context)
217-
{
218-
List<WebElement> els = findElements(context, locators);
219-
if (els.size() > 0)
220-
return els;
221-
else
222-
return null;
223-
}
224-
225-
@Override
226-
public String toString()
223+
return wait.until(new Function<SearchContext, List<WebElement>>()
227224
{
228-
List<String> locDescriptions = new ArrayList<>();
229-
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
230-
SearchContext searchContext = extractInputFromFluentWait(wait);
231-
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
232-
}
233-
});
225+
@Override
226+
public List<WebElement> apply(SearchContext context)
227+
{
228+
List<WebElement> els = findElements(context, locators);
229+
if (!els.isEmpty())
230+
return els;
231+
else
232+
return null;
233+
}
234234

235+
@Override
236+
public String toString()
237+
{
238+
List<String> locDescriptions = new ArrayList<>();
239+
Arrays.stream(locators).forEach(loc -> locDescriptions.add(loc.getLoggableDescription()));
240+
SearchContext searchContext = extractInputFromFluentWait(wait);
241+
return String.join("\n--OR--\n", locDescriptions) + (searchContext instanceof WebDriver ? "" : "\nIN: " + searchContext.toString());
242+
}
243+
});
244+
}
245+
catch (TimeoutException e)
246+
{
247+
throw new NoSuchElementException(e.getMessage(), e);
248+
}
235249
}
236250

237251
public static List<WebElement> findElements(SearchContext context, final Locator... locators)
@@ -984,7 +998,7 @@ public static String xq(String value)
984998
*/
985999
private static String ns(String value)
9861000
{
987-
return value.replaceAll("\\s+", " ").trim();
1001+
return TextUtils.normalizeSpace(value);
9881002
}
9891003

9901004
public static String cq(String value)

src/org/labkey/test/components/domain/DomainFieldRow.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.labkey.test.pages.core.admin.BaseSettingsPage.TIME_FORMAT;
2020
import org.labkey.test.params.FieldDefinition;
2121
import org.labkey.test.util.LabKeyExpectedConditions;
22+
import org.labkey.test.util.selenium.WebElementUtils;
2223
import org.openqa.selenium.ElementNotInteractableException;
2324
import org.openqa.selenium.NoSuchElementException;
2425
import org.openqa.selenium.SearchContext;
@@ -1795,8 +1796,8 @@ public WebElement hitSelectionCriteriaButton()
17951796

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

18021803
public RadioButton aliquotOption(ExpSchema.DerivationDataScopeType option)

src/org/labkey/test/components/domain/HitSelectionDialog.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
package org.labkey.test.components.domain;
22

33
import org.labkey.test.Locator;
4-
import org.labkey.test.components.Component;
5-
import org.labkey.test.components.WebDriverComponent;
64
import org.labkey.test.components.bootstrap.ModalDialog;
7-
import org.labkey.test.components.html.Input;
85
import org.labkey.test.components.ui.search.FilterExpressionPanel;
9-
import org.labkey.test.pages.LabKeyPage;
6+
import org.labkey.test.util.selenium.WebElementUtils;
107
import org.openqa.selenium.WebDriver;
118
import org.openqa.selenium.WebElement;
129

1310
import java.util.List;
1411

15-
import static org.labkey.test.components.html.Input.Input;
16-
1712

1813
public class HitSelectionDialog extends ModalDialog
1914
{
@@ -23,9 +18,9 @@ public HitSelectionDialog(WebDriver driver)
2318
super(new ModalDialogFinder(driver));
2419
}
2520

26-
public List<String> getAvailableFields()
21+
public List<String> getAvailableFieldLabels()
2722
{
28-
return getWrapper().getTexts(elementCache().findFieldOptions());
23+
return elementCache().findFieldOptions().stream().map(WebElementUtils::getTextContent).toList();
2924
}
3025

3126
public FilterExpressionPanel selectField(String fieldName)

src/org/labkey/test/components/react/BaseReactSelect.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.util.Collections;
2525
import java.util.List;
26+
import java.util.function.Function;
2627
import java.util.stream.Collectors;
2728

2829
import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
@@ -365,7 +366,7 @@ public List<WebElement> getOptionElements()
365366
*
366367
* @return List of strings for the values in the list.
367368
*/
368-
public List<String> getOptions()
369+
public List<String> getOptions(Function<WebElement, String> optionMapper)
369370
{
370371

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

377-
List<WebElement> selectedItems = Locators.listItems.findElements(getComponentElement());
378-
List<String> rawItems = getWrapper().getTexts(selectedItems);
378+
List<WebElement> optionElements = Locators.listItems.findElements(getComponentElement());
379+
List<String> rawItems = optionElements.stream().map(optionMapper).toList();
379380

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

384-
return rawItems.stream().map(String::trim).collect(Collectors.toList());
385+
return rawItems;
385386
}
386387

388+
public List<String> getOptions()
389+
{
390+
return getOptions(el -> el.getText().trim());
391+
}
387392

388393
public String getName()
389394
{

src/org/labkey/test/components/react/FilteringReactSelect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public FilteringReactSelect filterSelect(String value, Locator elementToWaitFor)
163163
return this;
164164
}
165165

166-
private List<WebElement> setFilter(String value)
166+
public List<WebElement> setFilter(String value)
167167
{
168168
open();
169169
elementCache().input.sendKeys(value);

src/org/labkey/test/components/ui/entities/EntityBulkUpdateDialog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public EntityBulkUpdateDialog(WebDriver driver, UpdatingComponent updatingCompon
4444
{
4545
super(new ModalDialogFinder(driver).withTitle("Update "));
4646
_updatingComponent = updatingComponent;
47+
getWrapper().mouseOver(elementCache().title); // avoid accidentally triggering tooltips
4748
}
4849

4950
/**
@@ -212,9 +213,8 @@ public List<String> getFieldNames()
212213
{
213214
List<WebElement> labels = Locator.tagWithClass("label", "control-label").withAttribute("for")
214215
.waitForElements(elementCache(), 2_000);
215-
List<String> columns = new ArrayList<>();
216-
labels.forEach(a -> columns.add(a.getDomAttribute("for")));
217-
return columns;
216+
217+
return labels.stream().map(a -> EscapeUtil.fieldKeyDecodePart(a.getDomAttribute("for"))).toList();
218218
}
219219

220220
public EntityBulkUpdateDialog waitForFieldsToBe(List<String> expectedFieldNames, int waitMilliseconds)

src/org/labkey/test/components/ui/grids/DetailTable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.Map;
1616

1717
import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
18+
import static org.labkey.test.util.selenium.WebElementUtils.getTextContent;
1819

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

158-
tableData.put(tds.get(0).getText(), tds.get(1).getText());
159+
tableData.put(getTextContent(tds.get(0)), tds.get(1).getText());
159160
}
160161

161162
return tableData;

0 commit comments

Comments
 (0)