Protractor training

18
Protractor.js End to End testing Global Logic

Transcript of Protractor training

Page 1: Protractor training

Protractor.jsEnd to End testing

Global Logic

Page 2: Protractor training

Lets Learn

Bad Experience

BE

Reflection

R

Theoretical Base

TB

Practice

P

Page 3: Protractor training

Fairy Tail about karma

Huge testsNo

Agreements

No Abstractions

“Should”

Copy/Paste

Page 4: Protractor training

How it connects

Tests

Jasmine

ProtractorWeb

DriverJS

Explorer

Mozilla

Firefox

Google

ChromeSelenium

InternetNode.js

Page 5: Protractor training

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

Page 6: Protractor training

Promise

asynchrony

try/catch

map

chaining

Abstraction of asynchrony

Page 7: Protractor training

???By the way, everything is a Promise

Page 8: Protractor training

Why does it look syncronous?

W

C O N T R O LL

F

Page 9: Protractor training

Protractor provides...

2

3

4

5

ElemenFinder1

ElementArrayFinder

Waiters for Angular $http and $timeout

Mock modules

Search by css, xpath, repeater, etc

Page 10: Protractor training

What E2E testing is about?

Page 11: Protractor training

Page Object pattern

2

3

4

5

Hides implementation details1

Maintainable

Reusable

Simplify tests

Extendable

Page 12: Protractor training

Keep in mind

If you have WebDriver APIs in your test

methods, You're Doing It Wrong

© Simon Stewart

Page 13: Protractor training

Page decomposition

Page 14: Protractor training

Page “primitives”

Page 15: Protractor training

Section methods

2

3

4

5

field(name)1

hasErrorOn(fieldName)

ensure(state, expected).otherwise(act)

try(action)

errorFor(fieldName)

Page 16: Protractor training

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

Page 17: Protractor training

What we have learned

Simplicity is prerequisite of reliability

© Edsger Dijkstra

Page 18: Protractor training

Sergii [email protected]

Any questions?

???