diff --git a/src/agent/driver-test-runner.js b/src/agent/driver-test-runner.js index 3526a7e..c30a114 100644 --- a/src/agent/driver-test-runner.js +++ b/src/agent/driver-test-runner.js @@ -48,6 +48,13 @@ export class DriverTestRunner { async openPage({ url, referencePage }) { await this.log(AgentMessage.OPEN_PAGE, { url }); await this.webDriver.switchTo().defaultContent(); + // Minimizing then restoring the window is recommended to trick the window + // manager on the OS to put focus in the browser. This is needed to + // steal focus away from a terminal/powershell tab if you launch the tests + // locally. + await this.webDriver.manage().window().minimize(); + await this.webDriver.manage().window().setRect({ x: 0, y: 0 }); + await this.webDriver.switchTo().defaultContent(); await this.webDriver.navigate().to(url.toString()); try {