You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cuprite finding elements inside closed detail tags #184
I'm in the process of replacing selenium with cuprite for my Rails system tests. I have a green CI with selenium, but when I switch to cuprite I start getting a lot of errors like this:
Test:
within ".modal-body-confirmation" do
click_button "Yes, delete"
end
Message
Capybara::Ambiguous: Ambiguous match, found 3 elements matching visible css ".modal-body-confirmation"
After checking, I discovered that I had 3 .modal-body-confirmation elements inside 3 different detail tags, but only 1 of those tags was open. So it seems that this file used for the specs needs to be updated to include a test for closed detail tags.
This is an extraction of what the HTML looked like at the failure. You can see 2 modal-body-confirmation but only whose parent detail element is open.
<detailsopen=""><summaryclass="modal-trigger"><buttonclass="" title="Recomeçar lista de presentes"><span>Recomeçar lista de presentes</span></button></summary><divclass="modal-content pos-1001"><divclass="modal-body modal-body-confirmation"><!-- Redacted --></div></div></details><details><summaryclass="modal-trigger"><divclass="" title="Remover loja"><span>Remover loja</span></div></summary><divclass="modal-content pos-1001"><divclass="modal-body modal-body-confirmation"><!-- Redacted --></div></div></details>
Fixed by #317 in Cuprite 0.18. Content of a closed <details> other than its first <summary> is no longer considered visible, and Capybara's shared specs for this run in Cuprite's suite now.
With your markup (one open and two closed <details>), all(".modal-body-confirmation") finds 1 visible element out of 3. within(".modal-body-confirmation") { click_button "Yes, delete" } clicks the button in the open one.
Activity
route commentedon Oct 16, 2026
Fixed by #317 in Cuprite 0.18. Content of a closed
<details>other than its first<summary>is no longer considered visible, and Capybara's shared specs for this run in Cuprite's suite now.With your markup (one open and two closed
<details>),all(".modal-body-confirmation")finds 1 visible element out of 3.within(".modal-body-confirmation") { click_button "Yes, delete" }clicks the button in the open one.