Reputation: 167
I'm trying to to click the button in this html code
<div class="modal-footer"><button class="btn" data-dismiss="modal">Kapat</button></div>
I've already tried find with various combinations, the closest I came to success was with this code:
click_on "Kapat"
The problem is that there are 3 copies of the same button in the page, so my question is; is there a way to specify this particular div ?
Upvotes: 4
Views: 2584
Reputation: 33161
If the button has a specific path, you could use within
or a find
down to that path, but that path to the element would have to be unique in the page or you end up with the same problem (though, I believe using :xpath
would give you a bit more flexibility here).
within ".modal-footer" do
click_on "Kapat"
end
within ".another-selector" do
click_on "Kapat"
end
Upvotes: 7