Selenium 2 – Differences to Version 1

Selenium 2 is out for a month now. As I had to introduce Selenium into a project, I picked the new version of Selenium (2.2). I’d like to show some of the differences between Selenium 1 and 2 that I experienced.

Selenium 1

  • supports real browsers only – no HtmlUnit support, needs a graphical desktop environment (slower but more realistic compared to HtmlUnit)
  • JavaScript based approach
  • when used in unit tests, you need a proxy application to control the browser (Selenium-RC)
  • limited by the browser’s Javascript security model
  • complex API, API has evolved over time (dictionary-based approach)
  • API methods for specific HTML elements – e.g. checking checkboxes, selecting radio buttons, selecting elements from dropdown menus etc.

Selenium 2

  • Selenium 2 has been created from Selenium 1 and the Webdriver project
  • backwards compatible to Selenium 1
  • Webdriver API
    • simple, object oriented API
    • supports real browsers and headless HTMLUnit (HTMLUnit should be faster than testing with a real browser)
    • uses most appropriate mechanism to control the browser (IE: automation controls, Firefox: Extension, Chrome: Webdriver API)
    • not limited by browser’s Javascript security model
    • more realistic simulation of the user’s actions by using OS level events (typing, mouse, …)
    • no API methods for specific HTML elements (e.g. checking checkboxes etc.) – you use click and type commands only (this could be a disadvantage)
    • you can no longer manipulate non-visible fields (e.g. hidden fields) (this could be a disadvantage)
    • methods to wait for elements to appear – very useful for testing ajax applications
  • you do no longer need selenium-rc (proxy to control the browser) in your unit tests. Webdriver is able to control the browser directly
  • Selenium-RC and Selenium-Grid from Selenium 1 have been merged into Selenium Server
  • supports all major desktop browsers (IE, Firefox, Opera, Webkit, Chrome), mobile browsers (IPhone, Android) and headless HtmlUnit

The newest version of the test recorder tool Selenium IDE already supports Selenium 2.

From my point of view, the improved ajax testing functionality, the direct browser control without proxy and the improved API make the upgrade worthwhile.

Short URL for this post: http://blog.oio.de/3td6k
This entry was posted in Java and Quality and tagged , , . Bookmark the permalink.

Leave a Reply