使用WatiN脚本将击键(即Enter键)传递到应用程序中 [英] Pass a key stroke (i.e., Enter Key) into application using WatiN scripts

查看:79
本文介绍了使用WatiN脚本将击键(即Enter键)传递到应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WatiN测试工具。我可以使用WatiN脚本将击键(即,按Enter键)传递给应用程序吗?

I'm using WatiN testing tool. Can I pass a key stroke (i.e., pressing a enter key) to the application using WatiN scripts?

该选项在WatiR中可用。此选项在WatiN中可用吗?

This option was available in WatiR. Is this option available in WatiN?

推荐答案

编辑:在进一步检查后,我发现该标准在WatiN中,发送Enter键的方法与在WatiR中不起作用。您需要使用 System.Windows.Forms.SendKeys

Upon further inspection, I found that the standard way of sending the ENTER key doesn't work in WatiN as it does in WatiR. You need to use System.Windows.Forms.SendKeys

此外,我建议您下载 WatiN Test Recorder

Also, I recommend that you download the WatiN Test Recorder.

这是示例代码。

using(IE ie = new IE("http://someurl"))
{
  TextField myTxt = ie.TextField(Find.ById("myTextBox")).TypeText("some value");
  System.Windows.Forms.SendKeys.SendWait("{ENTER}");      
}

这篇关于使用WatiN脚本将击键(即Enter键)传递到应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆