WatiN 并输入大写字母

发布于 2024-09-25 00:06:39 字数 119 浏览 0 评论 0原文

我正在尝试自动输入密码,但相关网站不允许您在打开大写锁定键的情况下输入密码。 WatiN 似乎使用大写锁定键来输入大写字母,因此不允许此操作。

有谁知道强制 WatiN 使用 Shift 键的解决方法或方法?

I'm trying to automate a password entry but the website in question does not allow you to type your password with the caps lock key on. WatiN appears to use the caps lock key in order to type capital letters thus not allow this to work.

Does anyone know a workaround or a way to force WatiN to use the shift key?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月静好 2024-10-02 00:06:39

您可以像这样将自己的扩展写入 TextField 类...

public static class WatinHelper
{
    public static void TypeTextFast(this TextField textField, string text)
    {
        textField.SetAttributeValue("value", text);
    }
}

然后使用 TypeTextFast 而不是 TypeText。在运行 WatiN 测试时,这将进一步显着提高打字速度(特别是在 IE 中)。请参阅 了解更多详情。

You could write your own extension to the TextField class like this...

public static class WatinHelper
{
    public static void TypeTextFast(this TextField textField, string text)
    {
        textField.SetAttributeValue("value", text);
    }
}

and then use TypeTextFast instead of TypeText. This would furthermore improve typing speed considerably (particularly in IE) when running the WatiN test. See this for further details.

同展鸳鸯锦 2024-10-02 00:06:39

TextField 类具有 Value 属性,您可以使用它直接设置 TextBox 的文本,而无需模仿手动输入,如 TypeText() 方法。

顺便说一句,因为该值是在场景后面设置的,所以它可能不会引发该值已更改的事件,如果您在键入时附加操作,则这可能是必要的。 TypeText() 正在为您处理这个问题。在这种情况下,您可以在设置值后使用 Change() 方法。

The TextField class has the Value property you can use to set text of the TextBox directly, without mimicking a manual input, like the TypeText() method.

As a side note, because the value is set behind the scene, it may not raise an event that the value has change, which could be necessary if action append as you type. The TypeText() was taking care of that for you. In those case you can use the Change() method after setting the Value.

一曲琵琶半遮面シ 2024-10-02 00:06:39

自从我使用 WatiN 创建任何内容以来已经有一段时间了,但是您可以直接使用如下所示的内容分配文本:

TextBox.Text = "PaSsWoRd";

我使用上述方法登录网站没有任何问题。

It has been a while since I created anything with WatiN, but you can assign the text directly with something like this:

TextBox.Text = "PaSsWoRd";

I logged into a website without any problems using the above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文