Talking testing, agility and automation... and anything else.


Selenium-WebDriver vs Sahi

selenium.logoJari Bakken has a couple of nice example tests that show some of the differences between a Selenium-WebDriver test and a Watir-Webdriver test. I thought I would create another example to show how the same code could be written in Sahi.

Both of the following scripts perform the same test. The test itself is simple:

  1. Go to the Google Translate page
  2. Click the Detect Language button
  3. Select Norwegian as your language
  4. Log the button’s text
  5. Enter the word “ost” into the text field
  6. Verify “cheese” is the returned translateion

Selenium-Webdriver Example…

Sahi Example…

The difference is pretty dramatic… at least in test size. Sahi handles all your waits for you so there’s no need to clutter up your tests with wait code. Accessor code is also less verbose in Sahi. Overall, I would argue the Sahi code is much more readable but code beautry, like beauty in general, is in the eye of the beholder. I.E. your millage may vary…

Note: I used an assert instead of just logging the returned translateion… same dif

UPDATE: I’ve also added Geb to the fray!

Plusone Linkedin Facebook Twitter Digg Email

3 comments

  1. Rune Offerdal

    That difference is pretty dramatic. :-)  I have tested Sahi for some weeks now, and I do agree that the code is both more readable and that the handling of waits seems cumbersome in Selenium.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.