Puppeteer page.click(选择器)没有响应IFrame

问题描述 投票:1回答:1

await page.evaluate(() => {
  window.scrollBy(0, window.innerHeight);
})
jest.setTimeout(20000)
await page.click('#ApplyBthNAP, #btnCheck');
<iframe id="frameContent" frameborder="0" height="100%" marginheight="0" marginwidth="0" scrolling="no" width="100%" src="html/status/wlaninfo.asp" style="height: 585px;"></iframe>

<div id="ApplyBthNAP">
  <span class="tabal_head"> 
    <script>
      document.write(status_wlaninfo_language['amp_napinfo_title']);     
    </script>
    Neighboring AP Information
  </span>
  <input style="margin-left:25px;" name="btnCheck" class="submit" id="btnCheck" type="button" value="Query">
  <script>
    document.getElementsByName('btnCheck')[1].value = status_wlaninfo_language['amp_stainfo_query'];
  </script>
</div>

我一直得到的错误是FAIL test \ header.test.js(24.613s)×点击查看网址(23238ms)

●单击并检查URL

TypeError: Cannot read property 'click' of null

  at Page.click (node_modules/puppeteer/lib/Page.js:816:18)

console.assert node_modules \ puppeteer \ lib \ Page.js:815 AssertionError [ERR_ASSERTION]:找不到选择器的节点:#ApplyBthNAP,#btnCheck

测试套房:1次失败,共1次

经过一些研究后我才知道木偶操作者有一些与IFrame相关的错误。要求是按下一个带有Value ='Query'的按钮。普通选择器方法的唯一问题是它显示为null。请赐教。提前致谢

javascript css node.js jestjs puppeteer
1个回答
0
投票

也许你的意思是('#ApplyBthNAP #btnCheck')而不是('#ApplyBthNAP, #btnCheck')找到div中的按钮,而不是按钮和div?

© www.soinside.com 2019 - 2024. All rights reserved.