Skip to content

Instantly share code, notes, and snippets.

@ruudud
Created January 23, 2014 09:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruudud/8575785 to your computer and use it in GitHub Desktop.
Save ruudud/8575785 to your computer and use it in GitHub Desktop.
Setting cookies before page load in a CasperJS test.
casper.test.setUp(function () {
casper.echo('Cookies enabled?: ' + phantom.cookiesEnabled);
phantom.addCookie({
domain: '.localhost',
name: 'sessionId',
value: '12345abcd6789efg'
});
casper.start("http://localhost:8000/test_index.html#pageRequiringLogin", function () {
casper.echo('Start callback has cookie: ' + JSON.stringify(phantom.cookies));
});
});
casper.test.begin("Should do usefull stuff", function (test) {
// …
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment