Selenium:如何从文本框中删除字符

发布于 2024-08-19 14:18:51 字数 212 浏览 1 评论 0原文

我正在尝试模拟用户从文本框中删除字符。这个文本框触发了许多 JS 事件,因此我在 ift 中键入(或 typeKey-ing)时遇到了很多麻烦。

我最近的尝试是: sel.key_press(locator, 127)sel.key_press(locator, "\177 ") 但它们不起作用。

最安全的方法是什么?

I'm trying to simulate a user deleting a character from a textbox. This textbox fires many JS events, I've had much trouble typing (or typeKey-ing) in ift because of this.

My latest try was: sel.key_press(locator, 127) and sel.key_press(locator, "\177
")
but they don't work.

What's the safest way?

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

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

发布评论

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

评论(2

初见你 2024-08-26 14:18:51

将 KeyPress 与 '\008' 一起使用

Use KeyPress with '\008'

携君以终年 2024-08-26 14:18:51

我认为 Selenium 不可能做到这一点。每次修改都会导致单独的 Type 命令调用。因此,例如,如果您编写“houses”,然后删除最后一个字符,则会将其翻译为:

type(, "houses")

type(, "house") ,而

不管发生什么情况在 JavaScript 级别。如果您的任务是测试各种方法,您应该使用 JsUnit(或 FireBug)。

I don't think that's possible with Selenium. Each modify results in a separate Type command call. So, for example, if you write "houses" and then delete the last character, it's translated with:

type(<field>, "houses")

type(<field>, "house")

with no regard of what happens at the Javascript level. If your task is to test the various methods you should use JsUnit (or FireBug).

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