Re: [Watin-users] TextField not being detected
Brought to you by:
jvmenen
|
From: Benjamin W. <ben...@bo...> - 2015-01-06 10:14:22
|
Thanks very much, that was really helpful.
Ben
From: Lowell Izaguirre [mailto:lo...@st...]
Sent: 05 January 2015 17:12
To: wat...@li...
Subject: Re: [Watin-users] TextField not being detected
it has to do with the input type; the new HTML 5 types are not in the old verison of Watin,a dn i haven't seen a newer , official release that directly supports the new types yet.
input type="email"
that's not recognized by watin, and you have to add a custom class which inherits watin to watch for it and the other new HTML5 input types instead.
here's how i might use that class to get/set a textbox extension class object :
on this page for example they had input type="email"(which is unknown to the default watin)
and input type="password",(which watin natively understands
myIEBrowser.GoTo("https://SomeWebSite/Login/"<https://SomeWebSite/Login/>);
//myIEBrowser.TextField(Find.ByName("username")).TypeText("lo...@so..."<mailto:lo...@so...>);
myIEBrowser.ElementOfType<TextFieldExt>(Find.ByName("username")).TypeText(LoginUser);
myIEBrowser.TextField(Find.ByName("password")).TypeText(LoginPass);
myIEBrowser.Button(Find.ByName("submitButn")).Click();
and here's my extension class in c#;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WatiN.Core;
namespace HPPWatin.DemographicsAutomation
{
//html5 tags
[ElementTag("input", InputType = "text", Index = 0)]
[ElementTag("input", InputType = "password", Index = 1)]
[ElementTag("input", InputType = "textarea", Index = 2)]
[ElementTag("input", InputType = "hidden", Index = 3)]
[ElementTag("textarea", Index = 4)]
[ElementTag("input", InputType = "email", Index = 5)]
[ElementTag("input", InputType = "url", Index = 6)]
[ElementTag("input", InputType = "number", Index = 7)]
[ElementTag("input", InputType = "range", Index = 8)]
[ElementTag("input", InputType = "search", Index = 9)]
[ElementTag("input", InputType = "color", Index = 10)]
[ElementTag("input", InputType = "textbox", Index = 11)]
[ElementTag("input", InputType = "tel", Index = 12)]
public class TextFieldExt : WatiN.Core.TextField
{
//public TextBox() : base() { }
public TextFieldExt(DomContainer domContainer, WatiN.Core.ElementFinder finder) : base(domContainer, finder) { }
public TextFieldExt(DomContainer domContainer, WatiN.Core.Native.INativeElement element) : base(domContainer, element) { }
public static void Register()
{
Type typeToRegister = typeof(TextFieldExt);
ElementFactory.RegisterElementType(typeToRegister);
}
}
}
On 1/5/2015 11:46 AM, Benjamin Wylie wrote:
I am using watin to automate logging on to this site and getting some data:
https://id.atlassian.com/login
Unfortunately watin doesn't detect the email address field (username) as a TextField and so I can't use TypeText to type in a username.
There are no problems when using the password field.
I can't see any obvious discrepencies between the way the two fields are created in the html:
<div class="field-group ">
<label for="username">Email address</label>
<input class="text full-width-field" type="email" name="username" id="username" autofocus placeholder="Email address" maxlength=255/>
</div>
<div class="field-group ">
<label for="password">Password</label>
<input class="text full-width-field" type="password" name="password" id="password" placeholder="Password"/>
</div>
Is there a reason why this wouldn't be detected as a TextField by watin?
Thanks for your help,
Ben
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
Watin-users mailing list
Wat...@li...<mailto:Wat...@li...>
https://lists.sourceforge.net/lists/listinfo/watin-users
|