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
Insights on Protractor testing
Search
Deyan Totev
September 13, 2015
Programming
0
93
Insights on Protractor testing
Learn some basic recommendations about the e2e testing framework - Protractor
Deyan Totev
September 13, 2015
Tweet
Share
More Decks by Deyan Totev
See All by Deyan Totev
Welcome to NPM Search 2.0
peeping4dsun
0
51
Other Decks in Programming
See All in Programming
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
720
エラーって何種類あるの?
kajitack
5
330
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
460
LINEヤフー データグループ紹介
lycorp_recruit_jp
0
1.7k
アンドパッドの Go 勉強会「 gopher 会」とその内容の紹介
andpad
0
290
童醫院敏捷轉型的實踐經驗
cclai999
0
210
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
260
PipeCDのプラグイン化で目指すところ
warashi
1
240
Systèmes distribués, pour le meilleur et pour le pire - BreizhCamp 2025 - Conférence
slecache
0
120
GoのGenericsによるslice操作との付き合い方
syumai
3
710
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
220
Featured
See All Featured
Speed Design
sergeychernyshev
32
1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
How GitHub (no longer) Works
holman
314
140k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
Facilitating Awesome Meetings
lara
54
6.4k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Writing Fast Ruby
sferik
628
62k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Transcript
by Dejan Toteff How to build faster e2e tests with
Protractor
• E2E testing framework • Developed by Google • Created
especially for Angular applications • Can be used with non Angular sites as well What is Protractor?
None
• Continuous integration • Integration tests • Test Driven Development
Why we need E2E tests?
• They are slow to write • Debugging is not
a straightforward process • Short life cycle without update What are the main issues with writing e2e tests?
• Well-documented • Integrated with headless and regular browsers •
Easy to set up • Very powerful API What are the pros of Protractor?
• It is not build for complex user interactions •
Works at its best only with Chrome • It doesn’t work well with nested promises What are the cons of Protractor?
Time for some example code
• Make a habit to use element.all(by...). count() to be
sure that you create most suitable element selector. Protractor tips
• Expect false errors. To confirm an error, run the
tests under alternative OS Protractor tips
• Beware of the async nature of Protractor. • If
something doesn't work as expected go Protractor native, i.e. using .then() Protractor tips
• Don't abstract the code directly to the PageObject. Often
this abstraction lead to errors. Protractor tips
• Other possible issue is when the element is not
in the visible part of the browser’s screen. Protractor tips
• Avoid use of browser.sleep() right after browser.waitForAngular() Protractor tips
• If you stumble on an error, that the element
you are clicking on is not attached to the document, that means that this is not a testable scenario Protractor tips
• Once you set the browser size, it persist in
your tests until the next browser. setSize() declaration Protractor tips
• Popups and animation can temporary disable Protractor. Protractor tips
• The behaviour of .then() method of Protractor’s .map(), .each(),
.filter() can be weird. Protractor tips
• One falsy selection can ruin all the tests. Protractor
is hard to debug mainly because in such occasions Protractor tips
• To make scroll down work, first you need to
focus the to the "window" by clicking on any element within the window. Protractor tips
• Make all your clicks statement either inside the tests,
or in the PageObject. Protractor tips
• https://github.com/lkrnac/primediser/tree/blog-2014-04-05- measuring-code-coverage-by-protractor • https://github.com/bennyhat/protractor-istanbul-plugin • http://lkrnac.net/blog/2014/04/measuring-code-coverage-by- protractor/ Walk the
extra mile
https://github. com/selfrefactor/Protractor-testing- patterns Shortlink: j.mp/endToEnd Most of slides of this
presentation are based on:
Thank you for your attention Protractor testing is actually easy