1

I have different selenium tests created on my fitnesse wiki. Fitnesse wiki is opened in a chrome browser. Now, When I hit on Test to run a particular test on fitnesse wiki, it opens a new chrome instance and runs tests there. The problem is that the new chrome instance opens in background and I can not see the execution unless I manually click the running chrome instance to bring it to foreground. My requirement is that whenever a new instance opened, it should get opened in foreground/OnTop without any manual intervention. How can I achieve this using selenium C#. Any help will be very much appreciated.

1 Answers1

0

Since Chrome was opened by Selenium, you should have access to that window.

Try to maximize the window:

driver.Manage().Window.Maximize();
Timothy Cope
  • 482
  • 2
  • 11
  • I have implemented this option already. It's not working. It is just maximizing the window but in background. I have to click on the running instance still to bring it on top. – Rupesh Barnawal Jun 07 '17 at 15:58
  • OS operations (such as bringing windows in and out of focus) are outside the control of Selenium as pointed out in [this answer](https://sqa.stackexchange.com/a/20035/23015) on SQA stack exchange. – Timothy Cope Jun 07 '17 at 16:04
  • How can I handle it (bringing running instance of chrome to foreground) then on OS level using C# fixture. This is very much needed for my tests to pass. – Rupesh Barnawal Jun 08 '17 at 05:23
  • Look into the User32.dll. A quick Google search yields a few examples of how to use it. – Timothy Cope Jun 08 '17 at 16:29
  • I tried to bring the running chrome instance foreground/OnTop through SetForegroundWindow(hWnd) but could not succeed till now. Process.GetProcessById(pid).MainWindowHandle is returning 0 instead of the chromedriver window handle. Any help in this regard what am I missing. – Rupesh Barnawal Jun 11 '17 at 17:33