Ho il seguente codice HTML:supporto per i tag HTML5 WatiN
<input type="email" id="email">
devo digitare il testo in esso da WatiN:
var field = Browser.TextField("email");
Assert.IsTrue(field.Exists);
Ma il campo non può essere trovato. Questo perché WatiN non supporta ancora i tag HTML5. Ho trovato un solution a questo creando un esteso TextField-classe:
[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)]
public class TextFieldExtended : TextField
{
public TextFieldExtended(DomContainer domContainer, INativeElement element)
: base(domContainer, element)
{
}
public TextFieldExtended(DomContainer domContainer, ElementFinder finder)
: base(domContainer, finder)
{
}
public static void Register()
{
Type typeToRegister = typeof (TextFieldExtended);
ElementFactory.RegisterElementType(typeToRegister);
}
}
Dopo aver registrato il tipo e l'esecuzione del codice ancora non funziona. Qualcuno può vedere perché o qualcuno ha un'altra soluzione per questo problema?
Grazie - funziona benissimo - hai omesso un attributo: [ElementTag ("input", InputType = "tel", Index = 11)] –