I’m writing a Wallaby test for a select
element that looks something like this:
<select id="status-select" name="status">
<option selected="" value="b9259ffd-a2de-488f-85f0-567d1e9a7159">new</option>
<option value="f56f5249-0920-4747-8e89-e8b07ba1a5e8">assigned</option>
</select>
The value
attributes on the options are auto-assigned each time by the back-end system. So in order to be able to call Wallaby.Browser.set_value/3
, I need to first query the page to find the current value
for the option. My code to do that is:
value_fixture = Browser.find(
session,
Query.css("#status-select > option:nth-child(2)", visible: false)
)
|> Element.attr("value")
If I execute the query expression in the browser console with a document.querySelectorAll()
, it finds the right element for me.
But Wallaby doesn’t:
** (Wallaby.QueryError) Expected to find 1 invisible element that matched
the css ‘#status-select > option:nth-child(2)’, but 0 invisible elements were found.
Is there some other way to query the options of a select using Wallaby that I should be using?