Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.click() not working. #142

Closed
apfelfabrik opened this issue Jan 9, 2015 · 5 comments
Closed

.click() not working. #142

apfelfabrik opened this issue Jan 9, 2015 · 5 comments

Comments

@apfelfabrik
Copy link

I tried to reduce the issue I'm having to this minimal example with a public site:

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();

I'm drawing a blank as to why this doesn't work, I even tried to trigger the click with jQuery('...').trigger('click'), which works in Chrome, but not in nightmare. Triggering with jQuery inside of a nightmare .evaluate(...) does not work either. Here is the debug output from running the above example:

  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

The screenshots are just a help figuring out that the list does not expand, when checking the DOM in .evaluate()-calls directly, I see that no additional nodes in the list become visible.

@apfelfabrik
Copy link
Author

Ok, this has nothing to do with nightmare but is an incarnation of this phantomjs phenomenon:

[https://github.com/ariya/phantomjs/issues/10375], previously [https://code.google.com/p/phantomjs/issues/detail?id=375], most recently [https://github.com/Modernizr/Modernizr/issues/1344].

@RainerAtSpirit
Copy link

Hit by the same issue. Have you found a fix for that?

@johntitus
Copy link

Have you tried using PhantomJS 2.0? The list expands ok for me.

@RainerAtSpirit
Copy link

Stuck on 1.9.x for the time being. Found a workaround by using .evaluate, window.setTimeout and calling an available onclick method directly. Feels hacky :(.

@apfelfabrik
Copy link
Author

apfelfabrik commented Mar 9, 2015

For me, it was an app that would not register for the click events after registering for touch. @RainerAtSpirit: If it really is the same issue, you could do one of the following:

  1. Register for click events instead of touch on the application side or
  2. Actually create touch events via nightmares JS injection into the browser or
  3. Trigger the click hanlders programatically w/o true browser events

It appears you resorted to (3). The other approaches might feel less hacky for you, especially (1).

@johntitus Haven't tried 2.0 yet, I'll give it a shot. The above example was fixed in the original app for me though and now also works w/ 1.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants