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

FilterSelectionDialog: handle non-removable fields #2192

Merged
merged 1 commit into from
Dec 13, 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
17 changes: 11 additions & 6 deletions src/org/labkey/test/components/ui/grids/FieldSelectionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,20 +386,25 @@ public FieldSelectionDialog removeFieldFromSelected(String field, int index)
public FieldSelectionDialog removeAllSelectedFields()
{
List<WebElement> allItems = elementCache().getListItemElements(elementCache().selectedFieldsPanel);
boolean removedAll = true;

for(WebElement listItem : allItems)
for (WebElement listItem : allItems)
Copy link
Contributor

Choose a reason for hiding this comment

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

Occasionally this method will fail because not every item was removed-- one theory I have is that it might be due to how they slide up when the previous one is removed. It might be more reliable to iterate from the bottom up, if it's possible for the click to 'miss' if it happens when the target is moving

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to leave as-is since I'm not looking to triage intermittent failures with this work. What you are proposing seems reasonable.

{
WebElement removeIcon = Locator.tagWithClass("span", "view-field__action").findWhenNeeded(listItem);

// For the tooltip not all fields can be removed.
if(removeIcon.isDisplayed())
// In some usages there may be fields that are not removable.
if (!removeIcon.isDisplayed())
{
removeIcon.click();
removedAll = false;
continue;
}

removeIcon.click();
}

WebDriverWrapper.waitFor(()-> getSelectedFields().isEmpty(),
"Did not remove all of the selected fields.", 500);
// If a non-removable field is encountered, then skip check to see if all fields are removed.
if (removedAll)
WebDriverWrapper.waitFor(()-> getSelectedFields().isEmpty(), "Did not remove all of the selected fields.", 500);

return this;
}
Expand Down