selenium
selenium copied to clipboard
[🚀 Feature]: Support Select Lists in Javascript
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, 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!
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.
Thanks for your comment. Would you share an example of the code needed? I have tried various things but no luck.
What did you try? Can you share your code as well, please?
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(); }
You don't need to use keyDown. Just click everything you want and it should keep the others selected still.
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.