Tengo el siguiente código HTML:apoyo WatiN para las etiquetas HTML5
<input type="email" id="email">
Quiero escribir texto en él desde WatiN:
var field = Browser.TextField("email");
Assert.IsTrue(field.Exists);
Pero el campo no se puede encontrar. Esto se debe a que WatiN aún no admite etiquetas HTML5. me encontré con un solution a esto mediante la creación de una clase TextField extendida:
[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);
}
}
Después de registrar el tipo y ejecutar el código que todavía no funciona. ¿Alguien puede ver por qué o alguien tiene otra solución para este problema?
Gracias - funciona bien: usted omitió un atributo: [ElementTag ("input", InputType = "tel", Index = 11)] –