Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Requirements

  • phantomjs
  • casperjs


Warning
titlePlease note

As of 2019, CasperJS is no longer maintained.


Description


Code Block
languagejs
titlegoogle_testing.js
casper.test.begin('Google search retrieves 10 or more results', 5, function suite(test) {
    casper.start("http://www.google.fr/", function() {
        test.assertTitle("Google", "google homepage title is the one expected");
        test.assertExists('form[action="/search"]', "main form is found");
        this.fill('form[action="/search"]', {
            q: "casperjs"
        }, true);
    });
    casper.then(function() {
        test.assertTitle("casperjs - Recherche Google", "google title is ok");
        test.assertUrlMatch(/q=casperjs/, "search term has been submitted");
        test.assertEval(function() {
            return __utils__.findAll("h3.r").length >= 10;
        }, "google search for \"casperjs\" retrieves 10 or more results");
    });
    casper.run(function() {
        test.done();
    });
});

...

The Execution Details of the Generic Test contains information about the Test Suite, which in this case corresponds to the name of the test case.


References

  • http://docs.casperjs.org/en/latest/testing.html