selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🚀 Feature]: Support Select Lists in Javascript

Open PeteSwauger opened this issue 2 years ago • 5 comments

Feature and motivation

Our web application has implemented multi-select lists and I want to exercise selecting multiple list entries in our automated tests.

Usage example

After building a list of values to include or exclude in a query, the user can multi-select values in the list to remove with one button click. I cannot automate this with our code that is implemented in javascript.

PeteSwauger avatar Jul 14 '22 21:07 PeteSwauger

@PeteSwauger, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Jul 14 '22 21:07 github-actions[bot]

What exactly isn't working for you?

If you locate the options you want to select and send the click command, Selenium should select them without de-selecting other options. My implementation of this is in Ruby not JavaScript, but there is nothing special involved, just click everything you want to be selected.

titusfortner avatar Jul 15 '22 01:07 titusfortner

Thanks for your comment. Would you share an example of the code needed? I have tried various things but no luck.

PeteSwauger avatar Jul 15 '22 11:07 PeteSwauger

What did you try? Can you share your code as well, please?

diemol avatar Jul 15 '22 11:07 diemol

The following code finds the list items and clicks on each, but when the second is clicked the first is unselected. I need both to be selected.

let dropdownItems = await driver.findElements(By.xpath("//li[contains(@class,'ui-listbox-item ui-corner-all')]//span")); await driver.actions().keyDown(Key.CONTROL); for (const item of dropdownItems) { await item.click(); }

PeteSwauger avatar Jul 15 '22 15:07 PeteSwauger

You don't need to use keyDown. Just click everything you want and it should keep the others selected still.

titusfortner avatar Sep 08 '22 22:09 titusfortner

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Oct 09 '22 00:10 github-actions[bot]