Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor OSX bring browser window to front

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?

like image 885
Billy Moon Avatar asked Aug 13 '14 18:08

Billy Moon


1 Answers

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.

like image 149
alecxe Avatar answered Oct 26 '22 17:10

alecxe