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
210
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
63
Design a REST API you will love to work with
ujovlado
0
700
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
430
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
330
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
85
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
50
CSS Flexbox (WebElement #35)
ujovlado
0
110
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
120
Don't underestimate CSS (WebElement #30)
ujovlado
0
530
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
230
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
690
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
Beyond ORM
77web
2
210
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
What's in a price? How to price your products and services
michaelherold
243
12k
For a Future-Friendly Web
brad_frost
175
9.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
How GitHub (no longer) Works
holman
311
140k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
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:~$