需要帮助以单击阴影根(封闭)类型下的元素 [英] Need help to click on the element under the shadow Root (closed) type

查看:131
本文介绍了需要帮助以单击阴影根(封闭)类型下的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击位于阴影根内部的元素的Null Pointer异常(关闭)

Null Pointer Exception on click at the element located inside of the shadow Root (closed)

试图用Java脚本处理它:

Tried to handle it with Java Script:

public WebElement getShadowRootElement(WebElement element) {
    return (WebElement)
            ((JavascriptExecutor)
                    driver).executeScript("return 
arguments[0].shadowRoot", element);
}

结果:

Cannot read property 'shadowRoot' of null

添加了屏幕截图:1.

Added screenshots: 1.

推荐答案

如果您的用例是要与< svg>内的< path> 元素进行交互,code>标记确实位于 #shadow-root(封闭) 中.

If your usecase is to interact with the <path> element which is within the <svg> tag, is indeed within a #shadow-root (closed).

@hayatoito(Shadow DOM的创建者)在此评论中明确提到:

@hayatoito (creator of Shadow DOM) in this comment clearly mentions:

引入封闭的影子树的最初动机是 绝对不允许从外部通过任何API访问封闭的影子树中的节点" ,AFIAK.那样,我们无法访问内部隐藏阴影树中的节点,该树在Blink中的< video> 元素中使用.

实际上,我以这种方式设计了一个封闭的影子树.如果可以访问封闭的影子树中的节点,则应将其视为规范的错误.

In fact, I designed a closed shadow tree in such a way. If there is a way to access a node in a closed shadow tree, it should be considered as a bug of the spec.

我认为拥有一个允许在Chrome应用或扩展程序层中进行访问的API完全可以.但是,对于普通的Web应用程序,我认为当前协议为 绝不允许" .

I think it's totally okay to have an API to allow an access in the layer of Chrome apps or extensions. However, for a normal web app, I think the current agreement is "Never allow it".

如果我们允许,那就意味着我们不需要封闭的影子树.我认为只有一棵开放的影子树就足够了.

If we allowed it, that means we do not need a closed shadow tree. Just having an open shadow tree is enough, I think.


WebDriver透视图

最近,@ AutomatedTester [Mozilla公司首席培根官David Burns]在上发起了讨论WebDriver-Web组件的可测试性

目前 Selenium Team 已开放,可以接受对它的请求请求.

Currently Selenium Team is open for accepting pull requests for the same.

您可以在如何找到相关讨论用硒自动化阴影DOM元素?

这篇关于需要帮助以单击阴影根(封闭)类型下的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆