|
18 | 18 | import org.labkey.test.params.FieldDefinition; |
19 | 19 | import org.labkey.test.params.FieldKey; |
20 | 20 | import org.labkey.test.util.AuditLogHelper; |
| 21 | +import org.openqa.selenium.NoSuchElementException; |
21 | 22 | import org.openqa.selenium.WebDriver; |
22 | 23 | import org.openqa.selenium.WebElement; |
23 | 24 | import org.openqa.selenium.support.ui.ExpectedConditions; |
|
26 | 27 | import java.io.File; |
27 | 28 | import java.io.IOException; |
28 | 29 | import java.time.Duration; |
| 30 | +import java.util.ArrayList; |
29 | 31 | import java.util.List; |
30 | 32 |
|
31 | 33 | /** |
@@ -325,15 +327,29 @@ public String getWarningAlertText() |
325 | 327 |
|
326 | 328 | public List<String> getFieldNames() |
327 | 329 | { |
328 | | - List<WebElement> labels = Locator.tagWithClass("label", "control-label").withAttribute("for") |
329 | | - .waitForElements(elementCache(), 2_000); |
| 330 | + List<WebElement> controlLabels = Locator.byClass("control-label").waitForElements(elementCache(), 2_000); |
| 331 | + List<String> names = new ArrayList<>(); |
| 332 | + for (WebElement label : controlLabels) |
| 333 | + { |
| 334 | + if (label.getAttribute("data-fieldkey") == null) |
| 335 | + try |
| 336 | + { |
| 337 | + label = label.findElement(Locator.tagWithAttribute("span", "data-fieldkey")); |
| 338 | + } |
| 339 | + catch (NoSuchElementException e) |
| 340 | + { |
| 341 | + throw new RuntimeException("Could not find field key for label: " + label.getText(), e); |
| 342 | + } |
| 343 | + String attribute = label.getAttribute("data-fieldkey"); |
| 344 | + names.add(FieldKey.fromFieldKey(attribute).getFullName()); |
| 345 | + } |
330 | 346 |
|
331 | 347 | // Amount and Units is an example that has a "hide-label" for StoredAmount |
332 | 348 | List<WebElement> hiddenLabels = Locator.tagWithClass("label", "hide-label").withAttribute("for") |
333 | 349 | .findElements(elementCache()); |
334 | | - labels.addAll(hiddenLabels); |
| 350 | + names.addAll(hiddenLabels.stream().map(a -> FieldKey.fromFieldKey(a.getDomAttribute("for")).getFullName()).toList()); |
335 | 351 |
|
336 | | - return labels.stream().map(a -> FieldKey.fromFieldKey(a.getDomAttribute("for")).getFullName()).toList(); |
| 352 | + return names; |
337 | 353 | } |
338 | 354 |
|
339 | 355 | public EntityBulkUpdateDialog waitForFieldsToBe(List<String> expectedFieldNames, int waitMilliseconds) |
@@ -425,7 +441,7 @@ public WebElement formRow(CharSequence fieldIdentifier) |
425 | 441 | { |
426 | 442 | String fieldKey = FieldKey.fromName(fieldIdentifier).toString(); |
427 | 443 | return Locator.tagWithClass("div", "row") |
428 | | - .withDescendant(Locator.tagWithAttribute("label", "for", fieldKey)) |
| 444 | + .withDescendant(Locator.tagWithAttribute("span", "data-fieldkey", fieldKey)) |
429 | 445 | .waitForElement(this, WAIT_TIMEOUT); |
430 | 446 | } |
431 | 447 |
|
|
0 commit comments