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]

10 comments:

  1. I think the best language to use is the one you think you'll be most successful with. I can say that there are a lot of testers successfully using Ruby and a large community for support, so it would be my first choice. Watir-WebDriver is a really nice abstraction of the Selenium WebDriver APIs and easy to use (http://watirwebdriver.com/). Watir 4 will include this by default.

    ReplyDelete
  2. I would say the best language to us is the one you can get the most support from. So if the dev team in your company use C# perhaps better to go with that for support and compatibility with the build tools etc.
    If its for personal learning or projects than go with a common language like Ruby or Java.

    ReplyDelete
  3. I'm not sure i understand everything written in here. At one point you're saying that WebDriver (aka Selenium) is so much better than Watir because it supports many browsers and operating systems. But then you're saying that let's deprecate Watir and move on to Watir-WebDriver, which isn't Selenium at all and is just available in Ruby.

    What i'm trying to say in here is that it's not yet possible to move to Watir-WebDriver completely due to it's unstable IE support and that's why i'm using Watir 3 (released just today) for IE and Watir-WebDriver for Firefox/Chrome.

    I'm still most confident that my application works best if the test is passing in IE due to its known problems. If it's passing there, then it's probably passing in other browsers too and not vice-versa.

    Of course i would use Watir-WebDriver instead of Watir, but not yet and deprecating anything before something better is actually available is just a not-so-smart move. Do you guys not agree?

    Also, using something for the sake of its popularity (as you mention about Selenium and employers) is not so good either, because if that would be true then we all would have used QTP and other commercial tools. I'd maybe used them if they were actually any good, but they're not.

    Just don't rush into things which are not ready yet. Yes, all tech-savvy developers who could help out with WebDriver's problems should do that, but let's not spread the word that "Watir is now deprecated" for regular users. That would cause more harm than good. At least that's the way i see it.

    ReplyDelete
    Replies
    1. Watir-Webdriver is most definitely Selenium. It is a Watir API that delegates to Selenium-Webdriver which are the ruby bindings to the Selenium Webdriver core. Jari gave a great presentation at the Test Automation Bazaar in March 2012 (and even fixed a bug live!)

      http://kondoot.com/videos/5f233d36004

      I don't think the IE implementation is unstable. It has some bugs which are being addressed. I'd report any issues you're seeing - that's where we can add a lot of value

      Delete
    2. I meant that it is not pure Selenium since it has a completely different API and is bound to Ruby only, which means that if you're on the job interview and they expect you to know Selenium (as you wrote up there), then knowing Watir-WebDriver does not count or does it?

      Anyway, as i mentioned then the last time i tried IE driver it was about 6 months ago. My friend tried it about 2 months ago, and was forced to switch back to Watir too. I hope it has gotten better :)

      Delete
  4. At the risk of butting where I don't belong and am not welcome, I'd like to know what deficiencies you've found that have made people "forced to switch back to Watir". Yes, there are issues with the IE driver, many of which are well-known and acknowledged, and there are efforts underway to resolve those issues. However, if there are things we don't yet know about, vague pronouncements about the IE driver being "unstable" or "not working well enough for me" are distinctly unhelpful. I would encourage you to reach out to the Selenium team in general, and me in particular, to help us get better.

    ReplyDelete
    Replies
    1. Jim, don't get me wrong - i haven't said anything bad towards you. I also mentioned that i haven't tried IE driver quite awhile now.

      I also know that my statements are not really helpful towards making IE driver better, because i'm also related with more than one open-source projects so i know how these things work, but i still can express my own experiences or the ones from the people i know. I don't know/remember details since it has been quite some time now. I would be really happy if it has gotten better (and it probably has!)

      I have participated in the history by opening bug tickets for selenium-webdriver and i'm pretty sure that some them are still open. I don't have the time to participate that actively right now anymore.

      Most of the IE driver problems appeared also when running watir-webdriver against watirspec with IE driver. What's the state with these specs currently?

      Just tried to run few of my specs against latest watir-webdriver and this is what i'm seeing after few successful specs:
      Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones.

      So, i had few green specs and then started getting this error for all the rest. I didn't change any protected mode settings
      and when i check IE settings then protected mode is switched off for all zones. I can't say anything else about this situation than it is "unstable" and i am "forced to switch back to Watir". Sorry.

      And where did you get that idea from that you're not welcome?

      Keep up the good work and hopefully i can switch to watir-webdriver at some point. I would help with that if i could.

      Delete
    2. Thanks for the response, Jarmo. Please bear in mind that I use neither Watir, nor watir-webdriver, so that's where the feeling that I may not be welcome comes from in discussing those projects. I don't have a proverbial dog in that hunt.

      Also, since I'm not directy involved with either project, any issue reports that may have come into them haven't filtered out to me yet. Seeing your concrete description of a problem is a great start. That's the kind of engagement that I'd love to see on an ongoing basis. There's a vast difference between saying, "it sucks," and, "it sucks because when I used it, it did this behavior exactly wrong." I can try to fix the behavior; I can't fix "sucks."

      Delete
  5. Let me try to explain exactly what watir-webdriver is:

    The first thing to know is that the selenium-webdriver API is radically different than the selenium1.0 API. Se1.0 followed Watir's model of trying to be all things to users. Se2.0 aims to expose only a basic set of building blocks from which users can create their own abstractions, their own DSLs.

    What this means in practice is that selenium-webdriver users (if they are good) end up writing something that looks like some subset of the Watir API anyway.

    What Jari did with watir-webdriver (pretty brilliantly) is to implement the existing Watir API as an abstraction from, a wrapper on top of selenium-webdriver. It is important to note that watir-webdriver actually derives from the standard HTML spec itself *automatically*, so watir-webdriver is *always* the standard implementation, regardless of how the W3C may choose to alter that standard in the future.

    selenium-webdriver is fully implemented and supported for Java, C#, Python, and Ruby. But only Ruby offers a standard high-level API in the form of watir-webdriver, and only Ruby offers a standard implementation of Page Objects. Which is pretty nifty.

    And this leads to projects like Jeff Morgan's page-object gem, a reference implementation of the Page Object design pattern in Ruby. page-object is aware of both watir-webdriver and selenium-webdriver APIs, and can use them interchangeably. page-object also knows how to work with rspec, so it takes advantage of the full Ruby testing "stack".

    ReplyDelete
  6. This post resonates somewhat with my experience, but I think I have a different viewpoint even than Chris, whom I know to have excellent programming and design skills.

    I'm a tester who has some competency at writing code, but is not skilled at OO design/coding. I don't write code on a daily basis. In fact, it's a pretty small part of my job, since the devs on my team automate most of the regression tests. I specify FitNesse test cases, and I automate GUI tests.

    We implemented Watir in 2004 because Canoo WebTest, our GUI tool at the time, was having trouble supporting JS. Since I am not a programmer, I struggled to learn enough Ruby to be able to write maintainable and useful Watir tests. I depended on a teammate who was good at it and wrote most of our tests. In the end, we moved back to Canoo WebTest for our regression testing, because once it was ported to HtmlUnit, it worked better with JS than Watir did at the time. I continue to use our Watir scripts to help with exploratory testing, but nobody else on my team uses them.

    In the last year we realized we need WebDriver because neither WebTest nor Watir works with our Dojo-generated JS. I tried upgrading to the latest Watir with Webdriver. Watir has changed so much, our existing scripts will not work in the latest version. I spent some time trying to upgrade, but it was too big a job for me. People in the Watir community have tried to help, but they usually suggest code changes that I do not know how to do.

    IME, Watir is for programmers. The Watir community is great, but it assumes you are a programmer and can easily do all the things they suggest when you have problems. In the small blocks of time I have to devote to writing automated test code, I cannot accomplish what I want with Ruby and Watir, because my programming skills are not good enough.

    We tried using the Geb framework with Se2/WebDriver, with the devs writing the page objects, but we hated the test result reporting. Now we are trying RobotFramework with its Selenium2Library and so far that looks like it will work better. RobotFramework IS designed with non-programming testers in mind. I feel comfortable using it and feel I can easily learn enough Python to do what I need. (I might turn out to be wrong about that, but so far, so good). The RobotFramework community does not answer my questions with the assumption that I'm a programmer and can write code to fix my issues.

    It's fine for different test drivers and frameworks to have different audiences, but they should be clear what audience they're aiming at, and discourage non-programming testers from using the tool if it is not appropriate for them. That was my biggest beef with Watir.

    ReplyDelete

Creative Commons License
The Science of Testing by Hugh McGowan is licensed under a Creative Commons Attribution 3.0 Unported License.