【发布时间】:2020-10-21 16:01:46
【问题描述】:
我有这个网站https://www.storytel.com/sg/en/我试图单击位于 Shadowroot 中的订阅组件中的按钮(请参阅图像)。我已尝试使用以下代码,但没有成功。如果有人可以提供帮助,那就太好了。提前致谢。
test('Click inside shadowDOM', async t => {
const shadowBtn = Selector(() => document.querySelector('storytel-subscription').shadowRoot.querySelectorAll('*[data-testid="subscription-card-0-button"]'));
await t
.click(shadowBtn);
});
【问题讨论】:
-
为什么选择器中有 *?
-
因此它与任何具有 data-testid="subscription-card-0-button" 属性的标签匹配
标签: testing automated-tests selector testcafe shadow-dom