I'm trying to focus Protractor/Webdriver browser test window when testing starts. By focus I mean that the test window should come on top of the other windows displayed on screen, right now it appears under the other windows.
Using Selenium chromedriver and starting Protractor from WebStorm.
I tried the following at the beginning of the scenario spec but it didn't have any effect:
browser.driver.switchTo().defaultContent();
browser.driver.switchTo().window(browser.driver.getWindowHandle());
browser.switchTo().window(browser.getWindowHandle());
browser.driver.executeScript('window.focus();')
This isn't something Webdriver can do since it only controls your testing window, not your operating system's window manager. However, there is a Chrome flag that might do the trick:
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['--start-maximized']
}
}
This belongs in your protractor.conf.js
file.
As soon as the Chrome window opens, it will maximize. On my system this puts it in front. Your mileage may vary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With