UI Testing Paradigm

  SELENIUM
nathangloyn
@NathanGloyn
Design Code Release
nathans.dropbox@gmail.com
Agenda

 UI testing
 Why use Selenium?
 Selenium: Origins
 Selenium: IDE & Concepts
 Selenium: WebDriver
 Selenium: Advanced concepts
 Summary
 Questions
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
Testing through the UI

 Pros
   Ensure that system works as a whole
   Easy regression testing


 Cons
   Expensive
   Time consuming
Why use Selenium

 Free
 Open source
 Supports Java, Ruby, .Net, Python, PHP & Perl
 Portable
 Combine with other tools
Origins

 Thoughtworks
 Jason Huggins
 Javascript
 Java + Http Request
 Simon Stewart
 WebDriver
Origins: Projects

Selenium 2.0
         1.0
                       Web driver
                       Selenium Core




Remote Control   IDE      Grid
Selenium IDE

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


Demo
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
Concepts: Commands

 Actions
   Click
   keyDown
 Accessors
   Title
   Text
 Assertions
   Assert
   Verify
Concepts: Locators

 id
 Name
 Tag Name       Attribute based
 Class Name
 CSS
 Link
                 Content based
 Partial link
 Xpath          Structure based
Concepts using Selenium IDE


Demo
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
Web Driver

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


Demo
Brittle tests

 Data dependent
 Framework & test code combined
 Incorrect locators
Data

 Deterministic vs Non-Deterministic
 Static vs Dynamic
 Easier vs Hard
Brittle tests


Bad Code
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 Object Pattern


Demo
Domain Specific Language

 Abstraction
 Specification
 Not a “proper” DSL
 Readable
 Build it piece at a time
 Investment
Domain Specific Language


Demo
Summary

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

Selenium ui paradigm - DDD North 2

Editor's Notes

  • #7 JavaScriptTestRunnerMost probably the first open source UI testing tool