0

If we use casper without --engine=slimerjs the casper.scrollToBottom(); and casper.page.scrollPosition = {top: scrollHeight, left: 0}; is not working.

I mean if we use just $ casperjs file.js it not works. But with $ casperjs --engine=slimerjs file.js it works good enough.

Any suggestion? maybe I should use something in command line? like --webdriver? I tried --ssl-protocol=any - IT ALSO DOESN'T HELPS. Or maybe I should include JS files like page.includeJs('https://www.my-site.com/thisjsfile.min.js')

P.S.: I'm not believe that it will be helpful but here is the code:

casper.then(function() {
  this.waitForSelector('#myselector', function() {
    this.open('http://www.my-site.com/messages');
    this.echo('Open messages Inbox');
  });
})
.then(function() {
  this.repeat(timesForCasperRepeat, function() {
    this.wait(5000, function() {
      scrollHeight = this.evaluate(function() {
          return document.body.scrollHeight;
      });
      this.echo('Scroll Height: ' + scrollHeight);
      this.scrollToBottom();
      this.echo('scrolling down', 'INFO_BAR');
    });
  }); 
}); 

even I change scrollToBottom() to:

this.page.scrollPosition = {
    top: scrollHeight,
    left: 0
  };

I also included Anrtjom's handle errors events, there is a link

and there is the errors i have:

Error: ReferenceError: Can't find variable: ourvarname1
Error: ReferenceError: Can't find variable: jQuery
Error: ReferenceError: Can't find variable: ourvarname2
Error: ReferenceError: Can't find variable: ourvarname3
Error: TypeError: 'undefined' is not a function (evaluating 'RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/)')
Console: Unsafe JavaScript attempt to access frame with URL http://www.my-site.com/messages from frame with URL http://ads.my-site.com/daisy?browser=windows_chrome&base=1&page=Mailbox&pageurl=%2fmessages&format=half_page&authid=1%2c0%2c1457605848%2c0xf290ca6243d86169%3beed7d0c7a540f963b5268452a4c95ac74793badc&cachebust=655998. Domains, protocols and ports must match.
HappyCoder888
  • 736
  • 1
  • 8
  • 16
  • Which PhantomJS version do you use? Please register to the `resource.error`, `page.error`, `remote.message` and `casper.page.onResourceTimeout` events ([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file-2_caspererrors-js)). Maybe there are errors. – Artjom B. Mar 09 '16 at 10:32
  • Phantomjs version 2.1.1 – HappyCoder888 Mar 09 '16 at 12:17
  • Since you haven't said anything about the site (or whether there are any error), we can only guess what the issue is. Check if you're on the correct page by taking a screenshot. Make sure that the body is actually scrollable and not some ancestor element such as a div. Make sure that you have changed into the iframe if you're interested in the contents of the iframe. – Artjom B. Mar 09 '16 at 15:25
  • You're not using PhantomJS 2.1.1, because `Function.prototype.bind` is implemented. It's not implemented in PhantomJS 1.x. Make sure that you're using the correct executable, for example by setting the `PHANTOMJS_EXECUTABLE` environment variable. – Artjom B. Mar 09 '16 at 16:24
  • what does mean `PHANTOMJS_EXECUTABLE` ? maybe problem is here https://github.com/ariya/phantomjs/issues/12181 – HappyCoder888 Mar 11 '16 at 15:13
  • CasperJS may use a different PhantomJS version than what is accessible through the PATH. For example, if you've installed it through NPM, it comes with an internal PhantomJS 1.x. Make sure you have only one and if you have multiple, choose a specific one: `export PHANTOMJS_EXECUTABLE=/path/to/phantomjs` (no idea if this does anything as I'm not a Mac user.) – Artjom B. Mar 11 '16 at 15:20
  • yes, you was right the problem was in phantomjs version in casperjs – HappyCoder888 Mar 12 '16 at 06:48

1 Answers1

1

found solution and it works for me, the problem was that casperjs use older version of phantomjs, so for mac users just go to folder where casperjs installed. For me it was: /usr/local/Cellar/casperjs/. And find folder with phantomjs: /usr/local/Cellar/casperjs/1.1-beta4/libexec/phantomjs and change it to new dowloaded from phantomjs website.

I found that casperjs used 1.9 version, but current phantomjs is 2.1.1, just changed folder to new one and no problems with it.

HappyCoder888
  • 736
  • 1
  • 8
  • 16