WatiN: Error trying TypeText ("WatiN") in Google search text box

I recently started to study WatiN and followed the example of http://www.codeproject.com/KB/aspnet/WatiN.aspx . Unfortunately, I have a problem when he claims that a text box named "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 falls into the string ietxt.TypeText ("WatiN"), it gives an error: "Could not find the matching criteria INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA: attribute" name " equals "q" on google.com/(Internal exception: the item wasn 't available for 30 seconds.) "

Everyone seems to be using this example, and it is great for them. In addition, I went into the google.com source code and found exactly where it indicates that “q” is indeed the name of the search text field.

 <input name="q" title="Search" class="gsfi" id="lst-ib" ....> 

Does anyone know why I can get this error?

+4
source share
1 answer

I found a fix for this! From further testing, I came to the conclusion that the problem seemed to come from how IE 8 was configured on my machine. I tested on other machines with xp and IE8, and everything worked fine. An issue with uninstalling and reinstalling IE8 has been fixed.

I'm still not sure what was set up differently with my last version of IE8, so if anyone has any ideas on what might cause this, I will be happy to hear.

Thanks!

+1
source

Source: https://habr.com/ru/post/1385384/


All Articles