ruby on rails - How can I tell Capybara to find the 1st, 2nd, or 3rd button? -


i have subscription screen in app. there 5 different choices, , therefore 5 different buttons. it's data-driven there 1 or 10 or whatever. n choices.

in writing request spec, find not know how point these. know can set match: :first argument click_button message, there way can arbitrarily call 1 of these?

capybara provides all method. method returns instance of capybara::result. class includes enumerable , provides methods #[].

all(selector)[n] return n-th element on page conforming locator. instance of capybara::node::element can use freely using methods click, set, etc.

a disadvantage all doesn't wait elements appear. if need it, can use synchronization like:

page.should have_css('#id') # wait element appears @ same time or after element click @ next row all(locator)[n].click 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -