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 #11)
Search
Vladimír Kriška
September 06, 2012
Programming
0
170
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
38
Design a REST API you will love to work with
ujovlado
0
620
Docker for PHP developers - Tips, Tricks & Lessons learned
ujovlado
3
370
Docker ‐ from development to production in minutes (PoSobota #91)
ujovlado
0
260
Non-traditional use of Docker (Nette Camp #3)
ujovlado
0
66
Contributions [lightning talk] (PyconCZ 2015)
ujovlado
0
39
CSS Flexbox (WebElement #35)
ujovlado
0
97
Simplify your dev life with Docker (WebElement Banská Bystrica)
ujovlado
0
83
Don't underestimate CSS (WebElement #30)
ujovlado
0
510
Other Decks in Programming
See All in Programming
PHPでOfficeファイルを取り扱う! PHP Officeライブラリを プロダクトに組み込んだ話
hirobe1999
0
840
15分間でふんわり理解するDocker @ Matsuriba MAX
ukwhatn
PRO
1
340
上手な探索的テストとその上達方法について
matsu802
4
650
Laravel標準バリデーションでできること
hmb_ok
2
360
GitHub Copilot Tips and Tricks
yuichielectric
26
7.4k
TCAの Shared Stateって どういう仕組みになってんの?
yimajo
0
330
Material 3で Material 2ぽい見た目にする
numeroanddev
2
250
Honoとhtmx
yusukebe
6
1.2k
phpunit/php-code-coverageって何をしてるんだ #phperkaigi
o0h
PRO
2
220
Go1.22からの疑似乱数生成器について/go-122-pseudo-random-generator
convto
1
160
Data Contracts In Practice With Debezium and Apache Flink (Kafka Summit London)
gunnarmorling
2
280
プロンプトエンジニアリング入門
tomokusaba
2
970
Featured
See All Featured
Design by the Numbers
sachag
274
18k
For a Future-Friendly Web
brad_frost
170
8.9k
What's new in Ruby 2.0
geeforr
335
31k
The Invisible Customer
myddelton
114
12k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.8k
Building Your Own Lightsaber
phodgson
97
5.6k
In The Pink: A Labor of Love
frogandcode
137
21k
Ruby is Unlike a Banana
tanoku
95
10k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
How GitHub Uses GitHub to Build GitHub
holman
467
290k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
101
6.6k
The Pragmatic Product Professional
lauravandoore
24
5.7k
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:~$