I ran into this problem, and just clicking on the text field and setting the value caused testing errors, because our ASP.NET WebForms application has validators that are executed when the change event is triggered. Here is the source code for the extension for WatiN:
using WatiN.Core; namespace Project.Extensions { public static class WatinExtensions { public static void TypeTextFaster(this TextField textfield, string value) { textfield.Value = value; textfield.Change(); } } }
If you have event handlers that fire when the user clicks on textfield , just add textfield.Click() or textfield.ClickNoWait() before setting the value.
Remember the line using Project.Extensions; at the beginning of your code to enable the WatiN extensions.
Now you can call the extension method:
TextField field = browser.TextField("id"); field.TypeTextFaster("the text to type");
Greg burghardt
source share