I just recently started looking into WatiN and was following the example from http://www.codeproject.com/KB/aspnet/WatiN.aspx. Unfortunately, I am running into an issue where it is claiming that a text field with the name “q” does not exist.
Here is my code:
[STAThread]
static void Main(string[] args)
{
IE ie = new IE();
ie.GoTo("http://www.google.com");
TextField ietxt = ie.TextField(Find.ByName("q"));
ietxt.TypeText("WatiN");
ie.Button(Find.ByValue("Google Search")).Click();
}
When it gets to the line ietxt.TypeText(“WatiN”) it throws the error:
“Could not find INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA element tag matching criteria: Attribute ‘name’ equals ‘q’ at google.com/ (inner exception: Element wasn’t available within 30 seconds.)”
It seems that everyone uses this example and it works fine for them. Also I went into the source code for google.com and found exactly where it states that “q” is indeed the name of the search text field.
<input name="q" title="Search" class="gsfi" id="lst-ib" ....>
Does anyone have any idea why I could be getting this error?
I found a fix for this! From further testing I came to the conclusion that the issue seemed to be coming from how IE 8 was configured on my machine. I tested on other machines with xp and IE8, and everything was working fine. Uninstalling and reinstalling IE8 has cleared up the issue.
I’m still not sure what was configured differently with my past version of IE8, so if anyone has any ideas of what could have caused this I’ll be delighted to hear.
Thanks!