Talking testing, automation... and anything else.

Geb vs. Sahi vs. Selenium-Webdriver

gebAs an addendum to my original post comparing Selenium and Sahi, I offer the same test written in Geb.

I took a bit of flack for the original article, mainly people complaining that my comparison wasn’t an apples to apples comparison. Their argument was that because they share a more similar architecture, a more fair comparison would be to compare Sahi to Selenium RC. Of course this argument is complete rubbish. My comparison was (and is) merely a look into the raw code of each tool. But even if it wasn’t, Sahi and Selenium both aim to provide the same function: web application automation. Comparing these two tools is completely valid… though I do profess to enjoy the modicum of hyperbole. That all being said, I will paraphrase Mike Watt and say: “if you don’t like it, go out and start your own blog!”

Anyway, I’ll throw Geb’s hat in the same ring with one disclaimer: Geb runs on top of Webdriver… WORLD BEWARE. Please feel free to breath into a paper bag or the something…

Now, without further ado, I give you [gasp] the Google Translate test, written in raw Geb (no developers were hurt during the coding of this test (unless you equate drinking most of a bottle of wine to being “hurt” (which I do not (because I live in Wisconsin)))). Enjoy responsibly!

import geb.Browser {

    $('', text:'Norwegian').click()
    $('textarea#source') << 'ost'

    waitFor {
        $('span#result_box').text() == 'cheese'


Download the working code from GitHub...

Note: this code, like the original Sahi and Selenium code, is "in the raw", as it were. I.e. no page objects or custom methods to help readability/maintainability/*.ility.


  1. Very interesting comparisons :-) You should also try Helium! It’s based on Selenium and available for the same languages. Here’s your example with the Python bindings:

    from helium.api import *
    click(Button(to_right_of="Detect language"))
    assert Text("cheese").exists()

    * Selenium: 812 characters
    * Sahi: 260 characters
    * Helium: 172 characters

  2. I should have added that Helium’s home page is

  3. >>no developers where hurt during the coding of this test<<
    "where" should be "were"

    I realize you're speaking in jest, so I'll let some of the other grammatical errors slide. This time.


  4. How is it is to maintain and reuse Sahi tests/codes?

  5. Stanislav Todorov


    I’m working in a company as a QA and we are using Behat and Selenium,
    i managed to install sahi and replace selenium for browser testing, however i’m not sure how to make use of sahi features to make my behat tests better i know this isn’t the right place but i can’t really find a better one.

Leave a Reply