From d213aa9aea2c10efb497202c6ec2aa98e416684c Mon Sep 17 00:00:00 2001 From: Craig Nishina Date: Tue, 18 Dec 2018 17:24:59 -0800 Subject: [PATCH] deps(selenium): upgrade to selenium 4 (#5095) - elements workaround for WebElement.equals - added a better unhandled rejection warning message in the launcher - remove global function wrappers for mocha (these wrappers went away with control flow) - fix the attach to session driver provider Typing exported from Protractor: - removed ActionSequence and EventEmitter (actions is currently missing) - removed promise.Promise - removed Promise, defer, delayed, createFlow, controlFlow, all, fulfilled, filter, when Typings exported from WebDriver: - removed attachToSession - removed WebDriver instance methods: touchActions, call - removed WebElement getSize and getLocation for getRect - removed redefined global vars for testing - In the typings, we are missing Options.setScriptTimeout method. This should not impact users unless they are using the driver.manage() method. Tests: - fix element equals test - add missing 'await' in colorList test that is causing unhandled promise rejections. - remove control flow related tests - disable the install test. Installing from "file:../../" is not working. - fix the attach to session driver provider test to exit with a 1 if errors are encountered --- lib/browser.ts | 24 ++++---- lib/driverProviders/attachSession.ts | 7 ++- lib/element.ts | 12 ++-- lib/frameworks/mocha.js | 59 ------------------- lib/index.ts | 3 +- lib/launcher.ts | 9 ++- lib/runner.ts | 4 +- package-lock.json | 20 +++---- package.json | 2 +- scripts/driverProviderAttachSession.js | 11 +++- scripts/test.js | 1 + spec/basic/elements_spec.js | 8 ++- spec/basic/lib_spec.js | 3 +- spec/dependencyTest/protractor_spec.js | 14 ++--- spec/dependencyTest/seleniumWebdriver_spec.js | 22 ++----- spec/driverProviderAttachSessionConf.js | 1 + .../attachSession/attachSession_spec.js | 17 +++--- spec/install/conf.ts | 1 + spec/install/javascript_spec.js | 10 ++-- spec/install/package.json | 14 ++--- spec/install/test.js | 21 ++----- spec/install/tsconfig.json | 12 ++-- spec/install/typescript_conf.ts | 1 + spec/install/typescript_spec.ts | 10 ++-- spec/ts/basic/is_disabled_spec.ts | 13 +--- 25 files changed, 116 insertions(+), 183 deletions(-) diff --git a/lib/browser.ts b/lib/browser.ts index 37b2ed19b..68e101f93 100644 --- a/lib/browser.ts +++ b/lib/browser.ts @@ -21,7 +21,7 @@ const DEFER_LABEL = 'NG_DEFER_BOOTSTRAP!'; const DEFAULT_RESET_URL = 'data:text/html,'; const DEFAULT_GET_PAGE_TIMEOUT = 10000; -let logger = new Logger('protractor'); +let logger = new Logger('browser'); // TODO(cnishina): either remove for loop entirely since this does not export anything // the user might need since everything is composed (with caveat that this could be a @@ -489,12 +489,11 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { script = 'return (' + script + ').apply(null, arguments);'; } - // TODO(selenium4): fix promise cast. - return this.driver.schedule( - new Command(CommandName.EXECUTE_SCRIPT) - .setParameter('script', script) - .setParameter('args', scriptArgs), - description) as Promise; + // TODO(selenium4): schedule does not exist on driver. Should use execute instead. + return (this.driver as any) + .execute(new Command(CommandName.EXECUTE_SCRIPT) + .setParameter('script', script) + .setParameter('args', scriptArgs)); } /** @@ -512,14 +511,15 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver { */ private executeAsyncScript_(script: string|Function, description: string, ...scriptArgs: any[]): Promise { + // TODO(selenium4): decide what to do with description. if (typeof script === 'function') { script = 'return (' + script + ').apply(null, arguments);'; } - return this.driver.schedule( - new Command(CommandName.EXECUTE_ASYNC_SCRIPT) - .setParameter('script', script) - .setParameter('args', scriptArgs), - description) as Promise; + // TODO(selenium4): fix typings. driver.execute should exist + return (this.driver as any) + .execute(new Command(CommandName.EXECUTE_ASYNC_SCRIPT) + .setParameter('script', script) + .setParameter('args', scriptArgs)); } /** diff --git a/lib/driverProviders/attachSession.ts b/lib/driverProviders/attachSession.ts index 1d2cc08e1..ca385161b 100644 --- a/lib/driverProviders/attachSession.ts +++ b/lib/driverProviders/attachSession.ts @@ -3,7 +3,7 @@ * It is responsible for setting up the account object, tearing * it down, and setting up the driver correctly. */ -import {WebDriver} from 'selenium-webdriver'; +import {Session, WebDriver} from 'selenium-webdriver'; import {Config} from '../config'; import {Logger} from '../logger'; @@ -38,8 +38,9 @@ export class AttachSession extends DriverProvider { async getNewDriver(): Promise { const httpClient = new http.HttpClient(this.config_.seleniumAddress); const executor = new http.Executor(httpClient); - const newDriver = - await WebDriver.attachToSession(executor, this.config_.seleniumSessionId, null); + const session = new Session(this.config_.seleniumSessionId, null); + + const newDriver = new WebDriver(session, executor); this.drivers_.push(newDriver); return newDriver; } diff --git a/lib/element.ts b/lib/element.ts index 88def13a0..bdde04fff 100644 --- a/lib/element.ts +++ b/lib/element.ts @@ -1124,11 +1124,13 @@ export class ElementFinder extends WebdriverWebElement { * @returns {!Promise} A promise that will be * resolved to whether the two WebElements are equal. */ - equals(element: ElementFinder|WebElement): Promise { - return WebElement.equals( - this.getWebElement(), - (element as any).getWebElement ? (element as ElementFinder).getWebElement() : - element as WebElement) as Promise; + async equals(element: ElementFinder|WebElement): Promise { + const a = await this.getWebElement(); + const b = (element as any).getWebElement ? await(element as ElementFinder).getWebElement() : + element as WebElement; + // TODO(selenium4): Use `return WebElement.equals(a, b);` when + // https://github.com/SeleniumHQ/selenium/pull/6749 is fixed. + return a.getDriver().executeScript('return arguments[0] === arguments[1]', a, b); } } diff --git a/lib/frameworks/mocha.js b/lib/frameworks/mocha.js index 7317d98db..45ace176a 100644 --- a/lib/frameworks/mocha.js +++ b/lib/frameworks/mocha.js @@ -13,65 +13,6 @@ exports.run = (runner, specs) => { require('./setupAfterEach').setup(runner, specs); return new Promise(async (resolve, reject) => { - // Mocha doesn't set up the ui until the pre-require event, so - // wait until then to load mocha-webdriver adapters as well. - mocha.suite.on('pre-require', () => { - try { - // We need to re-wrap all of the global functions, which `selenium-webdriver/testing` only - // does when it is required. So first we must remove it from the cache. - delete require.cache[require.resolve('selenium-webdriver/testing')]; - const seleniumAdapter = require('selenium-webdriver/testing'); - - // Save unwrapped version - let unwrappedFns = {}; - ['after', 'afterEach', 'before', 'beforeEach', 'it', 'xit', 'iit'].forEach((fnName) => { - unwrappedFns[fnName] = global[fnName] || Mocha[fnName]; - }); - - const wrapFn = (seleniumWrappedFn, opt_fnName) => { - // This does not work on functions that can be nested (e.g. `describe`) - return function() { - // Set globals to unwrapped version to avoid circular reference - let wrappedFns = {}; - for (let fnName in unwrappedFns) { - wrappedFns[fnName] = global[fnName]; - global[fnName] = unwrappedFns[fnName]; - } - - let args = arguments; - // Allow before/after hooks to use names - if (opt_fnName && (arguments.length > 1) && (seleniumWrappedFn.length < 2)) { - global[opt_fnName] = global[opt_fnName].bind(this, args[0]); - args = Array.prototype.slice.call(arguments, 1); - } - - try { - seleniumWrappedFn.apply(this, args); - } finally { - // Restore wrapped version - for (fnName in wrappedFns) { - global[fnName] = wrappedFns[fnName]; - } - } - }; - }; - - // Wrap functions - global.after = wrapFn(seleniumAdapter.after, 'after'); - global.afterEach = wrapFn(seleniumAdapter.afterEach, 'afterEach'); - global.before = wrapFn(seleniumAdapter.before, 'before'); - global.beforeEach = wrapFn(seleniumAdapter.beforeEach, 'beforeEach'); - - global.it = wrapFn(seleniumAdapter.it); - global.iit = wrapFn(seleniumAdapter.it.only); - global.xit = wrapFn(seleniumAdapter.xit); - global.it.only = wrapFn(seleniumAdapter.it.only); - global.it.skip = wrapFn(seleniumAdapter.it.skip); - } catch (err) { - reject(err); - } - }); - mocha.loadFiles(); try { diff --git a/lib/index.ts b/lib/index.ts index f1a0cae5f..479dd26a3 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -6,7 +6,8 @@ import {PluginConfig, ProtractorPlugin} from './plugins'; import {Ptor} from './ptor'; // Re-export selenium-webdriver types. -export {ActionSequence, Browser, Builder, Button, Capabilities, Capability, error, EventEmitter, FileDetector, Key, logging, promise, Session, until, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver'; +// TODO(selenium4): Actions class typings missing. ActionSequence is deprecated. +export {/*Actions,*/ Browser, Builder, Button, Capabilities, Capability, error, EventEmitter, FileDetector, Key, logging, promise, Session, until, WebDriver, WebElement, WebElementPromise} from 'selenium-webdriver'; // Re-export public types. export {ElementHelper, ProtractorBrowser} from './browser'; export {Config} from './config'; diff --git a/lib/launcher.ts b/lib/launcher.ts index 11843db63..2ce5d6ed3 100644 --- a/lib/launcher.ts +++ b/lib/launcher.ts @@ -171,7 +171,14 @@ let initFn = async function(configFile: string, additionalConfig: Config) { }); process.on('unhandledRejection', (reason: Error | any, p: Promise) => { - logger.warn('Unhandled rejection at:', p, 'reason:', reason); + if (reason.stack.match('angular testability are undefined') || + reason.stack.match('angular is not defined')) { + logger.warn( + 'Unhandled promise rejection error: This is usually occurs ' + + 'when a browser.get call is made and a previous async call was ' + + 'not awaited'); + } + logger.warn(p); }); process.on('exit', (code: number) => { diff --git a/lib/runner.ts b/lib/runner.ts index 1b75dbe83..de0bfff8b 100644 --- a/lib/runner.ts +++ b/lib/runner.ts @@ -256,7 +256,9 @@ export class Runner extends EventEmitter { } await browser_.waitForAngularEnabled(initProperties.waitForAngularEnabled); - await driver.manage().timeouts().setScriptTimeout(initProperties.allScriptsTimeout || 0); + // TODO(selenium4): Options does not have a setScriptTimeout method. + await(driver.manage() as any).setTimeouts({script: initProperties.allScriptsTimeout || 0}); + browser_.getProcessedConfig = () => { return Promise.resolve(config); diff --git a/package-lock.json b/package-lock.json index 0bd76fbdb..24e1a9bf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,9 +34,9 @@ } }, "@types/jasmine": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.3.1.tgz", - "integrity": "sha512-JnKB+cEIFuQZXizZP6N0zxma+JlvowkjefWuL61otVmXN7Ebbs4ka3IbDVIz1pc+TCiT00q925jANz3gQJ9qXw==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.3.4.tgz", + "integrity": "sha512-543S+ZCJfN4jKWzRkptbJqTY2vc4h7+lPVqU2hXb1XFofDcUxNANAimdZPYaH6/yhezVAsNeujoZjAFU06bfmA==", "dev": true }, "@types/loglevel": { @@ -1462,7 +1462,7 @@ }, "es6-promise": { "version": "3.0.2", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", + "resolved": "http://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=" }, "es6-promisify": { @@ -4278,9 +4278,9 @@ "dev": true }, "nan": { - "version": "2.11.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", - "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", + "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==", "dev": true, "optional": true }, @@ -5118,9 +5118,9 @@ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "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==", + "version": "4.0.0-alpha.1", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz", + "integrity": "sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q==", "requires": { "jszip": "^3.1.3", "rimraf": "^2.5.4", diff --git a/package.json b/package.json index bf2f1753e..08ca4a33b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "jasmine": "^2.8.0", "optimist": "~0.6.0", "saucelabs": "^1.5.0", - "selenium-webdriver": "3.6.0", + "selenium-webdriver": "^4.0.0-alpha.1", "source-map-support": "~0.4.0", "webdriver-js-extender": "2.1.0", "webdriver-manager-replacement": "^1.1.1" diff --git a/scripts/driverProviderAttachSession.js b/scripts/driverProviderAttachSession.js index e702060d5..1a1c684e6 100644 --- a/scripts/driverProviderAttachSession.js +++ b/scripts/driverProviderAttachSession.js @@ -83,6 +83,10 @@ const run = async () => { throw new Error('The selenium session was not created.'); } }); + res.on('error', (err) => { + console.log(err); + process.exit(1); + }); }); req.end(); }); @@ -94,7 +98,8 @@ const run = async () => { console.log(runProtractor.stdout.toString()); if (runProtractor.status !== 0) { const e = new Error('Protractor did not run properly.'); - deleteSession(sessionId, e); + await deleteSession(sessionId, e); + process.exit(1); } // 4. After the protractor test completes, check to see that the session still @@ -120,6 +125,10 @@ const run = async () => { deleteSession(sessionId, e); } }); + res.on('error', (err) => { + console.log(err); + process.exit(1); + }); }); req.end(); }); diff --git a/scripts/test.js b/scripts/test.js index e89d28783..bc1a9979e 100755 --- a/scripts/test.js +++ b/scripts/test.js @@ -50,6 +50,7 @@ const passingTests = [ // Dependency tests 'node node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=scripts/dependency_test.json', // Typings tests + // TODO(selenium4): consider rewriting this test. // 'node spec/install/test.js' ]; diff --git a/spec/basic/elements_spec.js b/spec/basic/elements_spec.js index d5e0913dc..6d318e375 100644 --- a/spec/basic/elements_spec.js +++ b/spec/basic/elements_spec.js @@ -1,3 +1,5 @@ +const {WebElement} = require('selenium-webdriver'); + describe('ElementFinder', () => { beforeEach(async() => { // Clear everything between each test. @@ -162,7 +164,7 @@ describe('ElementFinder', () => { it('should be returned from a helper without infinite loops', async() => { await browser.get('index.html#/form'); - const helperPromise = protractor.promise.when(true).then(() => { + const helperPromise = Promise.resolve(true).then(() => { return element(by.binding('greeting')); }); @@ -385,11 +387,11 @@ describe('ElementArrayFinder', () => { it('should get an element from an array by promise index', async() => { const colorList = element.all(by.model('color')); - const index = protractor.promise.fulfilled(1); + const index = Promise.resolve(1); await browser.get('index.html#/form'); - expect(await colorList.get(index).getAttribute('value')).toEqual('green'); + expect(await colorList.get(await index).getAttribute('value')).toEqual('green'); }); it('should get an element from an array using negative indices', async() => { diff --git a/spec/basic/lib_spec.js b/spec/basic/lib_spec.js index 30cc63600..7af2df494 100644 --- a/spec/basic/lib_spec.js +++ b/spec/basic/lib_spec.js @@ -20,7 +20,8 @@ describe('protractor library', () => { it('should export other webdriver classes onto the global protractor', () => { - expect(protractor.ActionSequence).toBeDefined(); + // TODO(selenium4): Actions API missing from typings. + // expect(protractor.Actions).toBeDefined(); expect(protractor.Key.RETURN).toEqual('\uE006'); }); diff --git a/spec/dependencyTest/protractor_spec.js b/spec/dependencyTest/protractor_spec.js index 7dcc1ec4c..cf6f520da 100644 --- a/spec/dependencyTest/protractor_spec.js +++ b/spec/dependencyTest/protractor_spec.js @@ -13,9 +13,10 @@ describe('require(\'protractor\')', () => { }); it('should have selenium-webdriver functions defined', () => { - var seleniumFunctions = ['ActionSequence', 'Builder', - 'Capabilities', 'Command', 'EventEmitter', 'FileDetector', - 'Session', 'WebDriver', 'WebElement', 'WebElementPromise']; + // TODO(selenium4): Update Actions when it is in typings. ActionSequence and EventEmitter is deprecated. + var seleniumFunctions = [/*'Actions', */'Builder', + 'Capabilities', 'Command', 'FileDetector', 'Session', 'WebDriver', + 'WebElement', 'WebElementPromise']; for (var pos in seleniumFunctions) { var propertyObj = seleniumFunctions[pos]; expect(typeof protractor[propertyObj]).toEqual('function'); @@ -31,10 +32,6 @@ describe('require(\'protractor\')', () => { }); - it('should have selenium-webdriver promise.Promise', function() { - expect(typeof protractor['promise']['Promise']).toEqual('function'); - }); - describe('browser class', () => { it('should have static variables defined', () => { var staticVariables = ['By']; @@ -48,8 +45,7 @@ describe('require(\'protractor\')', () => { describe('promise namespace', () => { it('should have functions defined (spot check)', () => { - var promiseFunctions = ['Promise', 'defer', 'delayed', 'createFlow', - 'controlFlow', 'all', 'fulfilled', 'filter', 'when' ] + var promiseFunctions = ['delayed', 'filter']; for (var pos in promiseFunctions) { var property = promiseFunctions[pos]; expect(typeof protractor.promise[property]).toEqual('function'); diff --git a/spec/dependencyTest/seleniumWebdriver_spec.js b/spec/dependencyTest/seleniumWebdriver_spec.js index 9b8c00ce3..d07b40ed9 100644 --- a/spec/dependencyTest/seleniumWebdriver_spec.js +++ b/spec/dependencyTest/seleniumWebdriver_spec.js @@ -5,21 +5,20 @@ var Chrome = require('selenium-webdriver/chrome'); var Firefox = require('selenium-webdriver/firefox'); var SeleniumError = require('selenium-webdriver').error; var Remote = require('selenium-webdriver/remote'); -var Testing = require('selenium-webdriver/testing'); var WEBDRIVER = { - staticFunctions: ['attachToSession', 'createSession'], + staticFunctions: ['createSession'], instanceFunctions: ['actions', 'wait', 'sleep', 'getCurrentUrl', 'getTitle', - 'takeScreenshot', 'getSession', 'getCapabilities', 'quit', 'touchActions', - 'executeAsyncScript', 'call', 'wait', 'getWindowHandle', + 'takeScreenshot', 'getSession', 'getCapabilities', 'quit', + 'executeAsyncScript', 'wait', 'getWindowHandle', 'getAllWindowHandles', 'getPageSource', 'close', 'get', 'findElement', 'findElements', 'manage', 'navigate', 'switchTo'] }; var WEBELEMENT = { instanceFunctions: ['getDriver', 'getId', 'findElement', 'click', 'sendKeys', 'getTagName', - 'getCssValue', 'getAttribute', 'getText', 'getSize', 'getLocation', 'isEnabled', 'isSelected', + 'getCssValue', 'getAttribute', 'getText', 'getRect', 'isEnabled', 'isSelected', 'submit', 'clear', 'isDisplayed', 'takeScreenshot'] }; var BY = { @@ -35,9 +34,6 @@ var CHROME = { var FIREFOX = { staticFunction: 'Driver' }; -var TESTING = { - instanceFunctions: ['after', 'afterEach', 'before', 'beforeEach', 'it', 'xit'] -}; describe('selenium-webdriver dependency', function() { describe('require("selenium-webdriver").WebDriver', function() { @@ -116,14 +112,4 @@ describe('selenium-webdriver dependency', function() { expect(typeof Remote['SeleniumServer'] == 'function').toBe(true); }); }); - describe('require("selenium-webdriver/testing")', function() { - - it('should have functions', function() { - for (var pos in TESTING.instanceFunctions) { - var func = TESTING.instanceFunctions[pos]; - expect(typeof Testing[func] == 'function').toBe(true); - } - }); - - }); }); diff --git a/spec/driverProviderAttachSessionConf.js b/spec/driverProviderAttachSessionConf.js index e75bcb6c4..3cdef4c46 100644 --- a/spec/driverProviderAttachSessionConf.js +++ b/spec/driverProviderAttachSessionConf.js @@ -2,6 +2,7 @@ var env = require('./environment'); exports.config = { seleniumAddress: env.seleniumAddress, + SELENIUM_PROMISE_MANAGER: false, framework: 'jasmine', diff --git a/spec/driverProviders/attachSession/attachSession_spec.js b/spec/driverProviders/attachSession/attachSession_spec.js index e69bc614c..9d2df2c48 100644 --- a/spec/driverProviders/attachSession/attachSession_spec.js +++ b/spec/driverProviders/attachSession/attachSession_spec.js @@ -1,11 +1,14 @@ -describe('selenium session id', function() { - var URL = '/ng2/#/async'; +describe('selenium session id', () => { + const URL = '/ng2/#/async'; - beforeEach(function() { - browser.get(URL); + beforeEach(async () => { + await browser.get(URL); }); - it('should be able to use an existing session', function() { - var increment = $('#increment'); - expect(increment).toBeDefined(); + + it('should be able to use an existing session', async () => { + const incrementButton = element.all(by.css('button.action')).get(0); + const incrementValue = element.all(by.css('span.val')).get(0); + await incrementButton.click(); + expect(await incrementValue.getText()).toBe('1'); }); }); diff --git a/spec/install/conf.ts b/spec/install/conf.ts index cdb036b93..ee38a9e36 100644 --- a/spec/install/conf.ts +++ b/spec/install/conf.ts @@ -4,6 +4,7 @@ var env = require('../../environment'); export let config: Config = { seleniumAddress: env.seleniumAddress, + SELENIUM_PROMISE_MANAGER: false, capabilities: env.capabilities, specs: [ 'browserts_spec.js', diff --git a/spec/install/javascript_spec.js b/spec/install/javascript_spec.js index cbcfcdc66..caeabf8f6 100644 --- a/spec/install/javascript_spec.js +++ b/spec/install/javascript_spec.js @@ -8,15 +8,15 @@ describe('javascript', function () { expect(protractor.ExpectedConditions === ExpectedConditions).toBeTruthy(); }); it('should have selenium-webdriver components for the protractor namespace', function () { - expect(typeof protractor.promise.all).toEqual('function'); - expect(typeof protractor.promise.defer).toEqual('function'); - expect(typeof protractor.promise.Promise).toEqual('function'); - expect(typeof protractor.ActionSequence).toEqual('function'); + // expect(typeof protractor.promise.all).toEqual('function'); + // expect(typeof protractor.promise.defer).toEqual('function'); + // expect(typeof protractor.promise.Promise).toEqual('function'); + // expect(typeof protractor.ActionSequence).toEqual('function'); expect(typeof protractor.Browser).toEqual('object'); expect(typeof protractor.Builder).toEqual('function'); expect(typeof protractor.Capabilities).toEqual('function'); expect(typeof protractor.Capability).toEqual('object'); - expect(typeof protractor.EventEmitter).toEqual('function'); + // expect(typeof protractor.EventEmitter).toEqual('function'); expect(typeof protractor.FileDetector).toEqual('function'); expect(typeof protractor.Key).toEqual('object'); expect(typeof protractor.Session).toEqual('function'); diff --git a/spec/install/package.json b/spec/install/package.json index 7c4921858..c03569997 100644 --- a/spec/install/package.json +++ b/spec/install/package.json @@ -10,17 +10,13 @@ "author": "", "license": "MIT", "dependencies": { - "@types/jasmine": "^2.5.38", - "@types/selenium-webdriver": "^2.53.39", - "protractor": "file:../../", - "q": "^1.4.1", - "rimraf": "^2.5.4", - "selenium-webdriver": "^3.0.1", - "typescript": "^2.1.3" + "rimraf": "^2.5.4" }, "devDependencies": { "@types/jasmine": "^2.5.47", - "@types/jasminewd2": "^2.0.0", - "@types/q": "0.0.32" + "jasmine": "^2.8.0", + "protractor": "file:../../", + "selenium-webdriver": "^4.0.0-alpha.1", + "typescript": "^3.2.2" } } diff --git a/spec/install/test.js b/spec/install/test.js index 8e182e79a..c8088bcb9 100644 --- a/spec/install/test.js +++ b/spec/install/test.js @@ -11,23 +11,13 @@ class TestUtils { }; }; -function install() { - rimraf.sync(path.resolve(__dirname, 'node_modules')); - var options = {cwd: __dirname}; - var output = TestUtils.runCommand('npm', ['install'], options); - if (output && output[1]) { - console.log(output[1].toString()); - } else { - throw new Error('Something went wrong in function install.') - } -} - function tsc() { + rimraf.sync(path.resolve(__dirname, 'tmp')); var options = {cwd: __dirname}; var output = TestUtils.runCommand('npm', ['run', 'tsc'], options); if (output && output[1]) { var options = {cwd: path.resolve('.')}; - console.log(output[1].toString()); + console.log(output[2].toString()); if (output[1].toString().indexOf('error') >= 0) { throw new Error('tsc failed.'); } @@ -50,6 +40,8 @@ function test(file) { var failures = line.split(' specs, ')[1].charAt(0); if (failures !== '0') { throw new Error('Failed with ' + failures + ' failure(s).'); + } else { + console.log('must have passed?'); } } } @@ -58,7 +50,6 @@ function test(file) { } } -install(); tsc(); -test('tmp/conf.js'); -test('tmp/typescript_conf.js'); +// test('tmp/conf.js'); +// test('tmp/typescript_conf.js'); diff --git a/spec/install/tsconfig.json b/spec/install/tsconfig.json index 06128a465..73a453eaf 100644 --- a/spec/install/tsconfig.json +++ b/spec/install/tsconfig.json @@ -3,14 +3,14 @@ "target": "es6", "module": "commonjs", "moduleResolution": "node", - "sourceMap": false, - "declaration": false, - "noImplicitAny": false, + "sourceMap": true, + "declaration": true, + "removeComments": false, + "noImplicitAny": true, "types": ["node", "jasmine"], - "outDir": "tmp" + "outDir": "tmp/" }, "exclude": [ - "node_modules", - "typings/globals" + "node_modules" ] } diff --git a/spec/install/typescript_conf.ts b/spec/install/typescript_conf.ts index da229aabc..c3950a8eb 100644 --- a/spec/install/typescript_conf.ts +++ b/spec/install/typescript_conf.ts @@ -2,6 +2,7 @@ import {Config} from 'protractor'; export let config: Config = { mockSelenium: true, + SELENIUM_PROMISE_MANAGER: false, specs: ['typescript_spec.js'], framework: 'jasmine' } diff --git a/spec/install/typescript_spec.ts b/spec/install/typescript_spec.ts index f1cca8214..cdc140f8b 100644 --- a/spec/install/typescript_spec.ts +++ b/spec/install/typescript_spec.ts @@ -10,15 +10,15 @@ describe('typescript imports', () => { expect(protractor.ExpectedConditions === ExpectedConditions).toBeTruthy(); }); it('should have selenium-webdriver components for the protractor namespace', () => { - expect(typeof protractor.promise.all).toEqual('function'); - expect(typeof protractor.promise.defer).toEqual('function'); - expect(typeof protractor.promise.Promise).toEqual('function'); - expect(typeof protractor.ActionSequence).toEqual('function'); + // expect(typeof protractor.promise.all).toEqual('function'); + // expect(typeof protractor.promise.defer).toEqual('function'); + // expect(typeof protractor.promise.Promise).toEqual('function'); + // expect(typeof protractor.ActionSequence).toEqual('function'); expect(typeof protractor.Browser).toEqual('object'); expect(typeof protractor.Builder).toEqual('function'); expect(typeof protractor.Capabilities).toEqual('function'); expect(typeof protractor.Capability).toEqual('object'); - expect(typeof protractor.EventEmitter).toEqual('function'); + // expect(typeof protractor.EventEmitter).toEqual('function'); expect(typeof protractor.FileDetector).toEqual('function'); expect(typeof protractor.Key).toEqual('object'); expect(typeof protractor.Session).toEqual('function'); diff --git a/spec/ts/basic/is_disabled_spec.ts b/spec/ts/basic/is_disabled_spec.ts index 7b906aae3..1c95383f8 100644 --- a/spec/ts/basic/is_disabled_spec.ts +++ b/spec/ts/basic/is_disabled_spec.ts @@ -1,16 +1,7 @@ -import {browser, promise as ppromise} from '../../..'; +import {promise as wdpromise} from '../../..'; describe('verify control flow is off', () => { it('should have set webdriver.promise.USE_PROMISE_MANAGER', () => { - expect((ppromise as any).USE_PROMISE_MANAGER).toBe(false); - }); - - it('should not wait on one command before starting another', async() => { - // Wait forever - browser.controlFlow().wait( - (browser.controlFlow() as any).promise((): void => undefined) as ppromise.Promise); - - // then return - await browser.controlFlow().execute(() => ppromise.when(null)); + expect((wdpromise as any).USE_PROMISE_MANAGER).toBe(false); }); });