Selenium: What I’ve Learned So Far

I’ve been experimenting with Selenium off and on for the past month or so. I thought I’d share some of the things I’ve gleaned from my experience so far.

1. Selenium can only be used to test things that render in a web browser. People are surprised by this, initially assuming that Selenium can be used to automate almost the testing of almost any software. However, think of this “limitation” as a benefit. Instead of being mediocre at testing all types of software, it is excellent for browser-based testing. As time goes on, more and more software is web-based.

2. The Selenium IDE is easy to use, but is limiting. I started out using the IDE but within a day I found myself wanting to use functionality that was only available by writing code. This is made possible by using the Webdriver API. The IDE was a good way to get my feet wet with Selenium basics, but there is so much more that can be done than what the IDE allows. So far I’ve set up a SQL data source and a method that waits for element X to load on the page or waits 10 seconds, whichever comes first, before performing a test. This method solved the “ElementNotFound” exception issues I had at first.

As with many things, learning the code is more daunting than using the GUI, but it’s easier in the long run to know how things work ‘under the hood’. The pain of the initial learning curve is more than made up for by the addition of features and the increased flexibility. Also, I’m happy that I’m getting to brush up on some C# as I work towards my goal of re-visiting programming.

3. Selenium is great for cross-browser testing. I’ve had success in testing in Chrome, Firefox, and Internet Explorer. You can even run the same tests in all three browsers at the same time. There is also support for Opera and HtmlUnit, which I haven’t tried yet. I was happy to discover that Webdriver also supports AndriodDriver and iPhoneDriver for mobile testing – something I hope to do in the future.

4. Most of the Selenium examples I’ve found are in Java. C# examples seem to be few and far between, but I’ve had some luck. Thankfully, the lack of C# examples is starting to matter less and less as I learn to translate Java into C#.

5. Selenium is very well documented. If it wasn’t for this, I probably would have given up long ago. But with a quick search, I can usually find the exact answer I’m looking for. I’ve found both the Google Project Wiki  and the SeleniumHQ Docs invaluable. I’ve also seen a lot of informative examples on various test automation blogs. I’m trying to ‘pay it forward’ by posting here – hopefully someone out there finds my posts valuable as well!

6. There are lots of front-end option for running Selenium tests. The one I’ve seen suggested most often is NUnit. So far I’ve just been running my tests straight from Visual Studio.

There’s still so much to learn and I’ve just scratched the tip of the iceberg within the past month. I will continue using Selenium & WebDriver to automate parts of my testing (not everything I’m testing is browser based). I’ll let you know what other interesting things I find!



So, what do you think ?