Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Removing delay in favor of better window management
Browse files Browse the repository at this point in the history
  • Loading branch information
evertonfraga committed Jan 13, 2017
1 parent cf90712 commit 80c83e0
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ exports.mocha = function (_module, options) {

yield this.client.waitUntilWindowLoaded();

// wait a small amount of time to ensure main app window is ready with data
yield Q.delay(8000);

// console.log(this.app.chromeDriver.logLines);

/*
Expand All @@ -131,6 +128,26 @@ exports.mocha = function (_module, options) {
this[key] = genomatic.bind(Utils[key], this);
}

// Loop over windows trying to select Main Window
let app = this;
let selectMainWindow = function* (mainWindowSearch) {
let windowHandles = (yield app.client.windowHandles()).value;

for (let handle in windowHandles) {
yield app.client.window(windowHandles[handle]);
const windowUrl = yield app.client.getUrl();
const isMainWindow = mainWindowSearch.test(windowUrl);
if (isMainWindow) return true;
}

// not main window. try again after 1 second.
yield Q.delay(1000);
yield selectMainWindow(mainWindowSearch);
}

const mainWindowSearch = (options.app === 'wallet') ? /^file:\/\/\/$/ : /interface\/index\.html$/;
yield selectMainWindow(mainWindowSearch);

this.mainWindowHandle = (yield this.client.windowHandle()).value;
},

Expand Down

0 comments on commit 80c83e0

Please sign in to comment.