SlideShare a Scribd company logo
FAILING GRACEFULLY
with Selenium and T.D.D.
FAILURE
IT’S A WAY OF LIFE
OBVIOUS
FAILURE
PREDICTABLE
SURPRISE
GRACEFUL
HOW TO COPE?
DENY IT
JUST BE VAGUE
GO ON THE OFFENSIVE
STALL FOR TIME
Better strategies? maybe just ....



CLEARER INSTRUCTIONS!
Graceful Failure with Selenium and Continuous Integration
FAILURE IS NATURAL.
Good, even.
Good, even.



               (fail)


              (win)
AS PROGRAMMERS
  we fail all the time.
Graceful Failure with Selenium and Continuous Integration
The only way to fail less is to


ANTICIPATE FAILURE
The only way to fail less is to


ANTICIPATE FAILURE
            and then

DON’T MAKE THE SAME
  MISTAKE AGAIN
        :)
THINGS HAPPEN.
BUT THEN ...
AND THEN ...
AND, WELL ...
Graceful Failure with Selenium and Continuous Integration
TESTING CAN HELP.
HUMAN Q.A. TESTING
                     is the ideal.

(Too bad humans are so much better at other things and
          need to eat and sleep and stuff ... )
SELENIUM IS

A tool for helping to automate testing.
ACTUALLY...
There are many kinds of
   automated tests




                          http://www.flickr.com/photos/60648084@N00/1360619915/
UNIT TESTS
* For individual functions
* The cutest test.




                         http://www.flickr.com/photos/donsolo/2900765675/in/set-72157594163175020/
INTEGRATION TESTS
* For groups of related
functionality

* More relevant and
(almost) fun to write




                          http://www.flickr.com/photos/donsolo/399501571/in/set-72157594163175020/
ACCEPTANCE TESTS
    * Highest level
    testing.

    * Basically user
    stories.

    * “Accepted” as in
    “get fired if they
    don’t work”

http://www.flickr.com/photos/donsolo
don’t get confused:


REGRESSION TESTING

(Is part of all of these, not another style)
So, let’s back up a sec.
      Let me tell you a story about ...




UNIT TESTING IN RUBY
           http://www.flickr.com/photos/21734563@N04/2198268918/
Graceful Failure with Selenium and Continuous Integration
ASSERT
Graceful Failure with Selenium and Continuous Integration
Graceful Failure with Selenium and Continuous Integration
svn ci -m “math library passes
         unit tests!!”
Integration testing is super cool
You can really smell the relevance.




             (seriously)
HOORAY FOR USER STORIES!




      Strive to pass good user-centered tests.


             http://www.lukeredpath.co.uk/blog/developing-a-rails-model-using-bdd-and-rspec-part-1.html
B.D.D. = BEHAVIOR DRIVEN
      DEVELOPMENT




         in rspec
(which uh, actually runs)
WAIT: IT’S IMPORTANT HOW YOU DO IT!!
http://atlalt.net/screwturn/MTG-2008-07-23%20Pub%20Night.ashx
http://blog.briandicroce.com/2008/03/14/three-index-cards-to-easily-remember-the-essence-of-test-driven-development/
RIGHT.
 SO, ANYWAY ...
  BACK TO THIS
SELENIUM THING
SELENIUM IS INCREDIBLY...
WEIRD
why:
It’s a Firefox plugin for testing.
Turns your actions into test code.
Let’s you edit test code in the browser.
Let’s you export to lots of languages.
FUN
why:
It’s a Firefox plugin for testing.
Turns your actions into test code.
Let’s you edit test code in the browser.
Let’s you export to lots of languages.
POWERFUL
why:
It’s a Firefox plugin for testing.
Turns your actions into test code.
Let’s you edit test code in the browser.
Let’s you export to lots of languages.
FIRE-FOXY AND SIMPLE




  Start here: http://seleniumhq.org/
(then go here)



HTTP://SELENIUMHQ.ORG/DOCS/
no forget about that

LETS JUST WRITE A TEST
       ALREADY!
Now: Record and Playback

•   Intelligent field selection will use IDs, names, or
    XPath as needed

•   Autocomplete for all common Selenium
    commands

•   Walk through tests

•   Debug and set breakpoints

•   Save tests as HTML, Ruby scripts, or any other
    format




                    Totally takes 5 seconds, man
Watch this video:
GO RED
(WRITE MORE CODE)
THEN GO GREEN
SPEAK SELENESE

open
       opens a page using a URL.

click/clickAndWait
    performs a click operation, and
optionally waits for a new page to
load.

verifyTitle/assertTitle
    verifies an expected page title.

verifyTextPresent
    verifies expected text is
somewhere on the page.
VERIFY PAGE ELEMENTS
                      is ...

1. an element is present somewhere on the page?
     2. specific text is somewhere on the page?
3. specific text is at a specific location on the page?
GOTCHAS

• clickAndWait         is usually
  required

• type    usually requires you
  to click somewhere else first

• it’s   slow

• brittle    if the UI is changing
  rapidly
HARD PART’S JUST FINDING IT
            Good thing you have so many options ...

• find    elements by name

• find    them by id if they have it

• or   with CSS selectors if you understand the cascade

• Xpath     is like a buzzsaw (a little more expensive)

• link   text as a last resort (since it changes often)
Now,

SELENIUM IDE
 is not the same as


SELENIUM RC
IDE and RC play great together!
RC                 Remote Control, that is.


• Runtests in multiple
 browsers.

• Runthem remotely (on a
 dedicated server)

• Runthem whenever you
 check in code!
exported test to c#
exported test in java
exported test to ruby
Selenium-RC leverages the full power of
programming languages, creating tests that
can do things like


• read   and write external files,

• make   queries to a database,

• send   emails with test reports

• practically
           anything else a user can do
 with a normal application ...
RC can where IDE can’t
•   condition statements
•   iteration
•   logging and reporting of test results
•   error handling, particularly unexpected errors
•   database testing
•   test case grouping
•   re-execution of failed tests
•   test case dependency
•   capture screenshots on test failures
WAIT, WHAT ABOUT TEST-
DRIVEN DEVELOPMENT?
  If you click around the app to build a test,
 that can’t be testing before development.
RIGHT.
You actually should write them beforehand, by hand, just like
            you would unit tests. It’s not so scary.

   • NUnit     for C#

   • Junit   for Java

   • Selenium     gem for Ruby
PUT IT ALL TOGETHER
Put it on your SVN server
trigger it with SVN hooks
Continuous Integration
with Selenium and Criuse Control
WHAT IT MEANS

• Run    your unit tests first locally (because they’re fast).
• Checking  in your changes triggers the continuous
  integration server running your Selenium tests (slow
  because they are in the browser).
• Cruise   Control gives you a web-based heads up when you
  fail or pass tests.
• Joy.
THANKS!

             :)
           Chris Blow
    http://unthinkingly.com
User Experience @ Meedan.net

More Related Content

PDF
Building testable chrome extensions
PDF
Front-end Automated Testing
PDF
PhpStorm for WordPress
PDF
Real Developer Tools for WordPress by Stefan Didak
PDF
Test your Javascript! v1.1
PDF
Real World Selenium Testing
PPTX
Web testing with Selenium
ODP
Selenium testing IDE 101
Building testable chrome extensions
Front-end Automated Testing
PhpStorm for WordPress
Real Developer Tools for WordPress by Stefan Didak
Test your Javascript! v1.1
Real World Selenium Testing
Web testing with Selenium
Selenium testing IDE 101

What's hot (20)

PPTX
Browser Automated Testing Frameworks - Nightwatch.js
PDF
Selenium 101
PDF
Selenium IDE and Beyond
PDF
Javascript testing should be awesome
PDF
Making cross browser tests beautiful
PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
PPTX
TiConnect: Memory Management in Titanium apps
PPT
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
PDF
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
PPT
Scryent: Plone - Hone Your Test Fu
PDF
Webdriver.io
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
KEY
Titanium appcelerator best practices
ODP
Extjs Howto
PDF
UI Testing Best Practices - An Expected Journey
PPT
Selenium
PDF
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
PDF
Introduction to Selenium IDE
PPTX
VorlonJS
PDF
How to become a Joomla! Tester
Browser Automated Testing Frameworks - Nightwatch.js
Selenium 101
Selenium IDE and Beyond
Javascript testing should be awesome
Making cross browser tests beautiful
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
TiConnect: Memory Management in Titanium apps
Automating Software Releases (Dallas/Ft. Worth Perl Mongers 2004)
Mobile Web Test Automation: to the Desktop! - Alexander Bayandin - Mobile Tes...
Scryent: Plone - Hone Your Test Fu
Webdriver.io
Better End-to-End Testing with Page Objects Model using Protractor
Titanium appcelerator best practices
Extjs Howto
UI Testing Best Practices - An Expected Journey
Selenium
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Introduction to Selenium IDE
VorlonJS
How to become a Joomla! Tester
Ad

Viewers also liked (6)

KEY
Crisis and Interaction Design
PPTX
Grassroots Information Management
PDF
Week13
ODP
Week13
PDF
Week13
ODP
Week13
Crisis and Interaction Design
Grassroots Information Management
Week13
Week13
Week13
Week13
Ad

Similar to Graceful Failure with Selenium and Continuous Integration (20)

PPTX
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
PDF
full-stack-webapp-testing-with-selenium-and-rails.pdf
PPTX
Selenium WebDriver - Test automation for web applications
PDF
How To Use Selenium Successfully (Java Edition)
PPTX
Selenium ui paradigm - DDD North 2
PPT
Selenium Concepts
PDF
How To Use Selenium Successfully (Java Edition)
PPTX
Selenium Automation
ODP
PDF
How To Use Selenium Successfully
PDF
Selenium RC: Automated Testing of Modern Web Applications
PPT
BCS Selenium Workshop
PDF
Web Application Testing with Selenium
PDF
Selenium - The Way Of Success
PPTX
Automated testing with Drupal
PPTX
Web Testing
DOC
PPTX
Selenium
PPT
Selenium
PPT
Selenium Introduction
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
full-stack-webapp-testing-with-selenium-and-rails.pdf
Selenium WebDriver - Test automation for web applications
How To Use Selenium Successfully (Java Edition)
Selenium ui paradigm - DDD North 2
Selenium Concepts
How To Use Selenium Successfully (Java Edition)
Selenium Automation
How To Use Selenium Successfully
Selenium RC: Automated Testing of Modern Web Applications
BCS Selenium Workshop
Web Application Testing with Selenium
Selenium - The Way Of Success
Automated testing with Drupal
Web Testing
Selenium
Selenium
Selenium Introduction

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced IT Governance
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Modernizing your data center with Dell and AMD
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced IT Governance
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Modernizing your data center with Dell and AMD
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Spectral efficient network and resource selection model in 5G networks
Transforming Manufacturing operations through Intelligent Integrations
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Dropbox Q2 2025 Financial Results & Investor Presentation
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf

Graceful Failure with Selenium and Continuous Integration