diff --git a/src/org/labkey/test/components/ui/grids/EditableGrid.java b/src/org/labkey/test/components/ui/grids/EditableGrid.java index b58765eadf..f5a0210e00 100644 --- a/src/org/labkey/test/components/ui/grids/EditableGrid.java +++ b/src/org/labkey/test/components/ui/grids/EditableGrid.java @@ -1019,13 +1019,50 @@ public String copyCurrentSelection() throws IOException, UnsupportedFlavorExcept return getWrapper().getClipboardContent(); } + /** + * Select a cell range and drag-fill from the end of that selection to {@code dragEnd}. + * Because this overload owns the {@link #selectCellRange} step, it can fully restore state + * and retry if the first drag extended the selection without applying the fill. + * + * @param selectStart first cell of the selection (passed to {@link #selectCellRange}) + * @param selectEnd last cell of the selection; also the source of the fill value + * @param dragEnd destination cell for the fill drag + */ + public void dragFill(WebElement selectStart, WebElement selectEnd, WebElement dragEnd) + { + Locator.XPathLocator selectionHandleLoc = Locator.byClass("cell-selection-handle"); + selectCellRange(selectStart, selectEnd); + String fillValue = getCellValue(selectEnd); + WebElement selectionHandle = selectionHandleLoc.waitForElement(getComponentElement(), 2_000); + dragToCell(selectionHandle, dragEnd); + if (!WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(dragEnd)), 3_000)) + { + // Fill didn't complete — the drag likely extended the selection without triggering the fill. + selectCellRange(selectStart, selectEnd); + selectionHandle = selectionHandleLoc.waitForElement(getComponentElement(), 2_000); + dragToCell(selectionHandle, dragEnd); + WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(dragEnd)), + "Drag fill did not populate end cell with value: " + fillValue, 5_000); + } + } + + /** + * Drag-fill from {@code startCell} (which must already be selected / part of the current + * selection) to {@code endCell}. Prefer {@link #dragFill(WebElement, WebElement, WebElement)} + * when the selection range is known — that overload can retry reliably. + */ public void dragFill(WebElement startCell, WebElement endCell) { dismissPopover(); Locator.XPathLocator selectionHandleLoc = Locator.byClass("cell-selection-handle"); - WebElement selectionHandle = selectionHandleLoc.findElement(startCell); + // Get the value from the start cell + String fillValue = getCellValue(startCell); + WebElement selectionHandle = selectionHandleLoc.waitForElement(getComponentElement(), 2_000); dragToCell(selectionHandle, endCell); - selectionHandleLoc.waitForElement(endCell, 5_000); + // Handle appearing in endCell alone is insufficient — the selection can expand + // (handle moves) without fill values being applied. Wait for the actual value. + WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(endCell)), + "Drag fill did not populate end cell with value: " + fillValue, 5_000); } public void selectCellRange(WebElement startCell, WebElement endCell) @@ -1045,7 +1082,7 @@ private void dragToCell(WebElement elementToDrag, WebElement destinationCell) // WebDriver doesn't calculate correct location to click the cell selection handle .moveToElement(elementToDrag, 0, 7) .clickAndHold() - .pause(Duration.ofMillis(200)) + .pause(Duration.ofMillis(500)) .moveToElement(destinationCell) // Extra wiggle to get it to stick .moveByOffset(0, -size.getHeight()) diff --git a/src/org/labkey/test/tests/MultiValueTextChoiceSampleTypeTest.java b/src/org/labkey/test/tests/MultiValueTextChoiceSampleTypeTest.java index c09e23f64d..68e0504a6d 100644 --- a/src/org/labkey/test/tests/MultiValueTextChoiceSampleTypeTest.java +++ b/src/org/labkey/test/tests/MultiValueTextChoiceSampleTypeTest.java @@ -149,7 +149,7 @@ public void testCrossFolderMVTCtoTCConversion() throws IOException, CommandExcep updateSampleTypePage.getFieldsPanel() .getField(multiValueTextChoiceFieldName) .expand() - .setAllowMultipleSelections(false); + .setAllowMultipleSelections(false, true); updateSampleTypePage.clickSave(); // Check that impossible to choose multiple values.