Skip to content
Open
Changes from all commits
Commits
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
25 changes: 19 additions & 6 deletions src/org/labkey/test/components/ui/grids/EditableGrid.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -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<EditableGrid.ElementCache>
Expand DownExpand Up@@ -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);
Expand All@@ -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)
Expand Down