我有以下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>
,假设我想单击按钮重定向到google.com,我不能使用value =“ google”或type =“ submit”,我必须同时使用value =“ google”和type =“ submit以避免点击错误的按钮。
我该如何在操纵up中做到这一点?
这不起作用:
等待页面。click('input [value =“ google”,type =“ submit”]')
答案 0 :(得分:2)
多个值选择器:
await page.click('input[value="google"][type="submit"]');
答案 1 :(得分:0)
您可以使用attribute selector
const element = await page.$('[value="google"]');
await element.click();