Created
August 11, 2015 15:13
-
-
Save tjFogarty/46a6bc231dbebe925728 to your computer and use it in GitHub Desktop.
Testing WordPress Search Form with CasperJS
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
/*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