WatiN doesn't find anything

57 Views Asked by At

I'm new to C# and I'm trying to do an application that automatize Internet Explorer.

When I click a button, the application does :

using ( var Browser = new IE())
{
    Browser.GoTo("http://testweb.com"); 
    Browser.TextField(Find.ByName("username")).TypeText("User");
    Browser.TextField(Find.ByName("password")).TypeText("Pass");
}

But it doesn't write anything. It navigates to the web but...

1

There are 1 best solutions below

0
Phil Zan On

Try this:

IE ie = null;
ie = new IE();
ie.GoTo("Link");
ie.WaitForComplete();

At least to get started.

For the other bit, you need to get an exact identification and then you can tell WaTiN to interact with it.

Textfield userTextBox = ie.Textfield(Find.ByName("name"));
userTextBox.TypeText("user");

This may seem banal but now you can add a peek definition in your code and see if "userTextBox" gets found by name. If it doesn't you need to find it through another method (ID or class).