Henry
Henry

Reputation: 384

watin not working with live.com

I am trying to use watin to mimic login to live.com using c#. code is below.

IE myIE = new IE("http://login.live.com/");  
myIE.TextField(Find.ByName("login")).TypeText("[email protected]"); 
myIE.TextField(Find.ByName("passwd")).TypeText("1234"); 

myIE.Button(Find.ByValue("Sign in")).Click();

However it always failed to find the textfield:

WatiN.Core.Exceptions.ElementNotFoundException: Could not find INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA element tag matching criteria: Attribute 'name' equals 'login' at http://login.live.com/

The sample code in home page of http://watin.org/ works fine for www.google.com.

Did I miss something or is there anything special on http://login.live.com that prevents watin to work?

PS: I am running windows 7 64bit. VS 2008 with .net 3.5

Upvotes: 0

Views: 914

Answers (2)

OCary
OCary

Reputation: 3311

You're hitting issues because the email field you're trying to type in is an HTML5 element.

Create the TextFieldExtended class as defined in this SO question: WatiN support for HTML5 tags

Then your code will be like the below:

ie.GoTo("http://login.live.com/");
ie.ElementOfType<TextFieldExtended>(Find.ByName("login")).TypeText("[email protected]");
ie.TextField(Find.ByName("passwd")).TypeText("thisismypassword");
ie.Button(Find.ByValue("Sign in")).Click();

Tested on Watin2.1, IE9, Win7-64.

Upvotes: 1

Botonomous
Botonomous

Reputation: 1764

You may want to try this: I got it to work on my end:

ie.Div(Find.ByCustom("innertext","[email protected]")).Click();
ie.TextField(Find.ById("i0116")).TypeText("hello");
ie.TextField(Find.ById("i0118")).Click();
ie.TextField(Find.ById("i0118")).TypeText("Hello!");

I recommend using this test Recorder. It will give you the elemnt names to use in your source:

http://www.codeproject.com/Articles/19180/WatiN-Test-Recorder

Edit:

I was also able to get this to work when finding by divID.

ie.Element(Find.ById("idDiv_PWD_UsernameExample")).Click()

Upvotes: 0

Related Questions