Reputation:
I have a table where all the button are like this:
<button class="button_class btn" type="button">
I want to click in all of them using Watir/Ruby. This is the code to click on the first one:
browser.button(:class => 'button_class btn').click
What can I do to go to the next one and click on it?
Thanks
Upvotes: 2
Views: 1070
Reputation: 46846
If you are looking to just click the second button (rather than clicking each and every button), you can use the :index locator.
browser.button(:class => 'button_class btn', :index => 1).click
Note:
Upvotes: 2
Reputation: 118289
I think you need to use buttons
instead of button
as below :-
browser.buttons(:class => 'button_class btn').each do |b|
b.click
end
Upvotes: 2