<input is="text-input" class="input-element style-scope paper-input"
autocomplete="off" placeholder="" autocapitalize="none" autocorrect="off"
aria-describedby="" aria-labelledby="paper-input-label-22" id="input-22"
tabindex="0">
#shadow-root (user-agent)
<div id="inner-editor">test</div>
</input>
我正在使用Selenium尝试将文本获取到shadow root的内部,但它始终返回null,我知道开放式和封闭式Shadow DOM之间的区别,并且Shadow dom的开放版本始终显示为#shadow-root(open )在我的Devtool中,所以我想知道如何确定此用户代理影子dom是打开还是关闭?
编辑:我正在使用JS和我的代码如下所示:
driver.executeScript("return
arguments[0].shadowRoot",driver.findElement(webdriver.By.css("#input-
22"))).then(function(text) { text.getText()});
文本返回为空.
解决方法:
按照@FlorentB.建议,
driver.findElement(By.css("#input-22")).getAttribute("value")
将返回用户代理影子根的文本值.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。