Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testovanie web aplikácií s CasperJS (WebElement #11)

Testovanie web aplikácií s CasperJS (WebElement #11)

Vladimír Kriška

September 06, 2012
Tweet

More Decks by Vladimír Kriška

Other Decks in Programming

Transcript

  1. Čo je CasperJS? Navigation scripting & testing utility CasperJS je

    postavený na PhantomJS - náhrada browsera využívajúca Webkit.
  2. Čo všetko vie? • Browsovať • Vypĺňať formuláre • Klikať

    • Robiť screenshoty • Sťahovať content • Testovať • ...
  3. Inštalácia • Stiahnúť PhantomJS a CasperJS • Vytvoriť symlinky vlado@pc:~$

    ln -s casper_path/bin/casperjs /usr/local/bin/casperjs vlado@pc:~$ casperjs javascript.js
  4. Command Line Interface casper.cli.has(); casper.cli.get(); Dva prístupy. // pre options

    casper.cli.has("arg"); // casper.cli.get("arg"); // pre args casper.cli.has(0); // casper.cli.get(0);
  5. HTTP Status Codes Nezačnem testovať keď nastala chyba. casper.on('http.status.404', function()

    { this.echo('404').exit(); }); casper.start('http://localhost/404', function() { this.echo('vsetko v poriadku'); });
  6. Verbose (debug) mode Chcem vedieť, čo sa deje var casper

    = require('casper').create({ verbose: true, logLevel: "debug" }); // logovanie casper.log('debug message', 'debug');
  7. Vlastné eventy casper.on("webelement.presentation", function (status) { this.echo("WebElement prednaska " +

    status); }); casper.start("http://localhost/casperjs", function() { var presentationStatus = 'bezi'; this.emit("webelement.presentation", presentationStatus); });
  8. Testovanie Metódy: • assert() • assertEval() • assertExists() • assertNot()

    • ... this.test.assertExists('.form', 'Form existuje');