Selenium IDE focus event doesn't fire unless window is active Selenium IDE focus event doesn't fire unless window is active selenium selenium

Selenium IDE focus event doesn't fire unless window is active


Does it make any difference if you use the fireEvent command?

fireEvent | argh | focus


Firstly the focus event DOES fire when using Selenium. However, as the browser Selenium is controlling typically does not have the focus within the Operating System, 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.