-1

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!

sahiljain
  • 2,215
  • 1
  • 29
  • 39

1 Answers1

1

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.

Migrating from Selenium RC to Selenium Webdriver

Abhishek_Mishra
  • 4,551
  • 4
  • 25
  • 38
  • I am already maximizing using **selenium.windowMaximize()** and window does get maximize but doesn't get focus. :( – sahiljain Jun 12 '14 at 14:01
  • thanks a lot for the quick reply and thoughtful suggestions. I have used all these functions but to no avail. One more thing i have automated quite a stuff at this point in time and migrating to webdriver would require lot of effort and cant afford now but plan to do it in future. – sahiljain Jun 12 '14 at 14:50
  • You are most welcome.I would say migration is not so tedious as they have provided support to the former API as well under the class "WebdriverBackedSelenium". Refer the link given in the answer. – Abhishek_Mishra Jun 12 '14 at 14:58
  • Thanks for the suggestion. I am also struggling with the version of the sel and FF. I am struggling to find most compatible version between Webdriver and firefox. – sahiljain Jun 13 '14 at 05:40