WatiN TextField and ASP.NET AJAX MaskedEdit Controls
2009-09-22 23:10
423 查看
If you have tried to user WatiN tests to set the value of text boxes/fields, you likely have run into a few things.
First, this...
ie.TextField("ID").Value = "some text";
is much faster than this...
ie.TextField("ID").TypeText("some text");
Next, if you are using client side validation or any of the MaxkedEdit controls, you probably discovered that it does not play too well. I originally used this just to make it work for me...
TextField textField = ie.TextField(Find.ById(new Regex(controlId)));
textField.Focus();
for (int i = 0; i < value.Length; i++)
{
textField.KeyPress(char.Parse(value.Substring(i, 1)));
textField.WaitForComplete();
}
For one, it is pretty slow. Also, it just does not seem to work 100% of the time. WatiN exposes one additional method to make this a lot faster. Eval() will allow you to inject and run javascript in the instance of the browser..
TextField textField = ie.TextField(Find.ById(new Regex(controlId)));
string eval = string.Format("document.getElementById('{0}').value = '{1}'", textField.Id, value);
ie.Eval(eval);
Happy Testing!
First, this...
ie.TextField("ID").Value = "some text";
is much faster than this...
ie.TextField("ID").TypeText("some text");
Next, if you are using client side validation or any of the MaxkedEdit controls, you probably discovered that it does not play too well. I originally used this just to make it work for me...
TextField textField = ie.TextField(Find.ById(new Regex(controlId)));
textField.Focus();
for (int i = 0; i < value.Length; i++)
{
textField.KeyPress(char.Parse(value.Substring(i, 1)));
textField.WaitForComplete();
}
For one, it is pretty slow. Also, it just does not seem to work 100% of the time. WatiN exposes one additional method to make this a lot faster. Eval() will allow you to inject and run javascript in the instance of the browser..
TextField textField = ie.TextField(Find.ById(new Regex(controlId)));
string eval = string.Format("document.getElementById('{0}').value = '{1}'", textField.Id, value);
ie.Eval(eval);
Happy Testing!
相关文章推荐
- 从Atlas到Microsoft ASP.NET AJAX(7) - ScriptManager and ScriptManagerProxy Controls, Extender Controls
- Pro ASP.NET 3.5 Server Controls and AJAX Components
- zhuanzai: AJAX: How to create a "Processing" modal window using UpdateProgress and ModalPopup ASP.net AJAX controls
- 从Atlas到Microsoft ASP.NET AJAX(7) - ScriptManager and ScriptManagerProxy Controls, Extender Controls
- 热门的技术教程!ASP.NET MVC, JQuery, ASP.NET AJAX and ADO.NET Entity Framework
- Upload Files In ASP.NET Core 1.0 (Form POST And JQuery Ajax)
- ASP.NET AJAX MultiHandleSliderExtender - Slide by Year and Month
- I learned several ASP.NET's AJAX ability today! It is so interesting and so easy to use AJAX in ASP.NET.
- Anti-Forgery Request Recipes For ASP.NET MVC And AJAX
- Packaging ASP.NET User Controls into an Assembly and Reuse it Multiple Projects
- 从Atlas到Microsoft ASP.NET AJAX(4) - Browser Compatibility, Building Debug and Release Scripts, Defining Type Descriptors
- Validation Server Controls->ASP.NET RequiredFieldValidator Control
- Code snippet of the day : Resizing ASP.NET Datagrid Controls in Edit mode at runtime
- Telerik RadControls for ASP.NET AJAX 2010 Q2最新版下载+源码下载
- ASP.NET AJAX Drag And Drop
- ASP.NET User Controls and Custom Server Controls
- [.NET控件]Telerik RadControls for ASP.NET AJAX 2008 Q1 net 3.5 Web.UI
- ASP.NET Ajax Drag and Drop Table Columns Extender Control/拖拽表列
- Ajax Web Controls for ASP.NET!
- ASP.NET Validation Controls – Important Points, Tips and Tricks