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
230
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
78
Design a REST API you will love to work with
ujovlado
0
720
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
450
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
350
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
100
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
62
CSS Flexbox (WebElement #35)
ujovlado
0
130
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
140
Don't underestimate CSS (WebElement #30)
ujovlado
0
550
Other Decks in Programming
See All in Programming
ML.NETで始める機械学習
ymd65536
0
250
Lambdaの監視、できてますか?Datadogを用いてLambdaを見守ろう
nealle
2
840
Devin入門 〜月500ドルから始まるAIチームメイトとの開発生活〜 / Introduction Devin 〜Development With AI Teammates〜
rkaga
3
1.4k
Duke on CRaC with Jakarta EE
ivargrimstad
0
350
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
310
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
430
AWS Step Functions は CDK で書こう!
konokenj
5
930
自力でTTSモデルを作った話
zgock999
0
130
AIプログラミング雑キャッチアップ
yuheinakasaka
21
5.4k
Jasprが凄い話
hyshu
0
200
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.3k
変化の激しい時代における、こだわりのないエンジニアの強さ
satoshi256kbyte
1
820
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.3k
Into the Great Unknown - MozCon
thekraken
35
1.7k
Become a Pro
speakerdeck
PRO
26
5.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
What's in a price? How to price your products and services
michaelherold
244
12k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Code Reviewing Like a Champion
maltzj
521
39k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Raft: Consensus for Rubyists
vanstee
137
6.8k
How to train your dragon (web standard)
notwaldorf
91
5.9k
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:~$