Skip to content

Instantly share code, notes, and snippets.

@clytras
Forked from kbingman/gist:6557074
Created March 14, 2017 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clytras/8afdbd1f4fd7088da5af9e66ff0e3d75 to your computer and use it in GitHub Desktop.
Save clytras/8afdbd1f4fd7088da5af9e66ff0e3d75 to your computer and use it in GitHub Desktop.
external include for casper.js login and preview
var require = patchRequire(require);
var loginAndPreview = function(baseUrl, bundleLocation, test){
casper.start('http://preview.mobify.com/', function suite() {
// Add a title comment so that you know what's happening and when
casper.test.comment('Lululemon - 2013 Refresh');
// Log out what we are doing
test.info('Previewing: ' + baseUrl);
// Populate the url box with our site and submit the form
this.fill('form', {
'url': baseUrl,
'site_folder': bundleLocation
}, true);
// Log out what we are doing
test.info('Mobifying...');
casper.waitForUrl(/whats-new/, function() {
var pathname = casper.evaluate(function() {
return document.location.pathname;
});
this.echo('redirected to ' + pathname);
test.assertEquals(pathname, '/products/category/whats-new', 'URL matches /products/category/whats-new');
casper.waitForSelector('#x-root', function() {
test.info('Mobified.');
test.assertExists('#x-root', 'The page is mobified');
});
});
});
}
exports.login = loginAndPreview;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment