我已经减少了问题,我有一个公共网站的这个最小的例子。单击“显示所有”按钮将触发更多的站点在每个浏览器中可见,但不会在噩梦中看到:
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中工作,但不是在噩梦般的.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发布于 2015-01-14 13:46:32
这是开发人员意识到的幻影的一个问题,但来自上游的webkit,使其无法修复。当站点使用现代化(或类似的)检查触摸支持时,就会发生这种情况,幻影提供了这种支持。当然,在事件队列中,单击不是触碰的,而噩梦的单击只触发前者。
噩梦的github问题有所有的链接来学习更多。
发布于 2015-01-09 11:42:34
我找不出为什么它不能工作,但是您可以简单地在url中加载带有?expanded=true参数的url。
我用以下方法尝试了CasperJS:
page.sendEvent,document.querySelector(selector).click()。我参加了所有的活动,但都没有提供任何线索。
https://stackoverflow.com/questions/27858871
复制相似问题