admin管理员组文章数量:1415476
I have the following html:
<html>
<body>
<div title="test" class="test">hello</div>
<input onclick="" type="confusepuppet" value="google" class="button">
<form action="">
<input onclick="" type="submit" value="yahoo" class="button">
</form>
<form action="">
<input onclick="" type="submit" value="google" class="button">
</form>
</body>
</html>
and suppose I want to click the button to redirect to google, I can't use value="google" or type="submit", I have to use both value="google" AND type="submit" to avoid clicking the wrong button.
How do I acplish this in puppeteer?
This doesn't work:
await page.click('input[value="google",type="submit"]')
I have the following html:
<html>
<body>
<div title="test" class="test">hello</div>
<input onclick="" type="confusepuppet" value="google" class="button">
<form action="http://yahoo.">
<input onclick="" type="submit" value="yahoo" class="button">
</form>
<form action="http://google.">
<input onclick="" type="submit" value="google" class="button">
</form>
</body>
</html>
and suppose I want to click the button to redirect to google., I can't use value="google" or type="submit", I have to use both value="google" AND type="submit" to avoid clicking the wrong button.
How do I acplish this in puppeteer?
This doesn't work:
await page.click('input[value="google",type="submit"]')
Share Improve this question asked Feb 8, 2020 at 1:54 medsmeds 23k42 gold badges175 silver badges337 bronze badges2 Answers
Reset to default 5Multiple value selector:
await page.click('input[value="google"][type="submit"]');
You can use attribute selector
const element = await page.$('[value="google"]');
await element.click();
本文标签: javascriptPuppeteerselect element with multiple selectorsStack Overflow
版权声明:本文标题:javascript - Puppeteer - select element with multiple selectors - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745196706a2647174.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论