I've done a search and most of the related google results have returned just in general selecting an element from a dropdown. However the ID's in this case for the elements in the dropdown are dynamically generated unfortunately.
This is for a base test case, so I basically just need to select for example the first one. The text is also the same for the elements in the dropdown (not sure if that helps).
Is there such an example of this?
Im using cucumber with caybara(using selenium driver) integration
After two days of searching and reading, this article was amongst one of a few that was helpful. Hopefully, this can help someone else!
I created a few methods like so, excuse the naming..I changed it.
I also referenced this.
You can find the first option element and then use the
select_option
method to select it.For example, if the select list has an id "select_id", you can do:
As @TomWalpole mentions, this will not wait for the element to appear. It would be safer to do one of the following:
or
Alternatively you can get the first element text then select it by
select
function: