-
-
Save FabricioFFC/fd6e6ca12897478a012c to your computer and use it in GitHub Desktop.
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
# Google sample testing. | |
# | |
# Usage: | |
# $ casperjs test googletesting.coffee | |
casper.test.begin 'Google search retrieves 10 or more results', 5, (test) -> | |
casper.start "http://www.google.fr/", -> | |
test.assertTitle "Google", "google homepage title is the one expected" | |
test.assertExists 'form[action="/search"]', "main form is found" | |
@fill 'form[action="/search"]', q: "foo", true | |
casper.then -> | |
test.assertTitle "foo - Recherche Google", "google title is ok" | |
test.assertUrlMatch /q=foo/, "search term has been submitted" | |
test.assertEval (-> | |
__utils__.findAll("h3.r").length >= 10 | |
), "google search for \"foo\" retrieves 10 or more results" | |
casper.run -> test.done() | |
casper.test.begin "Casperjs.org is first ranked", 1, (test) -> | |
casper.start "http://www.google.fr/", -> | |
@fill "form[action=\"/search\"]", q: "casperjs", true | |
casper.then -> | |
test.assertSelectorContains ".g", "casperjs.org", "casperjs.org is first ranked" | |
@capture './search_for_casperjs.png' | |
casper.run -> test.done() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment