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
740
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
470
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
370
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
130
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
83
CSS Flexbox (WebElement #35)
ujovlado
0
150
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
160
Don't underestimate CSS (WebElement #30)
ujovlado
0
580
Other Decks in Programming
See All in Programming
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
660
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
150
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
420
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
640
チームのテスト力を総合的に鍛えて品質、スピード、レジリエンスを共立させる/Testing approach that improves quality, speed, and resilience
goyoki
3
440
CursorはMCPを使った方が良いぞ
taigakono
1
240
iOS 26にアップデートすると実機でのHot Reloadができない?
umigishiaoi
0
120
Systèmes distribués, pour le meilleur et pour le pire - BreizhCamp 2025 - Conférence
slecache
0
120
今ならAmazon ECSのサービス間通信をどう選ぶか / Selection of ECS Interservice Communication 2025
tkikuc
21
3.9k
Node-RED を(HTTP で)つなげる MCP サーバーを作ってみた
highu
0
120
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
1.2k
ふつうの技術スタックでアート作品を作ってみる
akira888
0
450
Featured
See All Featured
Unsuck your backbone
ammeep
671
58k
Facilitating Awesome Meetings
lara
54
6.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Done Done
chrislema
184
16k
RailsConf 2023
tenderlove
30
1.1k
Statistics for Hackers
jakevdp
799
220k
Embracing the Ebb and Flow
colly
86
4.7k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Site-Speed That Sticks
csswizardry
10
680
Building Applications with DynamoDB
mza
95
6.5k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
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:~$