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
280
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Testovanie web aplikácií s CasperJS (WebElement #11)
Vladimír Kriška
September 06, 2012
More Decks by Vladimír Kriška
See All by Vladimír Kriška
Twelve-Factor app with Docker
ujovlado
0
180
Design a REST API you will love to work with
ujovlado
0
810
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
520
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
430
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
190
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
140
CSS Flexbox (WebElement #35)
ujovlado
0
200
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
200
Don't underestimate CSS (WebElement #30)
ujovlado
0
640
Other Decks in Programming
See All in Programming
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
360
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
200
AIエージェントで 変わるAndroid開発環境
takahirom
1
430
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
240
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
390
Vite+ Unified Toolchain for the Web
naokihaba
0
670
スマートグラスで並列バイブコーディング
hyshu
0
280
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
860
1B+ /day規模のログを管理する技術
broadleaf
0
130
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
0
780
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
220
How STYLIGHT went responsive
nonsquared
100
6.2k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
960
A designer walks into a library…
pauljervisheath
211
24k
エンジニアに許された特別な時間の終わり
watany
107
250k
Six Lessons from altMBA
skipperchong
29
4.3k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
400
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
550
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
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:~$