Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
260
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
130
Design a REST API you will love to work with
ujovlado
0
770
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
500
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
390
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
150
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
100
CSS Flexbox (WebElement #35)
ujovlado
0
170
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
180
Don't underestimate CSS (WebElement #30)
ujovlado
0
600
Other Decks in Programming
See All in Programming
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
5
18k
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
2
6.3k
AIコーディングエージェント(NotebookLM)
kondai24
0
130
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
270
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
230
分散DBって何者なんだ... Spannerから学ぶRDBとの違い
iwashi623
0
170
TVerのWeb内製化 - 開発スピードと品質を両立させるまでの道のり
techtver
PRO
3
1.4k
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.2k
dnx で実行できるコマンド、作ってみました
tomohisa
0
140
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
210
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
210
Developing static sites with Ruby
okuramasafumi
0
130
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Faster Mobile Websites
deanohume
310
31k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Balancing Empowerment & Direction
lara
5
780
4 Signs Your Business is Dying
shpigford
186
22k
Site-Speed That Sticks
csswizardry
13
990
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Why You Should Never Use an ORM
jnunemaker
PRO
60
9.6k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Making Projects Easy
brettharned
120
6.5k
KATA
mclloyd
PRO
32
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:~$