Selenium IDE:如何检查元素是否具有焦点?
Is there a built in method for checking that an input text element has a focus ?
Well, I didn't find one, so I tried this extension.
But, it doesn't work for me either (i.e. the test fails).
Any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在检测某个元素是否具有焦点时遇到了很多问题,因为 Selenium 控制的浏览器通常在操作系统中没有焦点,因此在浏览器重新获得焦点之前,浏览器不会考虑任何元素具有焦点。
我一直在为这个问题烦恼,所以想出了一个解决这个问题的方法。请参阅http://blog.mattheworiordan.com/帖子/9308775285/testing-focus-with-jquery-and-selenium-or
问题的完整解释和解决方案。
如果您不愿意阅读冗长的解释,只需添加 https://gist.github.com/1166821< /a> 在包含 JQuery 之前,使用 $(':focus') 查找具有焦点的元素,或使用 .is(':focus') 检查元素是否具有焦点。
I have had numerous problems detecting if an element has focus because the browser Selenium is controlling typically does not have the focus within the Operating System, and as such the browser will NOT consider any elements to have focus until the browser regains the focus.
I have been pulling my hair out over this, so worked up a solution to this problem. See http://blog.mattheworiordan.com/post/9308775285/testing-focus-with-jquery-and-selenium-or
for a full explanation of the problem and a solution to this.
If you can't be arsed to read the lengthy explanation, simply include https://gist.github.com/1166821 BEFORE you include JQuery, and use $(':focus') to find the element that has focus, or .is(':focus') to check if an element has focus.
我编写了该插件,它在我的环境中运行良好。
您能给我详细介绍一下您是如何使用它的吗?如果我们发现错误,我会尝试修复它。
I wrote that plugin and it is working fine in my environment.
Could you provide me a detailed description of how you used it? I would try bugfix it if we will find a bug.