Skip to content

Instantly share code, notes, and snippets.

@tjFogarty
Created August 11, 2015 15:13
Show Gist options
  • Save tjFogarty/46a6bc231dbebe925728 to your computer and use it in GitHub Desktop.
Save tjFogarty/46a6bc231dbebe925728 to your computer and use it in GitHub Desktop.
Testing WordPress Search Form with CasperJS
/*global casper*/
'use strict';
var config = require('../config'),
page = 'http://' + config.local_url + '/',
formData = {
's': 'suppliers' // search term
};
casper.test.begin('Testing search form', 2, function suite(test) {
test.comment('Loading ' + page + '...');
casper.start(page, function() {
test.assertExists('.c-form--search', 'Test that search form is present');
});
casper.then(function() {
test.comment('Filling out the form...');
casper.fill('.c-form--search', formData, false);
casper.thenClick('.c-form--search .c-button');
});
casper.then(function() {
test.assertTextExists('Search results for ' + formData.s, 'Results page contains search query');
});
casper.run(function() {
test.done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment