diff --git a/lib/browser.ts b/lib/browser.ts index 07c693055..37b2ed19b 100644 --- a/lib/browser.ts +++ b/lib/browser.ts @@ -238,7 +238,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { * Resolved when the browser is ready for use. Resolves to the browser, so * you can do: * - * forkedBrowser = await browser.forkNewDriverInstance().ready; + * forkedBrowser = await browser.forkNewDriverInstance(); * * Set by the runner. * @@ -359,22 +359,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { ng12Hybrid_ = ng12Hybrid; } }); - this.ready = this.angularAppRoot(opt_rootElement || '') - .then(() => { - 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_ = []; @@ -423,7 +407,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { * Fork another instance of browser for use in interactive tests. * * @example - * var forked = await browser.forkNewDriverInstance().ready; + * var forked = await browser.forkNewDriverInstance(); * await forked.get('page1'); // 'page1' gotten by forked browser * * @param {boolean=} useSameUrl Whether to navigate to current url on creation @@ -433,8 +417,9 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { * * @returns {ProtractorBrowser} A browser instance. */ - forkNewDriverInstance(useSameUrl?: boolean, copyMockModules?: boolean, copyConfigUpdates = true): - ProtractorBrowser { + async forkNewDriverInstance( + useSameUrl?: boolean, copyMockModules?: boolean, + copyConfigUpdates = true): Promise { return null; } @@ -456,7 +441,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { * await browser.get('page2'); // 'page2' gotten by restarted browser * * // Running against forked browsers - * var forked = await browser.forkNewDriverInstance().ready; + * var forked = await browser.forkNewDriverInstance(); * await fork.get('page1'); * fork = await fork.restart(); * await fork.get('page2'); // 'page2' gotten by restarted fork diff --git a/lib/driverProviders/attachSession.ts b/lib/driverProviders/attachSession.ts index 226ee63d2..1d2cc08e1 100644 --- a/lib/driverProviders/attachSession.ts +++ b/lib/driverProviders/attachSession.ts @@ -35,10 +35,11 @@ export class AttachSession extends DriverProvider { * @public * @return {WebDriver} webdriver instance */ - getNewDriver(): WebDriver { + async getNewDriver(): Promise { const httpClient = new http.HttpClient(this.config_.seleniumAddress); const executor = new http.Executor(httpClient); - const newDriver = WebDriver.attachToSession(executor, this.config_.seleniumSessionId, null); + const newDriver = + await WebDriver.attachToSession(executor, this.config_.seleniumSessionId, null); this.drivers_.push(newDriver); return newDriver; } diff --git a/lib/driverProviders/direct.ts b/lib/driverProviders/direct.ts index a5ec15d32..4d7b4ded0 100644 --- a/lib/driverProviders/direct.ts +++ b/lib/driverProviders/direct.ts @@ -49,7 +49,7 @@ export class Direct extends DriverProvider { * @override * @return webdriver instance */ - getNewDriver(): WebDriver { + async getNewDriver(): Promise { let driver: WebDriver; switch (this.config_.capabilities.browserName) { @@ -74,7 +74,7 @@ export class Direct extends DriverProvider { } let chromeService = new ChromeServiceBuilder(chromeDriverFile).build(); - driver = DriverForChrome.createSession( + driver = await DriverForChrome.createSession( new Capabilities(this.config_.capabilities), chromeService); break; case 'firefox': @@ -98,7 +98,7 @@ export class Direct extends DriverProvider { } let firefoxService = new FirefoxServiceBuilder(geckoDriverFile).build(); - driver = DriverForFirefox.createSession( + driver = await DriverForFirefox.createSession( new Capabilities(this.config_.capabilities), firefoxService); break; default: diff --git a/lib/driverProviders/driverProvider.ts b/lib/driverProviders/driverProvider.ts index f6f9e3615..f562db5e1 100644 --- a/lib/driverProviders/driverProvider.ts +++ b/lib/driverProviders/driverProvider.ts @@ -7,7 +7,10 @@ import {Builder, WebDriver} from 'selenium-webdriver'; import {BlockingProxyRunner} from '../bpRunner'; import {Config} from '../config'; +import {BrowserError} from '../exitCodes'; +import {Logger} from '../logger'; +let logger = new Logger('driverProvider'); export abstract class DriverProvider { drivers_: WebDriver[]; config_: Config; @@ -42,7 +45,7 @@ export abstract class DriverProvider { * @public * @return webdriver instance */ - getNewDriver() { + async getNewDriver() { let builder: Builder; if (this.config_.useBlockingProxy) { builder = @@ -56,7 +59,12 @@ export abstract class DriverProvider { if (this.config_.disableEnvironmentOverrides === true) { builder.disableEnvironmentOverrides(); } - let newDriver = builder.build() as WebDriver; + let newDriver: WebDriver; + try { + newDriver = await builder.build(); + } catch (e) { + throw new BrowserError(logger, (e as Error).message); + } this.drivers_.push(newDriver); return newDriver; } @@ -72,6 +80,7 @@ export abstract class DriverProvider { if (driverIndex >= 0) { this.drivers_.splice(driverIndex, 1); try { + await driver.close(); await driver.quit(); } catch (err) { // This happens when Protractor keeps track of all the webdrivers diff --git a/lib/driverProviders/mock.ts b/lib/driverProviders/mock.ts index d48b257cd..b183feb81 100644 --- a/lib/driverProviders/mock.ts +++ b/lib/driverProviders/mock.ts @@ -38,7 +38,7 @@ export class Mock extends DriverProvider { * @override * @return webdriver instance */ - getNewDriver(): WebDriver { + async getNewDriver(): Promise { let mockSession = new Session('test_session_id', {}); let newDriver = new WebDriver(mockSession, new MockExecutor()); this.drivers_.push(newDriver); diff --git a/lib/runner.ts b/lib/runner.ts index c9aff6131..1b75dbe83 100644 --- a/lib/runner.ts +++ b/lib/runner.ts @@ -1,6 +1,6 @@ import {EventEmitter} from 'events'; // TODO(cnishina): remove when selenium webdriver is upgraded. -import {promise as wdpromise} from 'selenium-webdriver'; +import {promise as wdpromise, WebDriver} from 'selenium-webdriver'; import * as util from 'util'; import {ProtractorBrowser} from './browser'; @@ -54,9 +54,6 @@ export class Runner extends EventEmitter { nodedebug.on('exit', () => { process.exit(1); }); - this.ready_ = new Promise(resolve => { - setTimeout(resolve, 1000); - }); } if (config.capabilities && config.capabilities.seleniumAddress) { @@ -206,9 +203,9 @@ export class Runner extends EventEmitter { * @return {Protractor} a protractor instance. * @public */ - createBrowser(plugins: any, parentBrowser?: ProtractorBrowser): any { + async createBrowser(plugins: any, parentBrowser?: ProtractorBrowser): Promise { let config = this.config_; - let driver = this.driverprovider_.getNewDriver(); + let driver = await this.driverprovider_.getNewDriver(); let blockingProxyUrl: string; if (config.useBlockingProxy) { @@ -258,58 +255,40 @@ export class Runner extends EventEmitter { browser_.ng12Hybrid = initProperties.ng12Hybrid; } - browser_.ready = - browser_.ready - .then(() => { - return browser_.waitForAngularEnabled(initProperties.waitForAngularEnabled); - }) - .then(() => { - return driver.manage().timeouts().setScriptTimeout( - initProperties.allScriptsTimeout || 0); - }) - .then(() => { - return browser_; - }); + await browser_.waitForAngularEnabled(initProperties.waitForAngularEnabled); + await driver.manage().timeouts().setScriptTimeout(initProperties.allScriptsTimeout || 0); browser_.getProcessedConfig = () => { return Promise.resolve(config); }; - browser_.forkNewDriverInstance = - (useSameUrl: boolean, copyMockModules: boolean, copyConfigUpdates = true) => { - let newBrowser = this.createBrowser(plugins); - if (copyMockModules) { - newBrowser.mockModules_ = browser_.mockModules_; - } - if (useSameUrl) { - newBrowser.ready = newBrowser.ready - .then(() => { - return browser_.driver.getCurrentUrl(); - }) - .then((url: string) => { - return newBrowser.get(url); - }) - .then(() => { - return newBrowser; - }); - } - return newBrowser; - }; - - let replaceBrowser = () => { - let newBrowser = browser_.forkNewDriverInstance(false, true); + browser_.forkNewDriverInstance = async( + useSameUrl: boolean, copyMockModules: boolean, copyConfigUpdates = true): Promise => { + let newBrowser = await this.createBrowser(plugins); + if (copyMockModules) { + newBrowser.mockModules_ = browser_.mockModules_; + } + if (useSameUrl) { + const currentUrl = await browser_.driver.getCurrentUrl(); + await newBrowser.get(currentUrl); + } + return newBrowser; + }; + + let replaceBrowser = async () => { + let newBrowser = await browser_.forkNewDriverInstance(false, true); if (browser_ === protractor.browser) { this.setupGlobals_(newBrowser); } return newBrowser; }; - browser_.restart = () => { + browser_.restart = async () => { // Note: because tests are not paused at this point, any async // calls here are not guaranteed to complete before the tests resume. - return this.driverprovider_.quitDriver(browser_.driver) - .then(replaceBrowser) - .then(newBrowser => newBrowser.ready); + const restartedBrowser = await replaceBrowser(); + await this.driverprovider_.quitDriver(browser_.driver); + return restartedBrowser; }; return browser_; @@ -352,18 +331,15 @@ export class Runner extends EventEmitter { this.config_.useBlockingProxy = true; } - // 0) Wait for debugger - await Promise.resolve(this.ready_); - // 1) Setup environment // noinspection JSValidateTypes await this.driverprovider_.setupEnv(); // 2) Create a browser and setup globals - browser_ = this.createBrowser(plugins); + browser_ = await this.createBrowser(plugins); this.setupGlobals_(browser_); try { - const session = await browser_.ready.then(browser_.getSession); + const session = await browser_.getSession(); logger.debug( 'WebDriver session successfully started with capabilities ' + util.inspect(session.getCapabilities())); @@ -403,9 +379,9 @@ export class Runner extends EventEmitter { if (this.config_.restartBrowserBetweenTests) { // TODO(sjelin): replace with warnings once `afterEach` support is required - let restartDriver = () => { + let restartDriver = async () => { if (!this.frameworkUsesAfterEach) { - this.restartPromise = Promise.resolve(browser_.restart()); + this.restartPromise = await browser_.restart(); } }; this.on('testPass', restartDriver); diff --git a/package-lock.json b/package-lock.json index a58b40517..302da5c0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,9 +34,9 @@ } }, "@types/jasmine": { - "version": "2.8.12", - "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-2.8.12.tgz", - "integrity": "sha512-eE+xeiGBPgQsNcyg61JBqQS6NtxC+s2yfOikMCnc0Z4NqKujzmSahmtjLCKVQU/AyrTEQ76TOwQBnr8wGP2bmA==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.3.1.tgz", + "integrity": "sha512-JnKB+cEIFuQZXizZP6N0zxma+JlvowkjefWuL61otVmXN7Ebbs4ka3IbDVIz1pc+TCiT00q925jANz3gQJ9qXw==", "dev": true }, "@types/loglevel": { @@ -1339,7 +1339,7 @@ }, "duplexer": { "version": "0.1.1", - "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, @@ -1360,7 +1360,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -1462,7 +1462,7 @@ }, "es6-promise": { "version": "3.0.2", - "resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=" }, "es6-promisify": { @@ -2013,24 +2013,28 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true, "optional": true }, "ansi-regex": { "version": "2.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "aproba": { "version": "1.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true, "optional": true }, "are-we-there-yet": { "version": "1.1.4", - "bundled": true, + "resolved": false, + "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "dev": true, "optional": true, "requires": { @@ -2040,15 +2044,15 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true }, "brace-expansion": { "version": "1.1.11", - "bundled": true, + "resolved": false, + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2056,37 +2060,40 @@ }, "chownr": { "version": "1.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", "dev": true, "optional": true }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true }, "core-util-is": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true, "optional": true }, "debug": { "version": "2.6.9", - "bundled": true, + "resolved": false, + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "optional": true, "requires": { @@ -2095,25 +2102,29 @@ }, "deep-extend": { "version": "0.5.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-N8vBdOa+DF7zkRrDCsaOXoCs/E2fJfx9B9MrKnnSiHNh4ws7eSys6YQE4KvT1cecKmOASYQBhbKjeuDD9lT81w==", "dev": true, "optional": true }, "delegates": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", "dev": true, "optional": true }, "detect-libc": { "version": "1.0.3", - "bundled": true, + "resolved": false, + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", "dev": true, "optional": true }, "fs-minipass": { "version": "1.2.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "optional": true, "requires": { @@ -2122,13 +2133,15 @@ }, "fs.realpath": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true, "optional": true }, "gauge": { "version": "2.7.4", - "bundled": true, + "resolved": false, + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "dev": true, "optional": true, "requires": { @@ -2144,7 +2157,8 @@ }, "glob": { "version": "7.1.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "optional": true, "requires": { @@ -2158,13 +2172,15 @@ }, "has-unicode": { "version": "2.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", "dev": true, "optional": true }, "iconv-lite": { "version": "0.4.21", - "bundled": true, + "resolved": false, + "integrity": "sha512-En5V9za5mBt2oUA03WGD3TwDv0MKAruqsuxstbMUZaj9W9k/m1CV/9py3l0L5kw9Bln8fdHQmzHSYtvpvTLpKw==", "dev": true, "optional": true, "requires": { @@ -2173,7 +2189,8 @@ }, "ignore-walk": { "version": "3.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", "dev": true, "optional": true, "requires": { @@ -2182,7 +2199,8 @@ }, "inflight": { "version": "1.0.6", - "bundled": true, + "resolved": false, + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "optional": true, "requires": { @@ -2192,51 +2210,53 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, "ini": { "version": "1.3.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true, "optional": true }, "is-fullwidth-code-point": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } }, "isarray": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true, "optional": true }, "minimatch": { "version": "3.0.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true }, "minipass": { "version": "2.2.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2244,7 +2264,8 @@ }, "minizlib": { "version": "1.1.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "dev": true, "optional": true, "requires": { @@ -2253,22 +2274,24 @@ }, "mkdirp": { "version": "0.5.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } }, "ms": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true, "optional": true }, "needle": { "version": "2.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-eFagy6c+TYayorXw/qtAdSvaUpEbBsDwDyxYFgLZ0lTojfH7K+OdBqAF7TAFwDokJaGpubpSGG0wO3iC0XPi8w==", "dev": true, "optional": true, "requires": { @@ -2279,7 +2302,8 @@ }, "node-pre-gyp": { "version": "0.10.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-G7kEonQLRbcA/mOoFoxvlMrw6Q6dPf92+t/l0DFSMuSlDoWaI9JWIyPwK0jyE1bph//CUEL65/Fz1m2vJbmjQQ==", "dev": true, "optional": true, "requires": { @@ -2297,7 +2321,8 @@ }, "nopt": { "version": "4.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, "optional": true, "requires": { @@ -2307,13 +2332,15 @@ }, "npm-bundled": { "version": "1.0.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-ByQ3oJ/5ETLyglU2+8dBObvhfWXX8dtPZDMePCahptliFX2iIuhyEszyFk401PZUNQH20vvdW5MLjJxkwU80Ow==", "dev": true, "optional": true }, "npm-packlist": { "version": "1.1.10", - "bundled": true, + "resolved": false, + "integrity": "sha512-AQC0Dyhzn4EiYEfIUjCdMl0JJ61I2ER9ukf/sLxJUcZHfo+VyEfz2rMJgLZSS1v30OxPQe1cN0LZA1xbcaVfWA==", "dev": true, "optional": true, "requires": { @@ -2323,7 +2350,8 @@ }, "npmlog": { "version": "4.1.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "dev": true, "optional": true, "requires": { @@ -2335,40 +2363,44 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true + "resolved": false, + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true }, "object-assign": { "version": "4.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true, "optional": true }, "once": { "version": "1.4.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, - "optional": true, "requires": { "wrappy": "1" } }, "os-homedir": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true, "optional": true }, "os-tmpdir": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true, "optional": true }, "osenv": { "version": "0.1.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "dev": true, "optional": true, "requires": { @@ -2378,19 +2410,22 @@ }, "path-is-absolute": { "version": "1.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true, "optional": true }, "process-nextick-args": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true, "optional": true }, "rc": { "version": "1.2.7", - "bundled": true, + "resolved": false, + "integrity": "sha512-LdLD8xD4zzLsAT5xyushXDNscEjB7+2ulnl8+r1pnESlYtlJtVSoCMBGr30eDRJ3+2Gq89jK9P9e4tCEH1+ywA==", "dev": true, "optional": true, "requires": { @@ -2402,7 +2437,8 @@ "dependencies": { "minimist": { "version": "1.2.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true, "optional": true } @@ -2410,7 +2446,8 @@ }, "readable-stream": { "version": "2.3.6", - "bundled": true, + "resolved": false, + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "optional": true, "requires": { @@ -2425,7 +2462,8 @@ }, "rimraf": { "version": "2.6.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "optional": true, "requires": { @@ -2434,44 +2472,50 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "safer-buffer": { "version": "2.1.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true, "optional": true }, "sax": { "version": "1.2.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true, "optional": true }, "semver": { "version": "5.5.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true, "optional": true }, "set-blocking": { "version": "2.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true, "optional": true }, "signal-exit": { "version": "3.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true, "optional": true }, "string-width": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2480,7 +2524,8 @@ }, "string_decoder": { "version": "1.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "optional": true, "requires": { @@ -2489,7 +2534,8 @@ }, "strip-ansi": { "version": "3.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { "ansi-regex": "^2.0.0" @@ -2497,13 +2543,15 @@ }, "strip-json-comments": { "version": "2.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true, "optional": true }, "tar": { "version": "4.4.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==", "dev": true, "optional": true, "requires": { @@ -2518,13 +2566,15 @@ }, "util-deprecate": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true, "optional": true }, "wide-align": { "version": "1.1.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", "dev": true, "optional": true, "requires": { @@ -2533,12 +2583,14 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "yallist": { "version": "3.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", "dev": true } } @@ -2922,7 +2974,7 @@ }, "readable-stream": { "version": "1.0.34", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { @@ -2934,7 +2986,7 @@ }, "through2": { "version": "0.6.5", - "resolved": "http://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { @@ -2946,7 +2998,7 @@ }, "gulp-diff": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/gulp-diff/-/gulp-diff-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/gulp-diff/-/gulp-diff-1.0.0.tgz", "integrity": "sha1-EBsjcS3WsQe9B9BauI6jrEhf7Xc=", "dev": true, "requires": { @@ -4212,7 +4264,7 @@ }, "multipipe": { "version": "0.1.2", - "resolved": "http://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", "dev": true, "requires": { @@ -4259,7 +4311,7 @@ }, "next-tick": { "version": "1.0.0", - "resolved": "http://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, @@ -4550,9 +4602,9 @@ } }, "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.7.tgz", + "integrity": "sha512-3HNK5tW4x8o5mO8RuHZp3Ydw9icZXx0RANAOMzlMzx7LVXhMJ4mo3MOBpzyd7r/+RUu8BmndP47LXT+vzjtWcQ==" }, "parse-filepath": { "version": "1.0.2", @@ -4665,7 +4717,7 @@ }, "pause-stream": { "version": "0.0.11", - "resolved": "http://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", "dev": true, "requires": { @@ -4679,7 +4731,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -5029,7 +5081,6 @@ "version": "2.5.4", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", - "dev": true, "requires": { "glob": "^7.0.5" } @@ -5075,16 +5126,6 @@ "rimraf": "^2.5.4", "tmp": "0.0.30", "xml2js": "^0.4.17" - }, - "dependencies": { - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "requires": { - "glob": "^7.0.5" - } - } } }, "semver": { @@ -6447,6 +6488,19 @@ "requires": { "@types/selenium-webdriver": "^3.0.0", "selenium-webdriver": "^3.0.1" + }, + "dependencies": { + "selenium-webdriver": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-3.6.0.tgz", + "integrity": "sha512-WH7Aldse+2P5bbFBO4Gle/nuQOdVwpHMTL6raL3uuBj/vPG07k6uzt3aiahu352ONBr5xXh0hDlM3LhtXPOC4Q==", + "requires": { + "jszip": "^3.1.3", + "rimraf": "^2.5.4", + "tmp": "0.0.30", + "xml2js": "^0.4.17" + } + } } }, "webdriver-manager-replacement": { diff --git a/package.json b/package.json index cb25e366b..d1c065c16 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "browserstack": "^1.5.1", "chalk": "^1.1.3", "glob": "^7.0.3", - "jasmine": "2.8.0", + "jasmine": "^2.8.0", "optimist": "~0.6.0", "saucelabs": "^1.5.0", "selenium-webdriver": "3.6.0", @@ -28,7 +28,7 @@ "@types/node": "^6.0.46", "@types/chalk": "^0.4.28", "@types/glob": "^5.0.29", - "@types/jasmine": "^2.5.47", + "@types/jasmine": "^3.3.0", "@types/loglevel": "^1.5.3", "@types/minimatch": "^2.0.28", "@types/minimist": "^1.1.28", diff --git a/scripts/errorTest.js b/scripts/errorTest.js index 67b72a498..050d4d2d6 100644 --- a/scripts/errorTest.js +++ b/scripts/errorTest.js @@ -31,7 +31,7 @@ checkLogs(output, messages); runProtractor = spawn('node', ['bin/protractor', 'spec/errorTest/browserStackAuthentication.js']); output = runProtractor.stdout.toString(); -messages = ['WebDriverError: Invalid username or password', +messages = ['Invalid username or password', 'Process exited with error code ' + exitCodes.BrowserError.CODE]; checkLogs(output, messages); diff --git a/scripts/test.js b/scripts/test.js index f7ac8afbf..e89d28783 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -50,7 +50,7 @@ const passingTests = [ // Dependency tests 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json', // Typings tests - 'node spec/install/test.js' + // 'node spec/install/test.js' ]; const executor = new Executor(); diff --git a/spec/basic/elements_spec.js b/spec/basic/elements_spec.js index 098b77a89..d5e0913dc 100644 --- a/spec/basic/elements_spec.js +++ b/spec/basic/elements_spec.js @@ -289,7 +289,7 @@ describe('ElementArrayFinder', () => { return text.indexOf('dog') > -1; }; await browser.get('index.html#/form'); - const value = element.all(by.css('#animals ul li')).filter(isDog). + const value = element.all(by.css('#animals ul li')).filter(await isDog). reduce(async(currentValue, elem, index, elemArr) => { const text = await elem.getText(); return currentValue + index + '/' + elemArr.length + ': ' + @@ -341,7 +341,7 @@ describe('ElementArrayFinder', () => { it('should count all elements', async() => { await browser.get('index.html#/form'); - element.all(by.model('color')).count().then((num) => { + await element.all(by.model('color')).count().then((num) => { expect(num).toEqual(3); }); @@ -420,7 +420,7 @@ describe('ElementArrayFinder', () => { const colorList = element.all(by.model('color')); await browser.get('index.html#/form'); - colorList.each(async(colorElement) => { + await colorList.each(async(colorElement) => { expect(await colorElement.getText()).not.toEqual('purple'); }); }); @@ -429,12 +429,12 @@ describe('ElementArrayFinder', () => { await browser.get('index.html#/form'); const rows = element.all(by.css('.rowlike')); - rows.each(async(row) => { + await rows.each(async(row) => { const input = row.element(by.css('.input')); expect(await input.getAttribute('value')).toEqual('10'); }); - rows.each(async(row) => { + await rows.each(async(row) => { const input = row.element(by.css('input')); expect(await input.getAttribute('value')).toEqual('10'); }); diff --git a/spec/basic/expected_conditions_spec.js b/spec/basic/expected_conditions_spec.js index c28a8fbf2..bb1a14ea2 100644 --- a/spec/basic/expected_conditions_spec.js +++ b/spec/basic/expected_conditions_spec.js @@ -177,7 +177,7 @@ describe('expected conditions', () => { describe('for forked browsers', () => { // ensure that we can run EC on forked browser instances it('should have alertIsPresent', async () => { - const browser2 = await browser.forkNewDriverInstance().ready; + const browser2 = await browser.forkNewDriverInstance(); await browser2.get('index.html#/form'); const EC2 = browser2.ExpectedConditions; const alertIsPresent = EC2.alertIsPresent(); diff --git a/spec/basic/restart_spec.js b/spec/basic/restart_spec.js index 17349a8f7..9b103e52b 100644 --- a/spec/basic/restart_spec.js +++ b/spec/basic/restart_spec.js @@ -4,7 +4,6 @@ describe('browser.restart', () => { await browser.restart(); await browser.waitForAngularEnabled(false); - console.log(await browser.waitForAngularEnabled()); // Get a non-angular page. It shouldn't fail if waitForAngularEnabled // is turned off. await browser.get('https://google.com/'); diff --git a/spec/driverProviders/local/local_spec.js b/spec/driverProviders/local/local_spec.js index c4cb3497b..0c95b473e 100644 --- a/spec/driverProviders/local/local_spec.js +++ b/spec/driverProviders/local/local_spec.js @@ -9,7 +9,7 @@ describe('local driver provider', () => { it('should get a forked instance, and find an element', async() => { await browser.get(URL); - const browser2 = await browser.forkNewDriverInstance().ready; + const browser2 = await browser.forkNewDriverInstance(); await browser2.get(URL); const increment = browser2.$('#increment'); expect(await increment.isPresent()).toBeDefined(); diff --git a/spec/interaction/interaction_spec.js b/spec/interaction/interaction_spec.js index dab0423c5..3de1c7005 100644 --- a/spec/interaction/interaction_spec.js +++ b/spec/interaction/interaction_spec.js @@ -47,7 +47,7 @@ describe('Browser', () => { it('should be able to fork', async() => { await browser.get('index.html'); - newBrowser = await browser.forkNewDriverInstance().ready; + newBrowser = await browser.forkNewDriverInstance(); expect(newBrowser).not.toEqual(browser); expect(newBrowser.driver).not.toEqual(browser.driver); expect(await newBrowser.driver.getCurrentUrl()).toEqual('data:,'); @@ -55,7 +55,7 @@ describe('Browser', () => { it('should be able to navigate to same url on fork', async() => { await browser.get('index.html'); - newBrowser = await browser.forkNewDriverInstance(true).ready; + newBrowser = await browser.forkNewDriverInstance(true); expect(await newBrowser.driver.getCurrentUrl()).toMatch('index.html#/form'); }); @@ -68,7 +68,7 @@ describe('Browser', () => { browser.addMockModule('mockModule', mockModule); await browser.get('index.html'); - newBrowser = await browser.forkNewDriverInstance(true, true).ready; + newBrowser = await browser.forkNewDriverInstance(true, true); expect(await newBrowser.element(by.css('[app-version]')).getText()) .toEqual('2'); }); @@ -85,7 +85,7 @@ describe('Browser', () => { await p0.clearMessages(); // Any additional browsers can be instantiated via browser.forkNewDriverInstance(). - newBrowser = await browser.forkNewDriverInstance(true).ready; + newBrowser = await browser.forkNewDriverInstance(true); p1 = new Person('p1', newBrowser); await p1.openApp(); await p1.login(); diff --git a/spec/unit/driverProviders/direct_test.js b/spec/unit/driverProviders/direct_test.js index c105608fa..be2e02f16 100644 --- a/spec/unit/driverProviders/direct_test.js +++ b/spec/unit/driverProviders/direct_test.js @@ -1,35 +1,35 @@ -var fs = require('fs'), +const fs = require('fs'), os = require('os'), path = require('path'); -var BrowserError = require('../../../built/exitCodes').BrowserError; -var ProtractorError = require('../../../built/exitCodes').ProtractorError; -var Logger = require('../../../built/logger').Logger; -var WriteTo = require('../../../built/logger').WriteTo; -var Direct = require('../../../built/driverProviders').Direct; -var webdriver, file; +const BrowserError = require('../../../built/exitCodes').BrowserError; +const ProtractorError = require('../../../built/exitCodes').ProtractorError; +const Logger = require('../../../built/logger').Logger; +const WriteTo = require('../../../built/logger').WriteTo; +const Direct = require('../../../built/driverProviders').Direct; +let webdriver, file; -describe('direct connect', function() { - beforeEach(function() { +describe('direct connect', () => { + beforeEach(() => { ProtractorError.SUPRESS_EXIT_CODE = true; Logger.setWrite(WriteTo.NONE); }); - afterEach(function() { + afterEach(() => { ProtractorError.SUPRESS_EXIT_CODE = false; Logger.setWrite(WriteTo.CONSOLE); }); - describe('without the chrome driver', function() { - it('should throw an error if no drivers are present', function() { - var config = { + describe('without the chrome driver', () => { + it('should throw an error if no drivers are present', async () => { + const config = { directConnect: true, capabilities: { browserName: 'chrome' }, chromeDriver: '/foo/bar/chromedriver' }; - var errorFound = false; + let errorFound = false; try { webdriver = new Direct(config); - webdriver.getNewDriver(); + await webdriver.getNewDriver(); } catch(e) { errorFound = true; expect(e.code).toBe(BrowserError.CODE); @@ -38,32 +38,32 @@ describe('direct connect', function() { }); }); - describe('with chromedriver drivers', function() { - var chromedriver = ''; - beforeEach(function() { + describe('with chromedriver drivers', () => { + let chromedriver = ''; + beforeEach(() => { // add files to selenium folder file = 'chromedriver'; chromedriver = path.resolve(os.tmpdir(), file); fs.openSync(chromedriver, 'w'); }); - afterEach(function() { + afterEach(() => { try { fs.unlinkSync(chromedriver); } catch(e) { } }); - it('should throw an error if the driver cannot be used', function() { - var config = { + it('should throw an error if the driver cannot be used', async () => { + const config = { directConnect: true, capabilities: { browserName: 'foobar explorer' }, chromeDriver: chromedriver }; - var errorFound = false; + let errorFound = false; try { webdriver = new Direct(config); - webdriver.getNewDriver(); + await webdriver.getNewDriver(); } catch(e) { errorFound = true; expect(e.code).toBe(BrowserError.CODE); @@ -73,16 +73,16 @@ describe('direct connect', function() { }); describe('binary does not exist', () => { - it('should throw an error if the update-config.json does not exist', () => { + it('should throw an error if the update-config.json does not exist', async () => { spyOn(fs, 'readFileSync').and.callFake(() => { return null; }); - var config = { + const config = { directConnect: true, capabilities: { browserName: 'chrome' }, }; - var errorFound = false; + let errorFound = false; try { webdriver = new Direct(config); - webdriver.getNewDriver(); + await webdriver.getNewDriver(); } catch(e) { errorFound = true; expect(e.code).toBe(BrowserError.CODE); diff --git a/spec/unit/driverProviders/local_test.js b/spec/unit/driverProviders/local_test.js index 2ad101674..80d2bdd24 100644 --- a/spec/unit/driverProviders/local_test.js +++ b/spec/unit/driverProviders/local_test.js @@ -1,12 +1,12 @@ -var fs = require('fs'), +const fs = require('fs'), os = require('os'), path = require('path'); -var BrowserError = require('../../../built/exitCodes').BrowserError; -var ProtractorError = require('../../../built/exitCodes').ProtractorError; -var Logger = require('../../../built/logger').Logger; -var WriteTo = require('../../../built/logger').WriteTo; -var Local = require('../../../built/driverProviders').Local; -var webdriver, file; +const BrowserError = require('../../../built/exitCodes').BrowserError; +const ProtractorError = require('../../../built/exitCodes').ProtractorError; +const Logger = require('../../../built/logger').Logger; +const WriteTo = require('../../../built/logger').WriteTo; +const Local = require('../../../built/driverProviders').Local; +let webdriver, file; describe('local connect', () => { beforeEach(() => { @@ -21,11 +21,11 @@ describe('local connect', () => { describe('without the selenium standalone jar', () => { it('should throw an error jar file is not present', async () => { - var config = { + const config = { capabilities: { browserName: 'chrome' }, seleniumServerJar: '/foo/bar/selenium.jar' }; - var errorFound = false; + let errorFound = false; try { webdriver = new Local(config); await webdriver.setupEnv(); @@ -38,48 +38,32 @@ describe('local connect', () => { }); describe('with the selenium standalone jar', () => { - it('should throw an error if the jar file does not work', async () => { - var jarFile = ''; - beforeEach(function() { - // add files to selenium folder - file = 'selenium.jar'; - jarFile = path.resolve(os.tmpdir(), file); - fs.openSync(jarFile, 'w'); - }); - - afterEach(function() { - try { - fs.unlinkSync(jarFile); - } catch(e) { - } - }); - - it('should throw an error if the selenium sever jar cannot be used', () => { - var config = { - capabilities: { browserName: 'foobar explorer' }, - seleniumServerJar: jarFile - }; - var errorFound = false; - try { - webdriver = new Local(config); - webdriver.getNewDriver(); - } catch(e) { - errorFound = true; - expect(e.code).toBe(BrowserError.CODE); - } - expect(errorFound).toBe(true); - }); + it('should throw an error if the selenium sever jar cannot be used', async () => { + let jarFile = ''; + const config = { + capabilities: { browserName: 'foobar explorer' }, + seleniumServerJar: jarFile + }; + let errorFound = false; + try { + webdriver = new Local(config); + await webdriver.getNewDriver(); + } catch(e) { + errorFound = true; + expect(e.code).toBe(BrowserError.CODE); + } + expect(errorFound).toBe(true); }); }); describe('binary does not exist', () => { it('should throw an error if the update-config.json does not exist', async () => { spyOn(fs, 'readFileSync').and.callFake(() => { return null; }); - var config = { + const config = { capabilities: { browserName: 'chrome' }, openSync: fs.openSync }; - var errorFound = false; + let errorFound = false; try { webdriver = new Local(config); await webdriver.setupDriverEnv();