Wallaby: how to interact with select boxes

Hi all, does anyone have any tips on how to best interact with <select> elements? After some experimentation I managed to get my test working by sending keys to the element but not by clicking

# this worked
session
|> send_keys(Query.select("List"), ["Option name"])

# this didn't
session
# note: after the following click a take_screenshot shows that the options do not appear open
|> click(Query.css("select"))
|> click(Query.option("Option name")

Sending keys is not how most users interact with the select boxes, so I’d be interested in learning about alternative approaches.

Clicking the option tag is generally how I do it. (Only the option, no need to click the select)

One thing to consider is anther you’re working with a native select element or a JS drop down widget (that probably reimplements it all using other elements).

Thank you for your answer, I guess that will do :slight_smile:

Yes, it was just a plain select box, nothing fancy

Forgive me for resurrecting this old thread!

I’m a massive Wallaby newb and was struggling with selects. I was thankful for the solution here but just wanted to add how I limited the scope to selecting an option in a specific select. Probably dead simple if you know how, but took me a bit of figuring out, and might help the next newb who finds this!

session
|> find(Query.select("Some select"), fn select ->
  click(select, Query.option("Some option"))
end)
1 Like