硒IDE:如何检查一个元素是否有焦点? [英] Selenium IDE: How to check if an element has a focus?

查看:171
本文介绍了硒IDE:如何检查一个元素是否有焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个内置的方法来检查一个输入文本元素有焦点?

那么,我没有找到一个,所以我试过这个扩展

但是,它不适用于我或者(即测试失败)。



有什么想法吗?

解决方案

由于Selenium控制的浏览器通常没有在操作系统内部的焦点,所以检测一个元素是否有焦点,我有很多问题,因此,浏览器将不会考虑任何元素焦点,直到浏览器重新获得焦点。 / p>

我已经把我的头发拉出来了,所以解决了这个问题。请参阅 http://blog.mattheworiordan.com/ post / 9308775285 / testing-focus-with-jquery-and-selenium-或者
查看问题的完整解释和解决方法。

如果您不能阅读冗长的解释,只需包含 https://gist.github.com / 1166821 在包含JQuery之前,使用$(':focus')来查找具有焦点的元素,或者使用.is(':focus')来检查元素是否具有焦点。 b $ b

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 ?

解决方案

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.

这篇关于硒IDE:如何检查一个元素是否有焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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