Last active
August 29, 2015 14:07
-
-
Save maciejjankowski/ffded8e03a1f3459ce2f to your computer and use it in GitHub Desktop.
using casperView to see what is going on with your script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var casper = require('casper').create({ | |
viewPortSize : { | |
width: 1024, | |
height: 768 | |
}, | |
onStepComplete : function(arg){ | |
show(); // THIS IS FOR CAPTURING SCREENSHOTS AFTER A STEP IS COMPLETE | |
}, | |
pageSettings : { | |
// loadImages: false // speeds up | |
} | |
}); | |
/* | |
below you can specify where casperView is listening. Make sure the port is set correctly | |
You can specify this in startup options: | |
casperjs your_script.js --observerUrl=http://localhost:2222 | |
*/ | |
var observerUrl = casper.cli.options.observerUrl || "http://localhost:8001/"; | |
casper.start("http://o2.pl") | |
.run() | |
setInterval(function(){ | |
show(); // ALTERNATIVE WAY - casper will send a screenshot at specified intervals | |
}, 300); | |
function show(){ | |
casper.evaluate( function(img, observerUrl){ | |
__utils__.sendAJAX(observerUrl, 'POST', {'img' : img }, false); | |
}, | |
casper.captureBase64('png'), | |
observerUrl | |
); // evaluate | |
} // show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment