diff --git a/lib/capybara/cuprite/javascripts/index.js b/lib/capybara/cuprite/javascripts/index.js index 837ee78..9a76e0c 100644 --- a/lib/capybara/cuprite/javascripts/index.js +++ b/lib/capybara/cuprite/javascripts/index.js @@ -85,7 +85,16 @@ class Cuprite { if (style.display === "none" || style.visibility === "hidden" || parseFloat(style.opacity) === 0) { return false; } - node = node.parentElement ?? (node.getRootNode() instanceof ShadowRoot && node.getRootNode()); + + let parent = node.parentElement; + if (parent && parent.tagName === "DETAILS" && !parent.open) { + // In a closed
only the first (and its subtree) is rendered. + if (node !== parent.querySelector(":scope > summary")) { + return false; + } + } + + node = parent ?? (node.getRootNode() instanceof ShadowRoot && node.getRootNode()); } } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b7ebf23..23e00a7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -56,8 +56,6 @@ module TestSessions node Element#drop can drop strings node Element#drop can drop multiple strings node Element#drop can drop a pathname - node #visible? details non-summary descendants should be non-visible - node #visible? works when details is toggled open and closed node #set should submit single text input forms if ended with node #shadow_root should produce error messages when failing #has_field with valid should be false if field is invalid