var utils = require('utils'); var fs = require('fs'); var casper = require('casper').create({ verbose: true, logLevel: "debug", stepTimeout: 20000, onStepTimeout: function(){ casper.die("Step timeout", 1); casper.exit() }, pageSettings: { loadImages: false, loadPlugins: true, userAgent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.8 (KHTML, like Gecko) Chrome/17.0.940.0 Safari/535.8" }, viewportSize: { width: 1280, height: 1024 } }).start(); casper.options.onResourceRequested = function(C, requestData, request) { utils.dump("reqData"); utils.dump(requestData); // here utils.dump("req"); utils.dump(request); // here }; casper.options.onResourceReceived = function(C, response) { utils.dump("response"); utils.dump(response); }; // so there is 500 on that request for some reason do we have any idea what the request is? wbell we have request object, // prints headers and info about it casper.thenOpen('https://www.facebook.com/?_rdr', function() { //just the facebook login page ok, so need to try add sleep, and then //print content again, maybe it just need more time }); //no good it seems, right? well i think i had same thing, it was because of ssl and ceritifcates, let's try one thing one sec. casper.waitForSelector("#email", function() { this.fill('form#login_form', { email: 'andrew.fenlon@tufts.edu', pass: '$mnesi42' }, true); // casper.sendKeys('#email', 'andrew.fenlon@tufts.edu') // casper.sendKeys('#pass', '$mnesi42') // casper.click('#u_0_l') // this.echo(this.getTitle()); }); casper.waitForSelector("#pagelet_welcome_box", function() { }); casper.thenOpen('https://www.facebook.com/photo.php?fbid=108354332830245', function(){ casper.scrollTo(0,0); casper.scrollToBottom(); fs.write("tmp.html", this.getHTML(), 'w'); this.waitForSelector('a.UFILikeLink', function(){ } ); this.waitForSelector('#fbPhotoImage', function(){ this.waitForSelector('div.like', function(){ // this.waitForSelector('a.UFILikeLink', function(){ //// casper.echo(this.getHTML()) //should I write it to a file? yeah // casper.click('button.like_link', function(){ casper.echo("clicked") }); // looks good, it sort of click on it, but not sure if js was triggered, or only