Javascript 单击包含特定alt标记的元素
我目前拥有以下代码:Javascript 单击包含特定alt标记的元素,javascript,node.js,puppeteer,Javascript,Node.js,Puppeteer,我目前拥有以下代码: <div class="c-form-field c-form-field--radio SelectStyle col"> <label for="input_radio_style_17" aria-hidden="false" class=""> <span class="c-form-label-content"> <span class="c-image product c-image--square"> <s
<div class="c-form-field c-form-field--radio SelectStyle col">
<label for="input_radio_style_17" aria-hidden="false" class="">
<span class="c-form-label-content">
<span class="c-image product c-image--square">
<span class="LazyLoad is-visible">
<img src="https://images.example.com/23434234.jpg" alt="Green picture frame" id="I0065001">
</span>
</span>
</span>
</label>
<input name="style" aria-labelledby="styleI0065001" id="input_radio_style_17" type="radio" required="" value="17"></div>
从这里我有点困惑,我如何返回匹配的元素,然后单击它?你可以用
我得到了这个错误:(节点:55234)未处理的PromisejectionWarning:错误:应该得到| string |或| function |作为第一个参数,但是得到了“undefined”。知道为什么吗@hardkodedSo sorry@FabricioG它应该是
$$
而不是`$$eval'``
const imgs = await page.$$eval('.SelectStyle', imgs => imgs.map{
return (img => img.getAttribute('alt'))
});
const imgs = await page.$$('.SelectStyle img[alt="Green picture frame"]');