Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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