如何减少 Watin 中的 TypeText 延迟?
如何减少 Watin 的 TypeText 方法中按键之间的延迟?如果我想“即时”输入一些文本,有更好的方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我知道有点晚了,但我不妨为其他有同样问题的人分享这些信息,特别是考虑到你要求提供一个例子。
玩得开心。 这里是一篇关于另一种方法是我前段时间发现的。
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.
Have fun. Here is a nice post on an alternative way which is where I found this some time back.
答案是在元素上使用
.ClickNoWait()
,然后设置其.Value
属性。希望这对某人有帮助。
The answer is to
.ClickNoWait()
on the element, and then just set its.Value
property.Hope this helps someone.
对我来说,只需设置文本字段的值属性就可以了,但这可能取决于页面的编码方式。
For me, simply setting the value attribute for the text field worked, but it could depend on how the page is coded.
我也遇到了这个问题,仅仅单击文本字段并设置值就会导致测试失败,因为我们的 ASP.NET WebForms 应用程序具有在
change
事件触发时执行的验证器。以下是 WatiN 扩展的源代码:如果您有在用户单击
textfield
时触发的事件处理程序,只需添加textfield.Click()
或 < code>textfield.ClickNoWait() 在设置值之前。请记住代码开头的
using Project.Extensions;
行以包含 WatiN 扩展。现在您可以调用扩展方法:
I ran into this problem as well, and just clicking on the text field and setting the value was causing test failures because our ASP.NET WebForms application has validators that execute when the
change
event fires. Here is the source code for an Extension to WatiN:If you have event handlers that get triggered when the user clicks on the
textfield
, just addtextfield.Click()
ortextfield.ClickNoWait()
before setting the value.Remember the
using Project.Extensions;
line at the beginning of your code to include the WatiN extensions.Now you can call the extension method: