J'ai le HTML suivant :
<input type="email" id="email">
Je veux y taper du texte à partir de WatiN :
var field = Browser.TextField("email");
Assert.IsTrue(field.Exists);
Mais le champ est introuvable. C'est parce que WatiN ne supporte pas encore les balises HTML5. J'ai trouvé un solution en créant une classe TextField étendue :
[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);
}
}
Après avoir enregistré le type et exécuté le code, cela ne fonctionne toujours pas. Quelqu'un peut-il voir pourquoi ou a-t-il une autre solution pour résoudre ce problème ?