Selenium 2
 Jason Huggins
Co-creator, The Selenium Project
Co-founder, CTO, Sauce Labs Inc
         twitter: @hugs
  email: hugs@saucelabs.com
Heckle me on Twitter:

@hugs
Agenda

•   Numbers

•   Selenium 1

•   Selenium 2

•   How to avoid Selenium poisoning

•   The Future of Testing - Part 1

•   The Future of Testing - Part 2
How do you measure
  market share?
3300
2969
#1!
51%
Percent of Fortune 150 with
    Selenium experience

       Source:
Past the Tipping Point

   Bran
        d   X

                Sele
                    nium
What is Selenium?



  =       +
The Problem
Selenium IDE for Firefox
!"#$%"&'$(%)$*




                                        16
                 +%%,-..///01*234)03$#.,+$%$5.23"6$(".789:;8<=:
Selenium Remote Control


                            Selenium RC Server
 Python, Ruby,
                                                               Your Awesome
Java, C#, or Perl    HTTP                        HTTP   HTTP
                                                                 Web App
   Test Script
Example Selenium RC Test - Java
Example Selenium RC Test - C#
!"#$
Selenium Grid




                %&&'())***+,-#./"+.01)'%0&02)$345)678
Servers




          Time


          Unit of Work
Servers




          Time


          Unit of Work
Sauce Labs
Selenium 2:
 Why and What
Builder (new!)
The Pareto Principle
AKA (“The Pacman Problem”)


          Selenium 1



                       Selenium 2
Solving the last 20%
• Native keyboard & mouse events
• Same Origin Policy / XSS / HTTP(S)
• Pop-ups, dialogs
  – Basic Authentication
  – Self-signed certi cates
  – File upload/download
Mobile
Types of Mobile Testing

•   Emulator
•   Real device (tethered to workstation)
•   Real device in a real location on a real
    network
Native vs Web
Life before the Web




Total Application Market
Yesterday



              JS+HTML




Total Application Market
Today



              JS+HTML5




Total Application Market
Today
                            Selenium
                           lives here!

              JS+HTML5




Total Application Market
Today
                            Selenium
                           lives here!

              JS+HTML5




Total Application Market
Tomorrow
                            Selenium
                           lives here!




      JS+HTML5




Total Application Market
But, wait!
Tomorrow
                            Selenium
                           lives here!




      JS+HTML5


                           Selenium lives
                             here, too!



Total Application Market
code.google.com/p/nativedriver
“NativeDriver is an implementation of the
WebDriver API which drives of the UI of a
  native application rather than a web
               application.”
Native app testing!
•   Android - Usable!

•   iOS - Usable!

•   Windows - Experimental!
Cleaner API
• WebDriver Object




• WebElement Objects
Other Bene ts
• Improved architecture
• Removing road-blocks, hacks, and workarounds
• Scales down (more developer friendly) experience
Selenium Remote Control


                            Selenium RC Server
 Python, Ruby,
                                                               Your Awesome
Java, C#, or Perl    HTTP                        HTTP   HTTP
                                                                 Web App
   Test Script
Selenium 2


                           Selenium RC Server
 Python, Ruby,
                                                              Your Awesome
Java, C#, or Perl   HTTP                        HTTP   HTTP
                                                                Web App
   Test Script
Python, Ruby,
                                  Your Awesome
Java, C#, or Perl   HTTP   HTTP
                                    Web App
   Test Script
Python, Ruby,
                                   Your Awesome
Java, C#, or Perl   C/C++   HTTP
                                     Web App
   Test Script
Running a server is now optional!


                           Selenium Grid
 Python, Ruby,
                                                         Your Awesome
Java, C#, or Perl   HTTP                   HTTP   HTTP
                                                           Web App
   Test Script
Demo!
How to Avoid
Selenium Poisoning
Intent   Action
Action

•   open 'www.example.com'

•   clickAndWait 'link=Log in'

•   type 'User Id', 'hugs@saucelabs.com'

•   type 'password', '12345678'

•   clickAndWait 'Log In'
Intent

• Log in
• Change password
• Modify profile
• Log out
1. Write intent.
2. Map to actions.
Seek higher level
  abstractions
Jenkins

Ant/NAnt

 xUnit

Selenium
Jenkins

      Ant/NAnt

        xUnit

Business Specific Library

       Selenium
Page Object Model
Search: “Selenium Page Objects”
Start small
It’ll get big anyway
Problems with
    Testing
  (UI)
Brittle!
Expensive!
How to Think about
     Testing
Risk




       Time
How to Think about
  Testing (Part 2)
“The prime goal of the new
    economy is to undo --
    company by company,
     industry by industry
 -- the industrial economy.”
“ADD”
“ADD”
Analytics Driven Development
Science Fiction?
analytics.blogspot.com/2011/10/introducing-flow-visualization.html
Visitor Flow
Use production
 analytics to measure
(or create!) your test
         suite
One more thing...
Robots!
bitbeam.org
BitbeamBot
The Selenium-Powered Angry-Birds
 Playing Functional Testing Robot
What?
• A computer-controlled (CNC) robot for
  testing applications on mobile devices
• Open Source components:
  - Electronics: Arduino
  - Mechanics: Bitbeam
        - Lego Technic compatible building toy
        - Made from Basswood
        - Designed with 3D tool OpenSCAD
        - Lasercut at TechShop San Francisco
  -   Software: Python, Selenium
Why?
• Selenium is a software-based robot.
• Selenium’s mission is to mimic and
  automate how users interact with an
  application.
• For mobile, this means handling real
  devices.
• BitbeamBot is an experiment to take
  Selenium out of the screen and into the
  real world.
No really, why?
The “Clicker”
Motorized Pin Art
pinthing.com
Links
For More Information:
✓http://saucelabs.com
✓http://seleniumhq.org
✓http://code.google.com/p/selenium
✓http://code.google.com/p/se-builder/
✓https://addons.mozilla.org/en-US/ refox/addon/se-builder
✓http://code.google.com/p/nativedriver
✓http://twitter.com/hugs
✓http://bitbeam.org
✓http://pinthing.com
✓http://analytics.blogspot.com/2011/10/introducing- ow-visualization.html
Demo:
✓Android: http://www.youtube.com/watch?v=IUUcEIfkOEY
✓Bitbeambot #1: http://www.youtube.com/watch?v=NoOdrf0kt9I
✓Bitbeambot #2: http://www.youtube.com/watch?v=x2e73HraePY
Android Demo Code:
✓http://gist.github.com/830011
Thanks!
 Jason Huggins
Co-creator, The Selenium Project
Co-founder, CTO, Sauce Labs Inc
         twitter: @hugs
  email: hugs@saucelabs.com

Selenium at STPCon - Dallas 2011