Take the 2-minute tour ×

How does one reduce the delay between keypresses in the TypeText method of Watin? Is there a better way if I want to "instantaneously" type some text?

share|improve this question
Just to be clear, "blog-type" posts are not recommended. Asking-then-answering questions is not really the purpose of this site. However, "answered my own question" is just fine. –  jcolebrand Dec 27 '10 at 5:25
@drachenstern: I did indeed answer my own question, and decided to post it in case someone else ran into the same issue. –  Kim Sun-wu Dec 27 '10 at 8:13
I have removed watir tag since the question is not related to it. –  Željko Filipin Dec 27 '10 at 9:50
@drachenstern: According to the FAQ: "It's also perfectly fine to ask and answer your own question, as long as you pretend you're on Jeopardy: phrase it in the form of a question." In this particular case, it was done correctly. –  Cody Gray Dec 27 '10 at 11:40
@CodyGray ~ Too true. –  jcolebrand Dec 27 '10 at 14:47
add comment

3 Answers

up vote 4 down vote accepted

The answer is to .ClickNoWait() on the element, and then just set its .Value property.

Hope this helps someone.

share|improve this answer
Can I see an example in use? I'm having trouble executing. –  atwellpub Dec 7 '11 at 0:16
add comment

I know its a bit late but I might as well share this bit of info for others having the same problem who land here especially considering you asked for an example.

IE browser = new IE();

browser.TextField("UserName").Value = "admin";
browser.TextField("Password").Value = "pass123";

Have fun. Here is a nice post on an alternative way which is where I found this some time back.

share|improve this answer
add comment
    LoginPage LoginPage = Browser.Page<LoginPage>();

    string UserName = ConstVars.UserName;
    string Password = ConstVars.Password;

    if (LoginPage.UserNameTextField.GetAttributeValue("value") != UserName)
        LoginPage.UserNameTextField.SetAttributeValue("value", UserName);
    if (LoginPage.PasswordTextField.GetAttributeValue("value") == null)
        LoginPage.PasswordTextField.SetAttributeValue("value", Password);

For me, simply setting the value attribute for the text field worked, but it could depend on how the page is coded.

share|improve this answer
add comment

Your Answer


