Protractor.js
End to End testing
Global Logic
Lets Learn
Bad
Experience
BE
Reflection
R
Theoretical
Base
TB
Practice
P
Fairy Tail about karma
Huge tests
No
Agreements
No
Abstractions
“Should”
Copy/Paste
How it connects
Tests
Jasmine
Protractor
Web
DriverJS
Explorer
Mozilla
Firefox
Google
Chrome
Selenium
InternetNode.js
Node.js
• Blocks execution
• Runs immediately and
return result
• Good for working with data
in memory
Synchronous
• Adds new event in the loop
• Runs after all synchronous
operations are executed.
• Good for heavy operations
like database or filesystem
access
Asynchronous
Promise
asynchrony
try/catch
map
chaining
Abstraction of asynchrony
??
By the way, everything is a Promise
Why does it look syncronous?
W
C O N T R O L
L
F
Protractor provides...
2
3
4
5
ElemenFinder1
ElementArrayFinder
Waiters for Angular $http and $timeout
Mock modules
Search by css, xpath, repeater, etc
What E2E testing is about?
Page Object pattern
2
3
4
5
Hides implementation details1
Maintainable
Reusable
Simplify tests
Extendable
Keep in mind
If you have WebDriver APIs in your test
methods, You're Doing It Wrong
© Simon Stewart
Page decomposition
Page “primitives”
Section methods
2
3
4
5
field(name)1
hasErrorOn(fieldName)
ensure(state, expected).otherwise(act)
try(action)
errorFor(fieldName)
OK, but how to organize code?
test/e2e
├── config
├── lib
│ ├── section
│ │ ├── behavior
│ │ └── field
│ ├── page.js
│ └── section.js
├── features
│ ├── login
│ └── channels
├── shared-specs
│ ├── toolbars
│ └── validators
└── support
└── login.js
What we have learned
Simplicity is prerequisite of reliability
© Edsger Dijkstra
Sergii Stotskyi
sergiy.stotskiy@gmail.com
Any questions?
??

Protractor training

Editor's Notes

  • #3 Do not stuck in BE-R
  • #6 show an example of synchronous and asynchronous (setTimeout)
  • #7 show examples of Promise/A+ show the diff about WebDriverJS promises promises chaining (all, then) error throwing
  • #9 show examples of code with control and without flow.execute custom promise
  • #11 User Interactions. Not implementation!
  • #12 page object is actually a panel object. Doesn’t mean one PO per real page
  • #13 why? Encapsulation! page objects has nothing to do with test libraries. If you use expectations inside your page objects you broke Single responsibility. And add redundant complexity Simon team lead of Selenium team
  • #15 show examples of behaviors: Accordion, Configurable show examples of custom form fields implementations Collection Item create abstraction for all standardized behaviors
  • #16 update tooltipFor
  • #17 show examples of behaviors: Accordion, Configurable show examples of custom form fields implementations Collection Item create abstraction for all standardized behaviors