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
270
0
Share
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
160
Design a REST API you will love to work with
ujovlado
0
790
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
520
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
410
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
180
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
130
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
630
Other Decks in Programming
See All in Programming
How We Practice Exploratory Testing in Iterative Development( #scrumniigata ) / 反復開発の中で、探索的テストをどう実施しているか
teyamagu
PRO
3
700
【26新卒研修資料】TDD実装演習
dip_tech
PRO
0
170
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
170
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
5
1.4k
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1k
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
220
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
210
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
140
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
490
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.1k
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
750
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.6k
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
170
The Limits of Empathy - UXLibs8
cassininazir
1
320
Prompt Engineering for Job Search
mfonobong
0
290
The browser strikes back
jonoalderson
0
1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
530
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
How to Talk to Developers About Accessibility
jct
2
190
Ethics towards AI in product and experience design
skipperchong
2
270
AI: The stuff that nobody shows you
jnunemaker
PRO
6
630
Typedesign – Prime Four
hannesfritz
42
3k
Test your architecture with Archunit
thirion
1
2.2k
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:~$