I am running protractor to test angularjs app. All working fine, but when the browser window is spawned, it is in the background, so I have to cmd-tab to find it, and miss what happens at the start.
Is there any way I can programmatically bring the browser window to the foreground?
You can trigger an alert and immediately accept it. Put the following into onPrepare()
:
onPrepare: function () {
return browser.executeScript("alert('Test');").then(function () {
return browser.switchTo().alert().accept();
});
},
Or, as @LeoGalucci pointed out, take a screenshot:
onPrepare: function () {
return browser.takeScreenshot();
},
Note that return
is important here - in this case, Protractor
would not start executing tests until the promise returned from onPrepare()
is resolved.
Both options worked for me.
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