-
-
Save clytras/8afdbd1f4fd7088da5af9e66ff0e3d75 to your computer and use it in GitHub Desktop.
external include for casper.js login and preview
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 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