DevOps Zone is brought to you in partnership with:

C# ASP.NET developer who works with MVC but is sometimes known to dabble with WebForms. Passionate coder who cares about his craft. Has a real want to create clean, readable and maintainable code. Obsessed with CI and its effects on a good development team. Pushing the bounds of continuous delivery and studying the advantages it brings to developers. Paul is a DZone MVB and is not an employee of DZone and has posted 25 posts at DZone. You can read more from them at their website. View Full User Profile

Automated UI Testing - Part 1 - WatiN

  • submit to reddit

A few months back I discovered a tool called WatiN. This is based on WatiR and is a web application testing tool for Dot Net developers. After doing a few little test applications i started to see the benefit of using this application in my development. The best thing i could see it could do for me was making sure my pre testing cycle smoke checks were all run and passing. This would save time in fixing little UI bugs spotted by QA testers.

For those who don't know what WatiN does then look at the following code:

public void SearchForWatiNOnGoofle()
    using(IE browser = new IE(""))

Within the class add a reference to WatiN.Core.dll and Nutit.framework.dll and then run this little test app. What will happen is a new instance of IE will spin up [other browsers can be run if necessary using further references]. It will search teh page for the textbox with the name 'q' and enter the text 'WatiN'. It will then find the button called 'btnG' and click it.

This will then give us the results and it checks to make sure that the results include the term 'WatiN'. Pretty easy  to follow eh?

I could really see the potential of how this could be used to see how a site behaves when certain things are done e.g. logging in as a user and making sure that user has the correct options available to them etc.

This was my first forage into the world of what i now know as BDD (behavioural driven development) and automated UI testing.

Published at DZone with permission of Paul Stack, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Daniel Blendea replied on Wed, 2011/07/27 - 8:13am

This is *OLD* news and very beginner stuff.. Could someone at dzone, please, make a categorization: beginnner, medium, advanced stuff?

Morten Brun replied on Wed, 2011/07/27 - 7:22pm

Thank you very much for this great article. I think it is great to see articles like this which are not for the very experienced audience, but for newbies like me. Looking forward to part 2.

Paul Stack replied on Wed, 2011/08/03 - 2:56pm

Really sorry - not sure how this got posted to the site - it was first posted to my site in Feb 2010

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.