Select by index?

16 views
Skip to first unread message

Ben Frey

unread,
Oct 10, 2019, 12:30:11 PM10/10/19
to Geb User Mailing List
Is there a way to select a drop-down value by its index? For a particular web site flow I don't really care which value I select for some drop-downs, and since they're tax-related, I'd rather not have to change the test if e.g. the IRS changes the tax brackets.

jc

unread,
Oct 10, 2019, 12:42:14 PM10/10/19
to Geb User Mailing List

You can select by value which is essentially index.

Ben Frey

unread,
Oct 10, 2019, 12:49:41 PM10/10/19
to Geb User Mailing List
The selects I'm working with have the value equal to the text, so that's not the case for them.

jc

unread,
Oct 10, 2019, 12:57:24 PM10/10/19
to Geb User Mailing List
In that case could you use a css selector that locates all of the elements in the dropdown?  Then instead of using the Select module you would have your test first click the dropdown box to expand the options and then do a click on the option you want.  

So if $("css-selector") find 4 dropdown options, you would use $("css-selector")[2] to select the 3rd index (zero-based numbering).
Reply all
Reply to author
Forward
0 new messages