@@ -1034,39 +1034,9 @@ public String copyCurrentSelection() throws IOException, UnsupportedFlavorExcept
10341034 return getWrapper ().getClipboardContent ();
10351035 }
10361036
1037- /**
1038- * Select a cell range and drag-fill from the end of that selection to {@code dragEnd}.
1039- * Because this overload owns the {@link #selectCellRange} step, it can fully restore state
1040- * and retry if the first drag extended the selection without applying the fill.
1041- *
1042- * @param selectStart first cell of the selection (passed to {@link #selectCellRange})
1043- * @param selectEnd last cell of the selection; also the source of the fill value
1044- * @param dragEnd destination cell for the fill drag
1045- */
1046- public void dragFill (WebElement selectStart , WebElement selectEnd , WebElement dragEnd )
1047- {
1048- Locator .XPathLocator selectionHandleLoc = Locator .byClass ("cell-selection-handle" );
1049- selectCellRange (selectStart , selectEnd );
1050- selectEnd .click ();
1051- String fillValue = getCellValue (selectEnd );
1052- WebElement selectionHandle = selectionHandleLoc .waitForElement (getComponentElement (), 2_000 );
1053- dragToCell (selectionHandle , dragEnd );
1054- if (!WebDriverWrapper .waitFor (() -> fillValue .equals (getCellValue (dragEnd )), 3_000 ))
1055- {
1056- // Fill didn't complete — the drag likely extended the selection without triggering the fill.
1057- selectCellRange (selectStart , selectEnd );
1058- selectEnd .click ();
1059- selectionHandle = selectionHandleLoc .waitForElement (getComponentElement (), 2_000 );
1060- dragToCell (selectionHandle , dragEnd );
1061- WebDriverWrapper .waitFor (() -> fillValue .equals (getCellValue (dragEnd )),
1062- "Drag fill did not populate end cell with value: " + fillValue , 5_000 );
1063- }
1064- }
1065-
10661037 /**
10671038 * Drag-fill from {@code startCell} (which must already be selected / part of the current
1068- * selection) to {@code endCell}. Prefer {@link #dragFill(WebElement, WebElement, WebElement)}
1069- * when the selection range is known — that overload can retry reliably.
1039+ * selection) to {@code endCell}.
10701040 */
10711041 public void dragFill (WebElement startCell , WebElement endCell )
10721042 {
@@ -1077,6 +1047,21 @@ public void dragFill(WebElement startCell, WebElement endCell)
10771047 selectionHandleLoc .waitForElement (endCell , 5_000 );
10781048 }
10791049
1050+ /**
1051+ * Select {@code selectStart} through {@code dragEnd} and fill down from {@code selectEnd}'s row using Ctrl/Cmd+D.
1052+ * @param selectStart top-left cell of the range to select
1053+ * @param selectEnd cell whose value will be filled down (must be in {@code selectStart}'s row)
1054+ * @param dragEnd bottom-right cell of the range to select and fill down to
1055+ */
1056+ public void fillDown (WebElement selectStart , WebElement selectEnd , WebElement dragEnd )
1057+ {
1058+ selectCellRange (selectStart , dragEnd );
1059+ String fillValue = getCellValue (selectEnd );
1060+ new Actions (getDriver ()).keyDown (MODIFIER_KEY ).sendKeys ("d" ).keyUp (MODIFIER_KEY ).build ().perform ();
1061+ WebDriverWrapper .waitFor (() -> fillValue .equals (getCellValue (dragEnd )),
1062+ "Fill-down did not populate end cell with value: " + fillValue , 3_000 );
1063+ }
1064+
10801065 public void selectCellRange (WebElement startCell , WebElement endCell )
10811066 {
10821067 dragToCell (startCell , endCell );
@@ -1195,8 +1180,9 @@ private boolean isInSelection(WebElement cell) // 'in selection' shows as blue
11951180 {
11961181 // Should not need to add code for a reactSelect here. A selection involves clicking/dragging, which closes the reactSelect.
11971182 return Locator .tagWithClass ("div" , "cellular-display" )
1198- .findElement (cell )
1199- .getDomAttribute ("class" ).contains ("cell-selection" );
1183+ .findOptionalElement (cell )
1184+ .map (el -> el .getDomAttribute ("class" ).contains ("cell-selection" ))
1185+ .orElse (false );
12001186 }
12011187
12021188 /**
0 commit comments