0

Username and password can be filled, but "Sign in" button can't be clicked.

Here is my command line:

/usr/local/bin/casperjs /Users/twyt/Downloads/casperLogin.js http://bato.to/

And here is casperLogin.js:

var casper = require('casper').create({

pageSettings: {
    loadImages:  true,        // The WebPage instance used by Casper will
    loadPlugins: true,
    userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7"         // use these settings
},
logLevel: "info",              // Only "info" level messages will be logged
verbose: true                  // log messages will be printed out to the console
});

casper.start(casper.cli.get(0), function() {

});

casper.then(function() {
    this.click('a[id="sign_in"]');  
    this.echo("sign_in click");   
});

casper.wait(3000, function () {   
this.sendKeys('div.ipbfs_login div.ipbfs_login_col input[id="ips_username"]', 'york');
this.sendKeys('div.ipbfs_login div.ipbfs_login_col input[id="ips_password"]', "szWYB213456");
 this.echo("fill user name");   
});

casper.then(function() {
 this.click('div.ipbfs_login div.ipsForm_submit.ipsForm_center.clear input[type="submit"]');
 this.echo("click sign_in button");   
});

casper.wait(5000, function () {   
    this.echo(this.getTitle());   
    this.capture("login.png");   
});

casper.run();
  • Your code looks fine. 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. Nov 23 '15 at 14:20
  • @Artjom B, Thank you very much! After add events, the output is below:Console: Refused to display document because display forbidden by X-Frame-Options. [warning] [phantom] Loading resource failed with status=fail (HTTP 200): http://bato.to/. Do you know what it means? – user2223080 Nov 23 '15 at 14:46
  • Have you tried calling it like this `casperjs --ssl-protocol=any --ignore-ssl-errors=true script.js`? See: http://stackoverflow.com/questions/26415188/casperjs-phantomjs-doesnt-load-https-page – Artjom B. Nov 23 '15 at 15:06
  • Just did it. Still show those error message. After reading the post, I guess using casper 1.0.4 and phantom 2.0.0 could be the problem. I will change it to phantom 1.9x, and update the test later. – user2223080 Nov 23 '15 at 15:50
  • It woks, Thank you very much! – user2223080 Nov 26 '15 at 14:46

0 Answers0