diff --git a/lib/browser.ts b/lib/browser.ts index aa0026c2e..128c656a5 100644 --- a/lib/browser.ts +++ b/lib/browser.ts @@ -348,7 +348,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { this.ignoreSynchronization = false; this.getPageTimeout = DEFAULT_GET_PAGE_TIMEOUT; this.params = {}; - this.ready = null; this.plugins_ = new Plugins({}); this.resetUrl = DEFAULT_RESET_URL; this.debugHelper = new DebugHelper(this); @@ -370,17 +369,22 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { ng12Hybrid_ = ng12Hybrid; } }); - this.driver.getCapabilities().then((caps: Capabilities) => { - // Internet Explorer does not accept data URLs, which are the default - // reset URL for Protractor. - // Safari accepts data urls, but SafariDriver fails after one is used. - // PhantomJS produces a "Detected a page unload event" if we use data urls - let browserName = caps.get('browserName'); - if (browserName === 'internet explorer' || browserName === 'safari' || - browserName === 'phantomjs' || browserName === 'MicrosoftEdge') { - this.resetUrl = 'about:blank'; - } - }); + this.ready = this.driver.controlFlow() + .execute(() => { + return this.driver.getSession(); + }) + .then((session: Session) => { + // Internet Explorer does not accept data URLs, which are the default + // reset URL for Protractor. + // Safari accepts data urls, but SafariDriver fails after one is used. + // PhantomJS produces a "Detected a page unload event" if we use data urls + let browserName = session.getCapabilities().get('browserName'); + if (browserName === 'internet explorer' || browserName === 'safari' || + browserName === 'phantomjs' || browserName === 'MicrosoftEdge') { + this.resetUrl = 'about:blank'; + } + return this; + }); this.trackOutstandingTimeouts_ = !opt_untrackOutstandingTimeouts; this.mockModules_ = []; diff --git a/lib/runner.ts b/lib/runner.ts index 147cba119..e79a197a7 100644 --- a/lib/runner.ts +++ b/lib/runner.ts @@ -249,7 +249,13 @@ export class Runner extends EventEmitter { } browser_.ready = - driver.manage().timeouts().setScriptTimeout(config.allScriptsTimeout).then(() => browser_); + browser_.ready + .then(() => { + return driver.manage().timeouts().setScriptTimeout(config.allScriptsTimeout); + }) + .then(() => { + return browser_; + }); browser_.getProcessedConfig = () => { return wdpromise.fulfilled(config); @@ -261,9 +267,16 @@ export class Runner extends EventEmitter { newBrowser.mockModules_ = browser_.mockModules_; } if (opt_useSameUrl) { - browser_.driver.getCurrentUrl().then((url: string) => { - newBrowser.get(url); - }); + newBrowser.ready = newBrowser.ready + .then(() => { + return browser_.driver.getCurrentUrl(); + }) + .then((url: string) => { + return newBrowser.get(url); + }) + .then(() => { + return newBrowser; + }); } return newBrowser; };