selenium ui paradigm - ddd north 2

25
SELENIUM UI Testing Paradigm @NathanGloyn nathangloy n Design Code Relea se [email protected]

Upload: nathan-gloyn

Post on 26-Jun-2015

862 views

Category:

Documents


3 download

DESCRIPTION

Slide deck from the presentation at DDD North 2

TRANSCRIPT

Page 2: Selenium ui paradigm - DDD North 2

Agenda

UI testing Why use Selenium? Selenium: Origins Selenium: IDE & Concepts Selenium: WebDriver Selenium: Advanced concepts Summary Questions

Page 3: Selenium ui paradigm - DDD North 2

What is UI testing?

a.k.a System Testing, Functional testing

Use UI to drive the system All parts of system exercised Ensure that UI behaves as expected

Page 4: Selenium ui paradigm - DDD North 2

Testing through the UI

Pros Ensure that system works as a whole Easy regression testing

Cons Expensive Time consuming

Page 5: Selenium ui paradigm - DDD North 2

Why use Selenium

Free Open source Supports Java, Ruby, .Net, Python,

PHP & Perl Portable Combine with other tools

Page 6: Selenium ui paradigm - DDD North 2

Origins

Thoughtworks Jason Huggins Javascript Java + Http Request Simon Stewart WebDriver

Page 7: Selenium ui paradigm - DDD North 2

Origins: Projects

Selenium Core

Remote Control GridIDE

Web driverSelenium 1.0Selenium 2.0

Page 8: Selenium ui paradigm - DDD North 2

Selenium IDE

Firefox addin Record & replay Supports plugins Creates Selenese scripts Can output unit tests in various

languages

Page 9: Selenium ui paradigm - DDD North 2

Selenium IDE

Demo

Page 10: Selenium ui paradigm - DDD North 2

Concepts: Assert vs Verify a.k.a hard or soft assertions Different uses Fail Assert = immediate test failure Fail verify = continue to end of test Use depends on test

Page 11: Selenium ui paradigm - DDD North 2

Concepts: Commands

Actions Click keyDown

Accessors Title Text

Assertions Assert Verify

Page 12: Selenium ui paradigm - DDD North 2

Concepts: Locators

id Name Tag Name Class Name CSS Link Partial link

Xpath

Attribute based

Structure based

Content based

Page 13: Selenium ui paradigm - DDD North 2

Concepts using Selenium IDE

Demo

Page 14: Selenium ui paradigm - DDD North 2

Selenium IDE: Summary

Easy way to get started Able to create suites of tests Very good for quick smoke tests e.g

navigation Test can be exported to different

languages Limited to FireFox Very data sensitive Not usable from a CI server

Page 15: Selenium ui paradigm - DDD North 2

Web Driver

Has native browser specific drivers No server needed Object Oriented API HtmlUnit support Support for Selenium RC

Page 16: Selenium ui paradigm - DDD North 2

WebDriver

Demo

Page 17: Selenium ui paradigm - DDD North 2

Brittle tests

Data dependent Framework & test code combined Incorrect locators

Page 18: Selenium ui paradigm - DDD North 2

Data

Deterministic vs Non-Deterministic

Static vs Dynamic Easier vs Hard

Page 19: Selenium ui paradigm - DDD North 2

Brittle tests

Bad Code

Page 20: Selenium ui paradigm - DDD North 2

Page Object Pattern

Popular design pattern in testing Abstracts a page Encapsulates all operations Helps prevent brittle tests Page Object does not assert or verify

Page 21: Selenium ui paradigm - DDD North 2

Page Object Pattern

Demo

Page 22: Selenium ui paradigm - DDD North 2

Domain Specific Language

Abstraction Specification Not a “proper” DSL Readable Build it piece at a time Investment

Page 23: Selenium ui paradigm - DDD North 2

Domain Specific Language

Demo

Page 24: Selenium ui paradigm - DDD North 2

Summary

Tests the application end to end Very easy to get going with Strategies to avoid brittle tests Free Investment in tests

Page 25: Selenium ui paradigm - DDD North 2

Questions?