0

After trying this answer How to login into a website with CasperJS? I didn't work apparently fill function is the one failing Now facebook doesn't have emai, and pass as direct children of login_form does this affect the code ? I figured it stops at this.test.assert... my code

var casper = require('casper').create({   
    pageSettings: {
         loadImages:  false,         // The WebPage instance used by Casper will
         loadPlugins: false,         // use these settings
         userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
    }
});
var url = 'https://www.facebook.com/';

casper.start(url, function() {
   console.log("page loaded");
   this.test.assertExists('form#login_form', 'form is found');
   this.fill('form#login_form', { 
        email: 'email', 
        pass:  'pass'
    }, true);
});

casper.then(function() {
    this.evaluateOrDie(function() {
        return /message sent/.test(document.body.innerText);
    }, 'sending message failed');
});

casper.run(function() {
    this.echo('message sent').exit();
});

In case no answers I got what I need working with PhantomJS only

Community
  • 1
  • 1
capadleman
  • 85
  • 6

2 Answers2

0

Version problem, not clear what was the problem.

0

Change the call to phantomjs in the batchbin/casperjs.bat file from

call phantomjs "%CASPER_BIN%bootstrap.js" --casper-path="%CASPER_PATH%" --cli %ARGV% 

to

call phantomjs --ignore-ssl-errors=yes "%CASPER_BIN%bootstrap.js" --casper-path="%CASPER_PATH%" --cli %ARGV% 

This simply forces the ignore-ssl-errors on every call to phantomjs, which for my use case was fine. This is not a fix, just a hack.

https://github.com/n1k0/casperjs/issues/49

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Shakil Ahmed
  • 1,481
  • 2
  • 19
  • 26