Reputation: 77
Using Rubygems and Watir
I'm unable to select options from a second drop down. here is the code of the 2 drop downs
<select class="LocalUtility" name="Accounts[0][Local_Utility]" id="">
<select class="LocalUtility" name="Accounts[1][Local_Utility]" id="">
I'm able to select options from the 1st by using
browser.select_list(:class, 'LocalUtility').set ('value')
I tried to use index for the 2nd drop down (tried with 1,2)
browser.select_list(:index, 1).set ('value')
And I cannot use the name because Ruby is throwing errors due to what I'm suspecting is that Ruby does not like the brackets [1][Local_Utility]
browser.select_list(:name 'Accounts[1][Local_Utility]').set ('value')
Is there a possible solution to this?
Upvotes: 0
Views: 437
Reputation: 739
Try
browser.select_list(:class => "LocalUtility", :index => 1).select("value")
to set the value in the second select list.
I'm surprised that the name doesn't work though. There's a potential typo in what you've supplied us with
Try
browser.select_list(:name => "Accounts[1][Local_Utility]").select("value")
Upvotes: 1
Reputation: 2016
have you tried using a regex match?
browser.select_list(:class => 'LocalUtility', :name => /1/).set 'value'
Please forgive me if my syntax is not right because I have been using watir-webdriver lately (and your web page code is insufficient to recreate the problem).
Upvotes: 1