WatiN Performance Tips

We use WatiN for integration and user acceptance testing (UATs). These tests are the slowest part of our build process. We are obsessed with finding ways to make these test run faster. Here is a list of what we do to make our UATs run as fast as possible.


Use one IE instance

Creating new IE instances is one of the most expensive operations in using WatiN. We use the following in our TestFixtureSetUp.

protected static IE ie;[TestFixtureSetUp]public virtual void TestFixtureSetUp(){    if(ie == null)    {        ie = new IE();        OpenBrowserToHomePage();    }}

Avoid using ie.Element

All Element methods are slow. Always be as specific as possible (even when accessing the body element).Don’t

ie.Element(id).Click();

Do

ie.Link(id).Click();

Avoid driving the web site to the testing point

In the beginning, we started all of our tests at the site entry point. We then clicked links until we made it to the section of the site we wanted to test. This is a very expensive pattern. We realized this and started our tests at the test point.Don’t

OpenBrowserToHomePage();ClickLink("Properties for Sale");  // http://localhost/sales

Do

OpenBrowserTo(region, "sales");  // http://localhost/sales

More tips

Do you have any more tips? I would love to hear about them.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: