Selenium:在 Chrome 上模拟打字
有人知道如何在 Chromium 上模拟打字吗?我想模拟真实的打字,我成功地在 Firefox 上使用了 keydown+keypress+keyup 的组合。不过,这种方法在 Chrome 上不起作用。我尝试了 key{down|press|up}native 但这也没有帮助。使用 type 命令不起作用,因为它不是模拟真实的打字,它只是设置输入元素的值。我知道 Chromium 中存在一个错误,无法成功分派关键事件,但我不确定 Selenium 是否可以在 javascript 级别或窗口级别上工作。这是我无法逾越的障碍吗?
谢谢!
Does anybody know how to simulate typing on Chromium? I want to simulate real typing and I successfully used combination of keydown+keypress+keyup on firefox. However, this approach does not work on Chrome. I tried key{down|press|up}native but that does not help, either. Using type command does not work, because it is not simulating the real typing, it is just setting the input element's value. I know there is a bug in Chromium where one is not able to dispatch key events successfully, but I wasn't sure does Selenium works on javascript level, or maybe on window level. Is this an obstacle I can't get over?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你如何使用 Selenium,但如果你通过 Selenium RC API 使用它,你可以使用普通类型(将字符串复制到字段中)。之后尝试使用类似 fireEvent("yourstringlcoator", "KeyUp") 的东西。当我想要触发 keyUP 事件时(这实际上是 jQuery 数据表),这对我有用。
I don't know how you are using Selenium but if you are using it through Selenium RC API you can use normal type (which copies the string into the field). After that try using something like fireEvent("yourstringlcoator", "KeyUp"). This has worked for me in a situation when I wanted the keyUP event triggered (this was with jQuery datatables actually).