Created
March 22, 2016 18:13
-
-
Save paoga87/4bd683a07221faf30690 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* Simple screenshot test using CasperJS to capture an entire web page | |
* by Paola Garcia Cardenas | |
*/ | |
// set screenshot URL variable | |
var screenshotUrl = 'http://www.paolagarcia.com'; | |
// set viewport size | |
casper.options.viewportSize = {width: 1928, height: 1274}; | |
casper.test.begin("myTest", function(test) { | |
// open the page. | |
casper.start(screenshotUrl, function() { | |
// test page title | |
test.assertTitle("Paola M. Garcia Cardenas | Welcome to my personal website"); | |
}); | |
// set user-agent | |
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)'); | |
// take screenshots | |
casper.then(function() { | |
// capture entire homepage | |
casper.capture("Homepage.png"); | |
// capture the page area that contains the specified element | |
casper.captureSelector("AboutMe.png", "#et_page_2"); | |
}); | |
// run the entire script (without this, the program won't run...) | |
casper.run(function() { | |
test.done(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment