Skip to content

Instantly share code, notes, and snippets.

@digilord
Created February 4, 2014 23:55
Show Gist options
  • Save digilord/8814875 to your computer and use it in GitHub Desktop.
Save digilord/8814875 to your computer and use it in GitHub Desktop.
// Add a title comment so that you know what's happening and when
casper.test.comment('Development SlideSlider - Homepage');
// Setup any variables you may need. In this case we need a search term
//var search_term = "speed of an unladen swallow";
// Start casper running on a web page, in this case the awesome
// duckduckgo seach engine.
casper.start('http://io.local:3000/', function () {
// Check the title is "DuckDuckGo"
this.test.assertTitle('SlideSlider', 'Homepage has the correct title');
//check to see if headline copy is there
this.test.assertSelectorHasText('h1.h1-landing', 'Advancing The Presentation.');
// Check the sitenav is available
this.test.assertExists('nav.navbar.navbar-inverse.navbar-fixed-top', 'sitenav is available');
// Check the footer is available
this.test.assertExists('nav.navbar.navbar-default.navbar-fixed-bottom', 'footer is available');
// Check the sign up button is available
this.test.assertExists('#SignUpButton', 'sign up button is available');
// Check the sitenav logo is available
this.test.assertExists('#home-page-logo', 'sitenav logo is available');
// Log out what we are doing
//casper.test.info("Populating search box with term: " + search_term);
// Populate the seach box with a query
// this.fill('#search_form_homepage', {
// 'q': search_term
// }, true);
// Log out what we are doing
//casper.test.info("Testing search...");
this.capture('screenshots/home.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
});
casper.then(function() {
// Click on 1st result link
this.click('#SignUpButton');
});
casper.then(function() {
this.echo(' - sign up button clicked ok, new location is ' + this.getCurrentUrl());
// Check the name field is available
this.test.assertExists('#name', 'name field is available');
// Check the inputEmail field is available
this.test.assertExists('#inputEmail', 'inputEmail field is available');
// Check the inputPassword field is available
this.test.assertExists('#inputPassword', 'inputPassword field is available');
// Check the inputName field is available
this.test.assertExists('#inputName', 'inputName field is available');
// Check the inputCard field is available
this.test.assertExists('#inputCard', 'inputCard field is available');
// Check the inputExpiry field is available
this.test.assertExists('#inputExpiry', 'inputExpiry field is available');
// Check the inputCVC field is available
this.test.assertExists('#inputCVC', 'inputCVC field is available');
// Check the inputAddress field is available
this.test.assertExists('#inputAddress', 'inputAddress field is available');
// Check the inputCity field is available
this.test.assertExists('#inputCity', 'inputCity field is available');
// Check the inputState field is available
this.test.assertExists('#inputState', 'inputState field is available');
// Check the inputZip field is available
this.test.assertExists('#inputZip', 'inputZip field is available');
this.capture('screenshots/signup.png', {
top: 0,
left: 0,
width: 1024,
height: 768
});
});
// After the form has been submitted and results shown
// casper.then(function () {
// // Test we got results back from our search query
// this.test.assertEval(function () {
// return __utils__.findAll('div.results_links_deep').length > 10;
// }, 'Returned search results for query');
// });
// Run the whole test suite (all the above)
casper.run(function () {
// Confirm this test is done
this.test.done();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment