Member-only story

Why do I prefer Selenium (Ruby) over Watir?

I develop/maintain raw Selenium WebDriver tests with better efficiency.

Zhimin Zhan
7 min readOct 10, 2022

A week ago, a reader sent me a question “what were your reasons for stopping using Watir in 2010?”

I started real UI test automation with Watir in 2006 (see My Test Automation Journey), and liked it a lot. I even wrote an ebook on Watir. Check out this article for my successful test automation in Watir that enabled real DevOps back in 2009 (when the term not existed yet). I still don’t mind using Watir now if necessary.

Since the release of Selenium 2, (a.k.a, Selenium WebDriver) in 2011, I have been using Watir and raw Selenium at the same time (Watir for Project 1, Selenium for Project 2). Gradually, I found myself using less and less Watir. I like Selenium WebDriver, the raw Selenium WebDriver better: more intuitive and consistent syntax, faster, more reliable, better supported, and easier to learn.

Table of Contents:
1. Raw selenium syntax is actually more natural.
2. Watir became a syntax layer on top of Selenium, anyway
3. Watir shows signs of fading
4. I implemented ‘Attaching existing Window’, the only missing feature in the original Watir, in TestWise
5. It is easier to convince a project to adopt Selenium than Watir.

1. Raw selenium syntax is actually more natural.

When I write a test step for the element, the syntax is more consistent with Selenium. For example, I copied the element ID or name (by inspection in Chrome).

driver.find_element(:name, "user_name")...

Here all I needed to focus on was to paste the Name attribute. In Watir, I had to remember the tag name too, such as browser.text(:name, ...) and brower.button(...) (the standard syntax based on the Watir doc).

I know that I could use browser.element(:name, ...) . But it would be two syntaxes for the same statement which is “not recommended” .

while this works: browser.element(tag_name: 'div')
it is highly recommended to leverage this locator by using the element's associated method: browser.div
” — Watir Doc

I prefer there is only one consistant syntax, like raw Selenium WebDriver.

Zhimin Zhan
Zhimin Zhan

Written by Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.

No responses yet

Write a response