tags:

views:

55

answers:

3

I'm trying to automate a password entry but the website in question does not allow you to type your password with the caps lock key on. WatiN appears to use the caps lock key in order to type capital letters thus not allow this to work.

Does anyone know a workaround or a way to force WatiN to use the shift key?

A: 

It has been a while since I created anything with WatiN, but you can assign the text directly with something like this:

TextBox.Text = "PaSsWoRd";

I logged into a website without any problems using the above.

Patrick
Text has no setter.
mstrickland
I seem to remember it having a setter, but maybe I am imagining things. Anyways, a quick google search turns up a TypeText method used as: ie.TextField(Find.ById("txtNickName")).TypeText("gsus");
Patrick
+1  A: 

You could write your own extension to the TextField class like this...

public static class WatinHelper
{
    public static void TypeTextFast(this TextField textField, string text)
    {
        textField.SetAttributeValue("value", text);
    }
}

and then use TypeTextFast instead of TypeText. This would furthermore improve typing speed considerably (particularly in IE) when running the WatiN test. See this for further details.

Coffeeshopboy
+1  A: 

The TextField class has the Value property you can use to set text of the TextBox directly, without mimicking a manual input, like the TypeText() method.

As a side note, because the value is set behind the scene, it may not raise an event that the value has change, which could be necessary if action append as you type. The TypeText() was taking care of that for you. In those case you can use the Change() method after setting the Value.

Vaudry