Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditableGrid: Support barcode scanners "streaming" input keys #1846

Merged
merged 1 commit into from
Mar 6, 2024
Merged
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
22 changes: 12 additions & 10 deletions src/org/labkey/test/components/ui/grids/EditableGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public String copyAllCells() throws IOException, UnsupportedFlavorException
/**
* Selects all cells in the table, then deletes their content
*/
public void clearAllCells() throws IOException, UnsupportedFlavorException
public void clearAllCells()
{
selectAllCells();
new Actions(getDriver()).sendKeys(Keys.DELETE).perform();
Expand Down Expand Up @@ -726,7 +726,7 @@ private void selectAllCells()
}
}

private WebElement selectCell(int row, String columnName)
public WebElement selectCell(int row, String columnName)
{
// Get a reference to the cell.
WebElement gridCell = getCell(row, columnName);
Expand Down Expand Up @@ -754,20 +754,22 @@ private void selectCell(WebElement cell)
private void activateCell(WebElement cell)
{
// If it is a selector, and it already has focus (is active), it will not have a div.cellular-display
if(Locator.tagWithClass("div", "select-input__control--is-focused")
.findElements(cell).isEmpty())
{
var cellContent = Locator.tagWithClass("div", "cellular-display").findElement(cell);
cellContent.sendKeys(Keys.ENTER);
}
if (Locator.tagWithClass("div", "select-input__control--is-focused").findElements(cell).isEmpty())
sendKeysToCell(cell, Keys.ENTER);
}

public void sendKeysToCell(WebElement cell, CharSequence... keysToSend)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to add a comment here as to the value of this method. For example does it emulate the barcode scanner?

{
var cellContent = Locator.tagWithClass("div", "cellular-display").findElement(cell);
cellContent.sendKeys(keysToSend);
}

/**
* Tests the specified webElement to see if it is in 'cell-selected' state, which means it has an active/focused input in it
* @param cell A WebElement that is the grid cell (a td).
* @return True if the edit is present
*/
private boolean isCellSelected(WebElement cell)
public boolean isCellSelected(WebElement cell)
{
try
{
Expand All @@ -777,7 +779,7 @@ private boolean isCellSelected(WebElement cell)
.findElement(cell)
.getAttribute("class").contains("cell-selected");
}
catch(NoSuchElementException nse)
catch (NoSuchElementException nse)
{
// If the cell is an open/active reactSelect the class attribute is different.
return Locator.tagWithClass("div", "select-input__control")
Expand Down