Problem: I am looking for a way to run a test that is able to disambiguate between select controls that have the same value in more than one place.
Example:
I am trying to choose the third "monday" from a select control
ie.select_list( :id , 'choose-day' ).set( '-monday' );
where the select control has a kind of "outline" format in the control itself:
alice
-monday
-tuesday
bob
-monday
-tuesday
charlie
-monday
-tuesday
Given that the text is identical (and I do not know what the option values are ahead of time) is there a way to code the test such that the monday under charlie is the one that gets selected?
It looks like you could use element_by_xpath to find the option you want, with something like this:
//select/option[text()='charlie']/following::option[text()='-monday']
then you could check the value attribute of that option (not sure how to do this in Watir), and select it using:
ie.select_list( :id , 'choose-day' ).select_value( whatever_the_value_was );