gpt4 book ai didi

javascript - 如何修复不传播的 Nightmare .click() 问题?

转载 作者:搜寻专家 更新时间:2023-11-01 00:43:06 26 4
gpt4 key购买 nike

我已将遇到的问题简化为公共(public)站点的这个最小示例。单击“全部显示”按钮会触发更多站点在每个浏览器中可见,但不是 Nightmare :

var Nightmare = require('nightmare');

new Nightmare({timeout: 60000})
.viewport(1920, 10000)
.goto('http://mtv.de/charts/5-hitlist-germany-top-100')
.wait(10000)
.screenshot('before.png')
.click('div#content div.chart-container a.button.show-all')
.wait(20000)
.screenshot('after.png')
.run();

我不知道为什么这不起作用,我什至尝试用 jQuery('...').trigger('click') 触发点击,这在 Chrome 中工作,但不是在 Nightmare 中 .evaluate(...)。这是运行上述示例的调试输出,没有显示任何异常:

nightmare queueing action "viewport" +0ms
nightmare queueing action "goto" +3ms
nightmare queueing action "wait" +0ms
nightmare queueing action "screenshot" +0ms
nightmare queueing action "click" +0ms
nightmare queueing action "wait" +0ms
nightmare queueing action "screenshot" +0ms
nightmare run +0ms
nightmare .setup() creating phantom instance with options {"timeout":60000,"interval":50,"weak":true,"loadImages":true,"ignoreSslErrors":true,"sslProtocol":"any","proxy":null,"proxyType":null,"proxyAuth":null,"cookiesFile":null,"webSecurity":true} +0ms
nightmare .setup() phantom instance created +588ms
nightmare .setup() phantom page created +4ms
nightmare .viewport() to 1920 x 10000 +2ms
nightmare .goto() url: http://mtv.de/charts/5-hitlist-germany-top-100 +2ms
nightmare .goto() page loaded: success +3s
nightmare .wait() for 10000ms +501ms
nightmare .screenshot() saved to before.png +10s
nightmare .click() on div#content div.chart-container a.button.show-all +2s
nightmare .wait() for 20000ms +11ms
nightmare .screenshot() saved to after.png +20s
nightmare .teardownInstance() tearing down +2s

最佳答案

事实证明,这是开发人员知道的 phantomjs 问题,但来自上游 webkit,因此无法修复。它发生在网站使用 Modernizr(或类似软件)检查 phantom 提供的触摸支持时。当然,事件队列中点击不是触摸,nightmare的点击只会触发前者。

github issue with nightmare 拥有所有链接以了解更多信息。

关于javascript - 如何修复不传播的 Nightmare .click() 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27858871/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com