Monday, May 21, 2012

Watir and the Pheonix

I'll be the first to admit it. I have a strong emotional attachment to Watir. I've used it almost every day for the last five years. It's had a profound affect on our engineering team and not just in finding bugs. It has made me a better tester. It has made our engineers respect and value what we do. It has helped me grow technically. It has introduced me to open source. It has a community like no other and has led me to meet and work with amazing people.


It's hard to let go, and yet I know that's the right thing to do.


Diminishing Returns

I joined Convio almost 6 years ago. We needed a tool to automate our UI tests and Watir was an excellent fit. It had a real programming language with Ruby,  targeted the browser most used by our clients, and provided a simple yet powerful API. Windows was broadly established in households and IE was king. Over the last several years, however, that landscape has dramatically changed.


Since 2009 Internet Explorer (IE) has been losing market share at the rate of 10% per year and has no sign of slowing up. In March of 2012, IE accounted for roughly 35% of the market with Chrome close behind at 31% and Firefox an even 30%. 

IE is no longer the 800 lb. (364 kilo.) gorilla.  In fact, out of the 85% of people running some flavor of Windows, half of them opted for a different browser, ditching IE. I suspect that over time, we'll see IE sharing the same market percentage that Safari does now... a meager 4.5%1 





The Rise of Mobile


In the US alone, half of the mobile phones are now smart phones with a 38% increase from last year.2 That's a lot of room for growth and these phones are having a profound effect on how the consumer accesses the internet. 

That's not even the whole story. According to Opera3, out of the 7 billion people on this planet, 25% have access to a mobile phone and 1.3 billion people use the mobile internet. 

Five years ago almost no-one had easy access through a mobile device and now all of my friends have one as do many of the generation before me. I can't imagine traveling without one and I almost feel a little naked without my phone. My 2-year-old daughter has no problem taking it and launching Netflix. These devices are now becoming an ubiquitous part of our daily life. 



Changing of the Guard


When you get down to it, we're all working to get a paycheck and keep the lights on at home. For our personal marketability, it's important to know what skills are valuable to employers. 



QTP and Mercury have been bleeding out over the last few years with Selenium taking the market by storm. In 2011, Selenium snuck by Mercury and recently eclipsed QTP. Watir has remained on the radar, but clearly never gained the traction that these other tools have managed.  


My good friend and colleague, Bret Pettichord, thinks that once employers start realizing this trend, jobs requiring these proprietary tools as a core skill will drop like a rock. I'm inclined to agree with him. 


The first message here is the power of open source tools. Being able to have a world-wide community contributing to a codebase is a competitive advantage. These tools are created by the users, for the users and as such are able to meet the needs much better than the shrink-wrap companies that lured in the masses with slick play-and-record tools (though the Selenium's IDE has a familiar smell4). 


The second, speaks to the needs of the tester. Watir can only drive IE with Ruby on Windows. Selenium provides support for multiple languages on all major OS platforms driving browsers including IE, FireFox, Chrome and Opera. There's also work underway to support Safari. Furthermore, you can drive real mobile devices running iOS, Andoid and Opera browsers. 



So Why are we Still Using Watir? 

When I returned home from the Selenium conference in 2011, I was energized. WebDriver was just released and it promised to give me access to more browsers. More precisely, I was interested in Watir-WebDriver, the ruby implementation of WebDriver using the same Watir API (Jari Bakken is solely responsible for what has to be the prettiest Ruby I've ever seen). I got home and tried it and was disappointed. It was slow and didn't provide good solutions for a lot of the features that our legacy application relied on, including modal dialogs.


A lot of difference a year can make. A few months ago I tried again and much to my delight, WebDriver was able to handle most things I threw at it. In fact, it has actually surpassed Watir in functionality. Firefox is clearly the darling and gets the most attention with Chrome a close second. I found Firefox to be the most stable and when using WebDriver, so it has become my primary browser. IE is much slower than the other browsers and isn't as reliable but does work (Jim Evans has done an enormous amount of work to improve this driver over the last year). 


So where I used to use Watir because Selenium wasn't mature enough, it's now becoming clear that it's no longer the case. Is Watir still better at driving IE? Yes, for sure. But is it better to stick to Watir and turn a blind eye to Selenium? Most definitely not. 


A Call to Action

You see, what Selenium needs most is the Watir community. We're the expert users of IE. We can give the feedback they need and make their implementation of IE first-class. If we continue to fall back on the crutch of using Watir, then we'll languish in a browser that is quickly becoming obsolete. It's a mutually beneficial, symbiotic relationship. We can learn from each other and make WebDriver what it needs to be. 


Now is the time to move. We need to redirect the Watir community to migrate from Watir to Watir-WebDriver. The API is very close and there's so much to gain. We have code to make the migration easier and if people switch to using Firefox instead of IE by default, it's an easy transition. IE on WebDriver will get better but it needs our help. 


There are some who want to use Watir for IE and WebDriver for everything else. Honestly, the people who want to do that can do that today and don't need help from the Watir team. (I personally think trying to maintain two completely different codebases adhering to the same API is abject madness...). We shouldn't continue to support the Watir IE driver. We need to deprecate it and get the Selenium and Watir communities working together to make WebDriver better than anything else out there. 


Rising From the Ashes

Driving browsers is no longer the long pole. There's more work to be done, that is certain, but WebDriver  has evolved into an industry standard. Members of the Selenium team are getting traction on making WebDriver a W3C standard and pushing browser developers to provide the browser-specific implementations. Firefox and Chrome have already committed to this future and they're working on Apple and Microsoft to do the same. 


I'm a core developer for Watir and a few weeks ago I renamed Watir to Watir-Classic. Watir is being reborn as a container gem. "By testers, for testers" is the new motto and it's going to start with moving to Watir-WebDriver in Watir 4.0. Down the road, the Watir gem will bundle what we think are the best set of tools to make testers successful. We're moving from driving a browser to developing standard ways to create and maintain a test framework. We're going to teach the Selenium team what we've learned about testing and share with them the community we've been able to develop and nurture. 

It's exciting. 



Update (2012/05/21)

Chrome just passed IE to become the most-used browser according to StatCounter: http://bit.ly/JKpAE5.

1. [w3schools.com]
2. [blog.nielsen.com]
3. [Andreas Tolfsen on Mobile Testing at SeConf 2012]
4. [Bret Pettichord SeConf 2011 Keynote]
Creative Commons License
The Science of Testing by Hugh McGowan is licensed under a Creative Commons Attribution 3.0 Unported License.