Reputation: 22926
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.com">
<input onclick="" type="submit" value="yahoo" class="button">
</form>
<form action="http://google.com">
<input onclick="" type="submit" value="google" class="button">
</form>
</body>
</html>
and suppose I want to click the button to redirect to google.com, 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 accomplish this in puppeteer?
This doesn't work:
await page.click('input[value="google",type="submit"]')
Upvotes: 3
Views: 5720
Reputation: 3431
You can use attribute selector
const element = await page.$('[value="google"]');
await element.click();
Upvotes: -1
Reputation: 3013
Multiple value selector:
await page.click('input[value="google"][type="submit"]');
Upvotes: 5