Reputation: 2095
I was just starting with SitePrism and I've got a site where elements get added dynamically to the page and don't have any kind of id, name, etc... the easiest I could think of is finding them by their 'text', eg. a CONTINUE button
I was trying:
element :continue_b, :button, 'Continue'
and SitePrism fails with the following:
Capybara::Ambiguous: Ambiguous match, found 4 elements matching button "Continue"
Is there a way for me to specify with SitePrism the element I want to click? I've found a few ways to do it with Capybara itself but I didn't manage to see the equivalent with SitePrism.
Upvotes: 0
Views: 1563
Reputation: 49910
If there really is no difference between any of the button elements and you can't/don't want to move the element
definition to a scoped section
of the page, you can use the match
argument to return just the first. Since all the parameters after the SitePrism element name are passed through to Capybara as find arguments it would be
element :continue_b, :button, 'Continue', match: :first
Upvotes: 1