Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击包含特定alt标记的元素_Javascript_Node.js_Puppeteer - Fatal编程技术网

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"]');