diff --git a/src/org/labkey/test/components/ui/grids/EditableGrid.java b/src/org/labkey/test/components/ui/grids/EditableGrid.java index 96a64e3984..a627f0bdd9 100644 --- a/src/org/labkey/test/components/ui/grids/EditableGrid.java +++ b/src/org/labkey/test/components/ui/grids/EditableGrid.java @@ -73,6 +73,7 @@ import static org.labkey.test.util.TestLogger.log; import static org.labkey.test.util.data.TestArrayDataUtils.formatMultiValueText; import static org.labkey.test.util.selenium.ScrollUtils.Alignment.center; +import static org.labkey.test.util.selenium.ScrollUtils.Alignment.nearest; import static org.labkey.test.util.selenium.WebDriverUtils.MODIFIER_KEY; public class EditableGrid extends WebDriverComponent @@ -1048,23 +1049,31 @@ public void dragFill(WebElement startCell, WebElement endCell) } /** - * Select {@code selectStart} through {@code dragEnd} and fill down from {@code selectEnd}'s row using Ctrl/Cmd+D. + * Select {@code selectStart} through {@code fillEnd} and fill down from {@code selectEnd}'s row using Ctrl/Cmd+D. * @param selectStart top-left cell of the range to select * @param selectEnd cell whose value will be filled down (must be in {@code selectStart}'s row) - * @param dragEnd bottom-right cell of the range to select and fill down to + * @param fillEnd bottom-right cell of the range to select and fill down to */ - public void fillDown(WebElement selectStart, WebElement selectEnd, WebElement dragEnd) + public void fillDown(WebElement selectStart, WebElement selectEnd, WebElement fillEnd) { - selectCellRange(selectStart, dragEnd); + selectCellRange(selectStart, fillEnd); String fillValue = getCellValue(selectEnd); new Actions(getDriver()).keyDown(MODIFIER_KEY).sendKeys("d").keyUp(MODIFIER_KEY).build().perform(); - WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(dragEnd)), + WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(fillEnd)), "Fill-down did not populate end cell with value: " + fillValue, 3_000); } + /** + * Select the rectangle of cells with {@code startCell} and {@code endCell} at opposite corners. Shift-click is + * used rather than a drag; a drag can only reach cells that stay on screen for the whole gesture. + */ public void selectCellRange(WebElement startCell, WebElement endCell) { - dragToCell(startCell, endCell); + dismissPopover(); + selectCell(startCell); + + getWrapper().scrollIntoView(endCell); + new Actions(getDriver()).keyDown(Keys.SHIFT).click(endCell).keyUp(Keys.SHIFT).build().perform(); WebDriverWrapper.waitFor(()-> isInSelection(startCell) && isInSelection(endCell), "Cell range did not become selected", 2000); @@ -1075,6 +1084,10 @@ private void dragToCell(WebElement elementToDrag, WebElement destinationCell) var size = destinationCell.getSize(); dismissPopover(); + // Scroll before the pointer picks anything up: scrolling with the button held skips the rows it scrolls past. + ScrollUtils.scrollIntoView(destinationCell, nearest, nearest); + ScrollUtils.scrollUnderFloatingHeader(elementToDrag); + new Actions(getDriver()) // WebDriver doesn't calculate correct location to click the cell selection handle .moveToElement(elementToDrag, 0, 7)