Skip to content

Commit

Permalink
Fix locator and remove workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-tchad authored and labkey-alan committed Dec 19, 2023
1 parent f2a9c4c commit 6fda8e9
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/org/labkey/test/components/ui/grids/EditableGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ public Integer getRowIndex(String columnLabel, String text)
public WebElement getCell(int row, String column)
{
int columNumber = getColumnIndex(column) + 1;
WebElement gridCell = getRow(row).findElement(By.cssSelector("td:nth-of-type(" + columNumber + ")"));
return gridCell;
return Locator.css("td:nth-of-type(" + columNumber + ")").findElement(getRow(row));
}

public boolean isCellReadOnly(int row, String column)
Expand Down Expand Up @@ -541,7 +540,7 @@ public EditableGrid pasteFromCell(int row, String columnName, String pasteText)
int initialRowCount = getRowCount();
WebElement gridCell = getCell(row, columnName);
String indexValue = gridCell.getText();
selectCell(row, columnName);
selectCell(gridCell);

getWrapper().actionPaste(null, pasteText);

Expand Down Expand Up @@ -670,7 +669,7 @@ private void selectAllCells()
if (!areAllInSelection())
{
int indexOffset = hasSelectColumn() ? 1 : 0;
selectCell(0, getColumnNames().get(1 + indexOffset)); // forces the index cell into selected state
selectCell(getCell(0, getColumnNames().get(1 + indexOffset))); // forces the index cell into selected state
// this resets the grid state to a known base condition
// use 'ctrl-a' to select the entire grid
Keys cmdKey = MODIFIER_KEY;
Expand All @@ -682,20 +681,12 @@ private void selectAllCells()

private WebElement selectCell(int row, String columnName)
{
WebElement cell = getCell(row, columnName);

if (!isCellSelected(cell))
{
// FIXME: We shouldn't have to do this, ReclickingWebElement should be using
// WebDriverUtils::scrollUnderStickyFormButtons, which should scroll the element into view for us.
getWrapper().scrollIntoView(cell, true);
cell.click();
// For some reason while doing this waitFor the cell was going stale, so we need to call getCell every time
WebDriverWrapper.waitFor(()-> isCellSelected(getCell(row, columnName)),
"the target cell did not become selected", 4000);
}
// Get a reference to the cell.
WebElement gridCell = getCell(row, columnName);

return getCell(row, columnName);
// Select the cell.
selectCell(gridCell);
return gridCell;
}

/**
Expand Down

0 comments on commit 6fda8e9

Please sign in to comment.