Reputation: 141
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
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
Reputation: 7372
python:
webdriver.execute_script('window.focus()')
Java:
webdriver.executeScript('window.focus()')
Upvotes: 1
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