Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testovanie web aplikácií s CasperJS (WebElement...
Search
Vladimír Kriška
September 06, 2012
Programming
0
250
Testovanie web aplikácií s CasperJS (WebElement #11)
Vladimír Kriška
September 06, 2012
Tweet
Share
More Decks by Vladimír Kriška
See All by Vladimír Kriška
Twelve-Factor app with Docker
ujovlado
0
110
Design a REST API you will love to work with
ujovlado
0
750
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
480
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
380
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
140
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
91
CSS Flexbox (WebElement #35)
ujovlado
0
160
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
160
Don't underestimate CSS (WebElement #30)
ujovlado
0
590
Other Decks in Programming
See All in Programming
LLMOpsのパフォーマンスを支える技術と現場で実践した改善
po3rin
8
990
オープンセミナー2025@広島「君はどこで動かすか?」アンケート結果
satoshi256kbyte
0
220
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
290
コーディングエージェント時代のNeovim
key60228
1
110
ソフトウェアテスト徹底指南書の紹介
goyoki
1
110
Google I/O recap web編 大分Web祭り2025
kponda
0
2.9k
testingを眺める
matumoto
1
120
TanStack DB ~状態管理の新しい考え方~
bmthd
2
340
Understanding Ruby Grammar Through Conflicts
yui_knk
1
140
令和最新版手のひらコンピュータ
koba789
14
8.1k
Constant integer division faster than compiler-generated code
herumi
2
700
STUNMESH-go: Wireguard NAT穿隧工具的源起與介紹
tjjh89017
0
390
Featured
See All Featured
How GitHub (no longer) Works
holman
315
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
RailsConf 2023
tenderlove
30
1.2k
How to Ace a Technical Interview
jacobian
279
23k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Embracing the Ebb and Flow
colly
87
4.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
The Cult of Friendly URLs
andyhume
79
6.6k
Transcript
CasperJS Vladimír Kriška (@ujovlado) WebElement #11
Čo je CasperJS? Navigation scripting & testing utility CasperJS je
postavený na PhantomJS - náhrada browsera využívajúca Webkit.
Čo všetko vie? • Browsovať • Vypĺňať formuláre • Klikať
• Robiť screenshoty • Sťahovať content • Testovať • ...
A ešte • Vykonávať kód na klientskej strane • Pracovať
s viewportom • ...
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
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);
Selektory // CSS3 casper.test.assertExists('#main', 'existuje'); // XPath casper.test.assertExists({ type: 'xpath',
path: '//*[@id="main"]' }, 'existuje');
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'); });
Verbose (debug) mode Chcem vedieť, čo sa deje var casper
= require('casper').create({ verbose: true, logLevel: "debug" }); // logovanie casper.log('debug message', 'debug');
Eventy casper.on("meno.eventu", function(resource) { // nieco sprav }); • http.status.[code]
• remote.alert • fill • start, exit • click • ...
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); });
Testovanie Metódy: • assert() • assertEval() • assertExists() • assertNot()
• ... this.test.assertExists('.form', 'Form existuje');
Príklady ...
Ďakujem vlado@pc:~$ casperjs presentation.js PASS Odprezentovane PASS 1 tests executed,
1 passed, 0 failed. vlado@pc:~$