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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
530
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
440
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
200
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
150
CSS Flexbox (WebElement #35)
ujovlado
0
200
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
210
Don't underestimate CSS (WebElement #30)
ujovlado
0
650
Other Decks in Programming
See All in Programming
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
510
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
120
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
190
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
250
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
260
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.9k
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
FastAPI の並行処理モデルを完全に理解する
hoto17296
8
2.7k
React本体のコードリーディング
high_g_engineer
1
150
Flow は今どうなっているか
mizdra
PRO
0
670
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
プロポーザルを書いてもらう
pvcresin
0
570
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
430
Code Reviewing Like a Champion
maltzj
528
40k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
470
Six Lessons from altMBA
skipperchong
29
4.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
BBQ
matthewcrist
89
10k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
390
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
240
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
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:~$