I am using Selenium 2.40.0 jar and Firefox 27.0 to test my web application. I am facing the issue while focusing on specific element since onstart the focus is not on Firefox window. how do I get the focus on Firefox window for focus element to work?
Thanks for the help!
I hope using
driver.manage().window.maximize();
will set the focus on window by default.
Edit :
With Selenium RC you can try these two more functions (Any of these should work)
selenium.windowFocus();
selenium.selectWindow(windowID or windowName);
To get the window ID and names at run time you can use these functions :
selenium.getAllWindowIds();
selenium.getAllWindowNames();
These will return an array of IDs and Names of all opened broswer windows via selenium.You have to select as per your need.
On top of all this I would recommend you to use Selenium Webdriver in place of Selenium RC if possible as selenium RC is now depricated. The above given function driver.manage().window.maximize(); is for Webdriver only. Using webdriver you can avoid these small issues easily.