Add initial support for shadow_root
Capybara added support to access an element's shadow DOM with Element#shadow_root in https://github.com/teamcapybara/capybara/pull/2546 – it would be nice if Cuprite supported it too.
Here is an attempt at that. Not sure if it does everything as it should, but the specs are passing locally and I've used it successfully in a project's test suite where
# this
expect(
evaluate_script('arguments[0].shadowRoot', page.find('.a-shadow-host'))
).to have_selector('.inside-shadow-dom')
# could be replaced with this
expect(
page.find('.a-shadow-host').shadow_root
).to have_selector('.inside-shadow-dom')
The spec "produces error messages when failing" provided by Capybara needed to be adapted because the generated error message includes the value of tagName which is different between Selenium and Cuprite.
The added spec "extends visibility check across shadow host boundary" covers a behaviour that Selenium implements this way: the visibility of the shadow propagates down to its children.
FWIW I've been playing around fixing some Shadow DOM issue using https://github.com/yuki24/capybara-shadowdom It still didn't play ball with likes of clicks not working because of some overlapping element issues.
let element = node.getRootNode().elementFromPoint(x, y); in this PR seems to be the magic sauce so having this available would be neat