Installing WatiN into Visual Studio 2010

October 14th, 2010    •   by Frank    •   9 Comments »

This install was performed on a Windows 7 Professional computer running the 64 bit operating system – so you may not have all the issues, but I’ll point out what I did find to help you along.

For the latest version of Visual Basic to work with the WatiN library, there needs to be some things done. Unfortunately, most of the info on the web is in c# and to be honest, I know next to nothing about C#.

I was fortunate enough though to get a hold of the author of WatiN, Jeroen van Menen. He has taking some of his time to teach me the details behind WatiN. To start, this library of functions is based upon the other open source project called Watir, which is written in Ruby.

Upon talking with Jeroen, he had told me that he wanted the power of Watir available to Visual Studio as it was such a nature improvement upon the current web automation tools available within VS.

So, what I’m going to show you is the currently recommended method to install WatiN in your project, right from Jeroen. You find a video here and full instructions below.

1. Installing the needed WatiN dll files.

This is pretty easy and makes sense. Create a new project within Visual Studio and save it before beginning. This will create a set of files and folders for the project. Within the project structure, create a ‘lib’ folder that will store your outside library of files (including WatiN).
clip_image002

2. Next, you will want to download the latest version of WatiN, which is into version 2.x. When you read this, it could be well beyond that, but again, download the latest. From that download, in the folder, ‘Bin’, you’ll find the following files that I’ve put around a box in the above picture. These files need to be copied to your ‘lib’ folder.

3. Next, you need to ensure that they can be used. This is a simple matter of right-clicking on the copied files and select, ‘Properties’. In the General folder of the properties box for the file, you need to select the ‘Unblock’ button to allow Visual Basic to properly use the file.
clip_image004

4. You will need to perform this action with all the WatiN files. If you don’t consider your hair to be forfeit as you’ll pull it out because things just won’t work right.

5. Next you need to tell your project about these new files. To do this, you need to add a reference to these files. To do this, you simply need to follow the clicks in the picture below.
clip_image006

6. Click on the Browse folder and select the WatiN.Core.dll file ONLY and click OK.
clip_image008

7. Next, we will need to ensure that WatiN is using the correct System.Web library that is a part of Visual Studio. This may not be an issue if you are running a Windows 32 bit operating system, but if you are like me, running Windows 7 – 64 bit, then you need to follow the next couple of steps.

8. You need to access the properties of your project, which you can do by right-clicking on your project name in the ‘Solution Explorer’ window and select properties.
clip_image010

9. You’ll have the centre box open up and show you all kinds of great information on your project, but you are interested in the ‘Compile’ options, and specifically the ‘Advanced Compile Options’ you will locate at the bottom of the Compile properties page.
clip_image012

10. By default, Visual Studio will use the bit value of the operating system to compile a program. If you are running 64-bit, then it’s compiled 64-bit. But WatiN only uses the 32-bit System.Web library at this time. So you need to change the Target Framework from ‘.Net Framework 4 Client Profile’ to ‘.Net Framework 4’.
clip_image014

For me, this was a hair pull out moment too. If you are running the ‘client profile’ version, you will lose more than sleep as WatiN will not function. Choosing the standard .Net framework 4, works just fine.

11. Finally, we will just need to use an Imports statement to call the WatiN.Core in our project code, which you will place above your main page code above everything else.
clip_image016

12. You are now ready to run WatiN in Visual Basic.net!

I would like to say a big thanks to Jeroen for his awesome help that I’ve gotten from him and especially for this awesome library of great functions! Without him, this tutorial would not be possible! Be sure to drop by his site, and send him some beer money!

http://watin.sourceforge.net/

Tags :, ,

9 Responses to “Installing WatiN into Visual Studio 2010”

  1. Chris says:

    Hey,

    Good video with some really good time saving tips. I am just looking at starting to use WatiN. What do you think is the best way to generate the code? I am looking to create a number of tests for regression testing of a medium sized site. Have you looked at the WatiN test recorder?

    Thanks for any additional information!
    Chris

    • Frank says:

      Hey Chris,

      Thanks very much. To answer your question, I’ve been spending time with the developer to get a handle on the WatiN code. He does charge, but I’m finding it worth it. I’ve tried the WatiN test recorder but there are a ton of bugs in it. For one, if you run any windows computer in 64 bit mode, you are immediately out of the game. I’ve tried to fix the problems with no luck. I’m thinking if the test recorder was working 100%, then this would be a magificent platform.

      Frank

  2. Haroon says:

    Thanks a million. Had I come across your website later, I probably would have pulled out my remaining strands of hair too (I am using a 64-bit PC/Windows)

    • Frank says:

      You’re welcome Haroon! This is exactly the reason I posted this. I have a bad habit of forgetting stuff, so I make sure that I post it for you and ME, lol.

      Frank

  3. Ai says:

    Excellent~!. I got lucky in finding your website quickly. I just started using the WatiN 30 minutes ago .. and thank you very much for your posting save hours of my work and frustration.

  4. MKG says:

    Thanks, i had the same problem on my Win 7 – 64 bit machine.
    My google search keyword was “watin.core dll on Win 7 x64″ :) , lucky that i found your site on the top results.
    Keep the knowledge sharing going.

    • Frank says:

      The exact reason I published this article! Took me days and eventually a talk with the original author of watin to figure it out. You are totally welcome.

      Frank

  5. Trent says:

    Thanks a bunch for posting this! I had been searching all over, but all of the tutorials/help was directly related to C# and I needed it for VB.net.

    I do have a question if you are able to answer; here is what I’m trying to do:

    1. Open a website
    2. Use the searchbox within the main page of the website
    3. Type in an item number and click ‘search’
    4. expected result: opens up search results page
    4b. Actual result: refreshes main page and does not do anything else

    If you have any suggestions they would be appreciated. Again, I really appreciate you posting the tutorial as it has been tremendously helpful!

    Thank you,

    Trent

Password Reset
Please enter your e-mail address. You will receive a new password via e-mail.