剧作家如果找到了很多地段,则如何单击特定元素?
我很难单击第三个元素。我尝试了索引,并且.thixd()方法仍然不起作用。
测试结果: 测试结果
async clickAddToCart(page) {
const element = commonEl.addToCart();
await page.evaluate((el) => document.querySelector(el)[3].click(), element)
}
addToCart() {
return ('.bg-blue-500.text-white.font-semibold.rounded-md');
}
试图获得这个元素 试图获得此元素
I having a hard time clicking 3rd element found. I tried index, and .third() method still not working.
Test Result:
Test Result
async clickAddToCart(page) {
const element = commonEl.addToCart();
await page.evaluate((el) => document.querySelector(el)[3].click(), element)
}
addToCart() {
return ('.bg-blue-500.text-white.font-semibold.rounded-md');
}
Trying to get this element
Trying to get this element
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为此使用
nth
选择器。对于第三个按钮,您必须使用索引值为2。You can use the
nth
selector for this. For the third button you have to use the index value as 2.