Skip to content

Instantly share code, notes, and snippets.

@kbingman
Created September 13, 2013 22:56
Show Gist options
  • Save kbingman/6557121 to your computer and use it in GitHub Desktop.
Save kbingman/6557121 to your computer and use it in GitHub Desktop.
Basic casper.js test
casper.test.begin('Home Page', function(test) {
loginAndPreview(baseUrl, bundleLocation, test);
casper.then(function() {
// Home body Class
test.assertExists('.x-home', 'Home body class');
// Main content
test.assertExists('.x-main', 'Main content');
});
casper.then(function() {
// Two carousels, one for women, one for men
test.assertElementCount('.m-scooch', 3, 'Scooch Containers');
// Women's Products
test.assertExists('.x-whats-new-for-women');
test.assertSelectorHasText('.x-whats-new-for-women-header', "what's new women");
test.assertExists('.x-whats-new-for-women .x-product-item:first-child a img');
test.assertElementCount('.x-whats-new-for-women .x-product-item:first-child a.pic img', 1, "Shouldn't have Multiple Images");
test.assertExists('.x-swatch-container li a', "Swatches should be tappable");
// Men's Products
test.assertExists('.x-whats-new-for-men');
test.assertSelectorHasText('.x-whats-new-for-men-header', "what's new men");
});
casper.run(function () {
// Confirm this test is done
test.done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment