How to force Firefox to be the foreground application when testing with Selenium on Mac OS X How to force Firefox to be the foreground application when testing with Selenium on Mac OS X selenium selenium

How to force Firefox to be the foreground application when testing with Selenium on Mac OS X


Selenium drives the browser through Javascript. There is no way to control browser window through JS. In general, testing the 'onfocus' and 'onblur' events in Selenium is very difficult.

You can try firing this event yourself by doing a JS evaluation using either the 'runScript' or the 'getEval' methods of Selenium after entering the invalid email address. This is not "pure" black box testing i.e. your test needs to be changed if the implementation of the validation is changed, but this is the most feasible way to carry out this test.