Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Google sample testing.
# Usage:
# $ casperjs test
casper.test.begin 'Google search retrieves 10 or more results', 5, (test) ->
casper.start "", ->
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" -> test.done()
casper.test.begin " is first ranked", 1, (test) ->
casper.start "", ->
@fill "form[action=\"/search\"]", q: "casperjs", true
casper.then ->
test.assertSelectorContains ".g", "", " is first ranked"
@capture './search_for_casperjs.png' -> test.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.