user1425353
user1425353

Reputation: 141

How to make the firefox webdriver browser window to the very front of the desktop

I'm writing automation tests with Selenium 2.0, in Java, Win7 platform. In some situation, I need the firefoxdriver window to be in front of all windows on the desktop, not only windows of the firefoxdriver but also the mannually opened ones(eclispe IDE e.g.). Is there some way to do this? I've investigated this for 2 days, maybe I'll need some Windows API? Any comment, big welcome

Upvotes: 3

Views: 3211

Answers (3)

shellbye
shellbye

Reputation: 4848

I use python, and I got what I want by:

self.selenium.execute_script('alert(1);')
alert = self.selenium.switch_to.alert
alert.accept()

Hope this help someone later.

Upvotes: 2

Alex Okrushko
Alex Okrushko

Reputation: 7372

python:

webdriver.execute_script('window.focus()')

Java:

webdriver.executeScript('window.focus()')

Upvotes: 1

AJ_Cemprola
AJ_Cemprola

Reputation: 143

This should help with positioning the window. It should come into focus once the tests are running.

   webDriver.Manage().Window.Position = new Point(screenPosition, 0);
   webDriver.Manage().Window.Size = new Size(width, height);

Upvotes: 1

Related Questions