首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决无法传播的噩梦.click()问题?

如何解决无法传播的噩梦.click()问题?
EN

Stack Overflow用户
提问于 2015-01-09 10:47:56
回答 2查看 2K关注 0票数 2

我已经减少了问题,我有一个公共网站的这个最小的例子。单击“显示所有”按钮将触发更多的站点在每个浏览器中可见,但不会在噩梦中看到:

代码语言:javascript
复制
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(...)中。下面是运行上述示例的调试输出,没有显示什么特别之处:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-01-14 13:46:32

这是开发人员意识到的幻影的一个问题,但来自上游的webkit,使其无法修复。当站点使用现代化(或类似的)检查触摸支持时,就会发生这种情况,幻影提供了这种支持。当然,在事件队列中,单击不是触碰的,而噩梦的单击只触发前者。

噩梦的github问题有所有的链接来学习更多。

票数 3
EN

Stack Overflow用户

发布于 2015-01-09 11:42:34

我找不出为什么它不能工作,但是您可以简单地在url中加载带有?expanded=true参数的url。

我用以下方法尝试了CasperJS:

  • CasperJS的本机单击使用PhantomJS page.sendEvent
  • 合成PhantomJS点击 (类似于梦魇正在使用的那个)和
  • 朴素点击:document.querySelector(selector).click()

我参加了所有的活动,但都没有提供任何线索。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27858871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档