简体   繁体   English

Webdriverio:访问 shadow dom 元素

[英]Webdriverio: Accessing shadow dom elements

I have an app structure like this: 
<shell>
#shadow-root (open)
<mini-app>
#shadow-root (open)
<input id="username" autocomplete="off" name="username" type="text" aria-required="true" required="" value="">
</mini-app>
<shell>
Nested tags with shadow-root element username inside it.I want to access input element username using webdriverio.

I am able to access username in dev using the following:我可以使用以下方法访问 dev 中的用户名:

   let a = document.querySelector('shell')
    let b = a.shadowRoot.querySelector('mini-app')
    b.shadowRoot.getElementById('username')

  How can i access the same using webdriverio ? I went through this `https://webdriver.io/blog/2019/02/22/shadow-dom-support.html` but the documentation looks outdated because I am unable to use shadowRoot with shadow$
Any help would be appreciated.

Is there any other way to access shadow dom elements through webdriver?有没有其他方法可以通过 webdriver 访问 shadow dom 元素?

Documentation seems to be fine, can you show how exactly you are using shadow$ method?文档似乎很好,你能展示一下你是如何使用 shadow$ 方法的吗?

I belive that simple我相信那么简单

$('shell').shadow$('.mini-app').shadow$('#username')

should work应该管用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM