Your SlideShare is downloading. ×
Selenium and Selenium on Rails
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Selenium and Selenium on Rails


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Selenium and Selenium on Rails
  • 2. Agenda
    • Overview of Selenium
      • Simple Selenium Tests
      • Selenium IDE
    • Overview of Selenium on Rails
    • Problems with Selenium
  • 3. Selenium Overview
    • Selenium is composed of four things:
      • Selenium Core
      • Selenium IDE
      • Selenium RC
      • Selenium on Rails
  • 4. Overview of Selenium
    • Open source browser based integration test framework built originally by Thoughtworks
    • 100% Javascript and HTML
    • Designed to make test writing easy
    • Ability to run whole suites of tests or individual tests
    • Ability to step through individual tests
    • Cross browser – IE 6/7, Firefox .8+, Opera, Safari 2.0+
    • Lets see an example of a selenium test suite…
  • 5. Overview of Selenium
    • Downloads and Documentation can be found at:
    • Getting started:
      • Download Selenium core off of
      • Place the contents of the zip file on a web server in a selenium-core directory
      • Go to http://web-server-host/selenium-core/index.html
  • 6. Simple Selenium Tests
    • Selenium understands two types of files
      • Tests
      • Test Suites
    • Every test must be contained within a test suite
    • Both tests and test suites are defined by using simple tables in HTML
    • To execute a test suite you must point TestRunner.html at it
  • 7. Format of Selenium Test Suite
    • More complex than Selenium Tests
    • Easiest just to copy TestSuite.html from the samples
    • Mostly a table that points to the tests
  • 8. Format of a Selenium Test
    • HTML Table with 3 columns
      • First Column: Selenium command
      • Second Column: Required first parameter
      • Third Column: Optional second parameter
    • Selenium commands are broken into 3 types:
      • Actions – Command the browser to do something
      • Accessors – Store/retrieve data from selenium variables
      • Asserts – Verify that the browser is in a certain state
  • 9. Format of a Selenium Test
    • Two types of Selenium Parameters
      • Locators – Used to find elements in html trees
      • Pattern Matchers – Used to verify values
    • Lots of locator types. Some examples are: Id based, xpath based, css selector based
    • Pattern matchers are typically exact matches or regular expressions
    • Lots more info at:
    • So lets try to write a simple Selenium test…
  • 10. Gotchas in HTML Selenium Test Writing
    • Selenium is sensitive to the format of the table
    • All selenium command rows must have three columns or they will not be recognized as commands
    • You can only test URL’s that are in the same domain as the selenium core
    • Separation of concerns is hard – Tests become very dependent on the internal structure of the HTML
  • 11. Wow, that was hard!
    • Lesson learned: Never ever write this by hand
    • There are a lot of commands - you can even add your own custom commands into the user-extensions.js
    • Firebug is very useful for developing your accessors
  • 12. Selenium IDE
    • Firefox extension that allows recording and editing of tests
    • Can be download off of
    • Allows easier development of tests
    • Can even output Ruby for it’s Ruby based API
    • Lets see it in action…
  • 13. Selenium IDE
    • Much easier to use
    • Only really works with synchronous requests
    • Only automates commands, assert still must be entered by hand
    • Still requires lots of work to get Selenium to run it as part of a Test Suite
  • 14. Selenium on Rails
    • Plugin for Rails that allows tests to be expressed in Ruby
    • Selenium core files no longer go in public – they are part of the Plugin
    • Supports two kinds of files SEL files and RSEL files
      • SEL files are pipe separated files that look much like Selenium HTML
      • RSEL files talk to a Ruby API that closely mirrors the normal commands – more info at:
  • 15. Selenium on Rails
    • Each test becomes a single RSEL file which contains Ruby calls closely resembling the Selenium Commands
    • RSEL files work much like views in Ruby and can be broken down into partials
    • Selenium on Rails takes over the /selenium/ URL space
    • RSEL files are used to automatically generate Selenium HTML table based tests
    • Selenium on Rails then generates it’s own Test Suite containing all of the tests
  • 16. Selenium on Rails
    • RSEL files can reference fixtures and clear session state on startup
    • RSEL files support partials
    • Test development is much more Rails like -> Edit RSEL file, hit Reload in browser, run updated test
    • Lets see it in action…
  • 17. That was still pretty hard…
    • Selenium on Rails does not initially make WRITING tests any easier
    • Selenium on Rails makes deploying and the development cycle of tests easier
    • Selenium on Rails makes writing tests more natural for RoR developers – it also gives your tests access to the rest of the code you have developed for your application
    • Selenium on Rails should really be seen as a starting point for developing a DSL to test YOUR application
  • 18. Problems with Selenium
    • The Xpath locators are basically worthless because of the poor performance in IE
    • It is not designed to do AJAX type testing
    • waitForElement and waitForCondition are the tools that Selenium provides to deal with AJAX both of which add a lot of complexity to tests
    • Custom Selenium commands added to user-extensions.js are difficult to write – Avoid doing so unless you must
    • Timeouts are unreliable – sometimes tests hang
    • Not all Javascript events are supported
  • 19. ?