Getting Started with WatiN

Here’s a code snippet to start testing with WatiN. Got it from the WatiN web site.

using System;
using WatiN.Core;

namespaceWatiNGettingStarted
{
  class WatiNConsoleExample
  {
    [STAThread]
    static void Main(string[] args)
    {
      // Open a new Internet Explorer window and
      // goto the google website.
      IE ie = new IE(http://www.google.com);
      // Find the search text field and type Watin in it.
      ie.TextField(Find.ByName(“q”)).TypeText(“WatiN”);
      // Click the Google search button.
      ie.Button(Find.ByValue(“Google Search”)).Click();
      // Uncomment the following line if you want to close
      // Internet Explorer and the console window immediately.
      //ie.Close();
    }
  }
}


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