找到并点击在Shadow DoM中的元素:
使用shadow()方法
<div class="shadow-host">
#shadow-root
<button class="my-button">Click me</button>
</div>
使用Shawdow()方法:*先定位到 “#shadow-root”的父级 ,例子中是 class="shadow-host"(在实际中可能为其他值,定位到root的上一级就可以了)
// yields [#shadow-root (open)]
cy.get('.shadow-host').shadow().find('.my-button').click()
存在shadow嵌套的情况:
<div class="shadow-host">
#shadow-root
<div id="123"></div>
<div id="mylist">
<service-card type="data" id="zx">
#shadow-root
<button class="my-button">Click me</button>
</service-card>
</div&