Monday, September 24, 2012

Selenium IE Webdriver in Java

Recently at the company I work for, we've been using the Robot Framework and Selenium for automated testing.  We've had great success so far, Firefox and Chrome have been working great.  However, IE was a bit more problematic for us.  The default IE web driver for IE has been very flaky for us.  We've had issue such as xpath expressions failing, random javascript errors and even crashes.  Even when testing on Sauce Labs, we've experienced these issues.  Given that these same tests worked for Chrome and Firefox without issue, naturally we blamed the IE driver.

After we gave up on the standard IE driver, we started researching other solutions for testing IE.  Watir was the first interesting project we looked at.  It looked good, but it was a Ruby project and we don't have much Ruby expertise.  I found a java equivalent called Watij and that showed more promise for us.  Unfortunately, the project is several years old and didn't support 64-bit JVM's.  In addition, Watij is based on a set of proprietary COM API's from a company called teamdev.  This made it difficult to track down issues when the COM calls would fail.  So I started evaluating calling IE COM directly from Java.

I finally settled on COM4j for the bulk of the IE interaction with addtional help from JNA to call some of the win32 API's.  This combination has worked well for us and we were able to get a Java IE WebDriver going.  We've created a googlecode project to host this effort:

So far we've had great success with this driver and one of our projects has 50+ robot tests that are all passing in both IE 8 and IE 9 using this driver.  At this point, most of the driver is implemented, including all the element finder methods and full file upload support. So feel free to give it a try and let us know how it works for you.