From b142be9fa0abc76e51900502d5dd6d127b3a7eed Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Tue, 28 Feb 2023 08:28:43 -0700 Subject: [PATCH] chore(ci,webdriverjs): update selenium-webdriver to latest (#673) * chore(ci): update selenium-webdriver to latest * fix tests * udpate webdriverjs --- packages/cli/package-lock.json | 52 +++++++++++++------------- packages/cli/package.json | 2 +- packages/cli/src/lib/webdriver.test.ts | 31 ++++++++------- packages/cli/src/lib/webdriver.ts | 10 ++--- packages/webdriverjs/package-lock.json | 34 ++++++++--------- packages/webdriverjs/package.json | 2 +- 6 files changed, 65 insertions(+), 66 deletions(-) diff --git a/packages/cli/package-lock.json b/packages/cli/package-lock.json index e7ddc40048..689af6ecae 100644 --- a/packages/cli/package-lock.json +++ b/packages/cli/package-lock.json @@ -9,12 +9,12 @@ "version": "4.6.0", "license": "MPL-2.0", "dependencies": { - "@axe-core/webdriverjs": "^4.5.2", + "@axe-core/webdriverjs": "^4.6.0", "axe-core": "^4.6.1", "chromedriver": "^109.0.0", "colors": "^1.4.0", "commander": "^9.4.1", - "selenium-webdriver": "4.3.0" + "selenium-webdriver": "^4.8.1" }, "bin": { "axe": "dist/src/bin/cli.js" @@ -53,11 +53,11 @@ } }, "node_modules/@axe-core/webdriverjs": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/@axe-core/webdriverjs/-/webdriverjs-4.5.2.tgz", - "integrity": "sha512-7OvK9y6vn4VEGiwosyQd0O14YWaDCIvrVDlDG8bbUauFS6jncZin0rVmuwrPWt40SpHY/uxJypfZgPJcENHuPw==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@axe-core/webdriverjs/-/webdriverjs-4.6.0.tgz", + "integrity": "sha512-Xs88fPiqCK5rBtDWVAWYoKwKHNcyfjXk5HO/hYZtDz4weyOsMq4ENsXRWGGOaq93+994h5/DdkrdbNIRbP1iZQ==", "dependencies": { - "axe-core": "^4.5.2" + "axe-core": "^4.6.1" }, "peerDependencies": { "selenium-webdriver": ">3.0.0-beta || >=2.53.1 || >4.0.0-alpha" @@ -3106,16 +3106,16 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/selenium-webdriver": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.3.0.tgz", - "integrity": "sha512-9XFr8w95BO7jageR61AtiB83fJNem3fdtOQcUpqIIDHWSxihomyG/yBlL1H4y/shi/dO/Ai3PJMAOG+OW3+JHw==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.8.1.tgz", + "integrity": "sha512-p4MtfhCQdcV6xxkS7eI0tQN6+WNReRULLCAuT4RDGkrjfObBNXMJ3WT8XdK+aXTr5nnBKuh+PxIevM0EjJgkxA==", "dependencies": { "jszip": "^3.10.0", "tmp": "^0.2.1", - "ws": ">=8.7.0" + "ws": ">=8.11.0" }, "engines": { - "node": ">= 10.15.0" + "node": ">= 14.20.0" } }, "node_modules/semver": { @@ -3601,15 +3601,15 @@ } }, "node_modules/ws": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz", - "integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -3714,11 +3714,11 @@ } }, "@axe-core/webdriverjs": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/@axe-core/webdriverjs/-/webdriverjs-4.5.2.tgz", - "integrity": "sha512-7OvK9y6vn4VEGiwosyQd0O14YWaDCIvrVDlDG8bbUauFS6jncZin0rVmuwrPWt40SpHY/uxJypfZgPJcENHuPw==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@axe-core/webdriverjs/-/webdriverjs-4.6.0.tgz", + "integrity": "sha512-Xs88fPiqCK5rBtDWVAWYoKwKHNcyfjXk5HO/hYZtDz4weyOsMq4ENsXRWGGOaq93+994h5/DdkrdbNIRbP1iZQ==", "requires": { - "axe-core": "^4.5.2" + "axe-core": "^4.6.1" } }, "@babel/code-frame": { @@ -5990,13 +5990,13 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "selenium-webdriver": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.3.0.tgz", - "integrity": "sha512-9XFr8w95BO7jageR61AtiB83fJNem3fdtOQcUpqIIDHWSxihomyG/yBlL1H4y/shi/dO/Ai3PJMAOG+OW3+JHw==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.8.1.tgz", + "integrity": "sha512-p4MtfhCQdcV6xxkS7eI0tQN6+WNReRULLCAuT4RDGkrjfObBNXMJ3WT8XdK+aXTr5nnBKuh+PxIevM0EjJgkxA==", "requires": { "jszip": "^3.10.0", "tmp": "^0.2.1", - "ws": ">=8.7.0" + "ws": ">=8.11.0" } }, "semver": { @@ -6345,9 +6345,9 @@ } }, "ws": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz", - "integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "requires": {} }, "y18n": { diff --git a/packages/cli/package.json b/packages/cli/package.json index cb99d2bca4..97c15a566f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -49,7 +49,7 @@ "chromedriver": "^109.0.0", "colors": "^1.4.0", "commander": "^9.4.1", - "selenium-webdriver": "4.3.0" + "selenium-webdriver": "^4.8.1" }, "devDependencies": { "@types/chai": "^4.3.3", diff --git a/packages/cli/src/lib/webdriver.test.ts b/packages/cli/src/lib/webdriver.test.ts index 1d754e9da7..83b1754fb5 100644 --- a/packages/cli/src/lib/webdriver.test.ts +++ b/packages/cli/src/lib/webdriver.test.ts @@ -1,6 +1,7 @@ import 'mocha'; import { assert } from 'chai'; import { startDriver } from './webdriver'; +import { WebDriver } from 'selenium-webdriver'; import chromedriver from 'chromedriver'; import chrome from 'selenium-webdriver/chrome'; import type { Options } from 'selenium-webdriver/chrome'; @@ -9,6 +10,7 @@ import { WebdriverConfigParams } from '../types'; describe('startDriver', () => { let config: WebdriverConfigParams; let browser: string; + let driver: WebDriver; beforeEach(() => { browser = 'chrome-headless'; config = { @@ -19,28 +21,25 @@ describe('startDriver', () => { }); afterEach(async () => { - const service = chrome.getDefaultService(); - if (service.isRunning()) { - await service.kill(); - } + await driver.quit(); }); it('creates a driver', async () => { - const driver = await startDriver(config); + driver = await startDriver(config); assert.isObject(driver); assert.isFunction(driver.manage); }); xit('sets the config.browser as the browser', async () => { browser = 'chrome'; - const driver = await startDriver(config); + driver = await startDriver(config); const capabilities = await driver.getCapabilities(); assert.equal(capabilities.get('browserName'), browser); }); it('sets the browser as chrome with chrome-headless', async () => { browser = 'chrome-headless'; - const driver = await startDriver(config); + driver = await startDriver(config); const capabilities = await driver.getCapabilities(); assert.equal(capabilities.get('browserName'), 'chrome'); @@ -48,26 +47,26 @@ describe('startDriver', () => { it('uses the chromedriver path with chrome-headless', async () => { browser = 'chrome-headless'; - await startDriver(config); - const service = chrome.getDefaultService(); + driver = await startDriver(config); + const chromedriverPath = (config as any).builder.chromeService_.exe_; - assert.equal((service as any).executable_, chromedriver.path); + assert.equal(chromedriverPath, chromedriver.path); }); it('uses the passed in chromedriver path with chrome-headless', async () => { browser = 'chrome-headless'; config.chromedriverPath = path.relative(process.cwd(), chromedriver.path); - await startDriver(config); - const service = chrome.getDefaultService(); + driver = await startDriver(config); + const chromedriverPath = (config as any).builder.chromeService_.exe_; assert.notEqual(config.chromedriverPath, chromedriver.path); - assert.equal((service as any).executable_, config.chromedriverPath); + assert.equal(chromedriverPath, config.chromedriverPath); }); it('passes the --no-sandbox argument to chromeOptions', async () => { browser = 'chrome-headless'; config.chromeOptions = ['--no-sandbox']; - await startDriver(config); + driver = await startDriver(config); const options = config?.builder?.getChromeOptions(); assert.isArray(options?.get('goog:chromeOptions').args); @@ -80,7 +79,7 @@ describe('startDriver', () => { it('passes multiple arguments argument to chromeOptions', async () => { browser = 'chrome-headless'; config.chromeOptions = ['no-sandbox', 'disable-dev-shm-usage']; - await startDriver(config); + driver = await startDriver(config); const options = config?.builder?.getChromeOptions(); assert.isArray(options?.get('goog:chromeOptions').args); @@ -94,7 +93,7 @@ describe('startDriver', () => { it('sets the --timeout flag', async () => { browser = 'chrome-headless'; config.timeout = 10000; - const driver = await startDriver(config); + driver = await startDriver(config); config.builder; const timeoutValue = await driver.manage().getTimeouts(); diff --git a/packages/cli/src/lib/webdriver.ts b/packages/cli/src/lib/webdriver.ts index 1407772baf..c41c1cba36 100644 --- a/packages/cli/src/lib/webdriver.ts +++ b/packages/cli/src/lib/webdriver.ts @@ -12,10 +12,7 @@ const startDriver = async ( if (config.browser === 'chrome-headless') { const service = new chrome.ServiceBuilder( config.chromedriverPath || chromedriver.path - ).build(); - // Pinned to selenium-webdriver@4.3.0 - // https://github.com/SeleniumHQ/selenium/pull/10796/files#diff-6c87d95a2288e92e15a6bb17710c763c01c2290e679beb26220858f3218b6a62L260 - chrome.setDefaultService(service); + ); let options = new chrome.Options().headless(); if (config.chromeOptions?.length) { @@ -24,7 +21,10 @@ const startDriver = async ( }, options); } - builder = new Builder().forBrowser('chrome').setChromeOptions(options); + builder = new Builder() + .forBrowser('chrome') + .setChromeOptions(options) + .setChromeService(service); } else { builder = new Builder().forBrowser(config.browser); } diff --git a/packages/webdriverjs/package-lock.json b/packages/webdriverjs/package-lock.json index 415e61a979..6217552dfa 100644 --- a/packages/webdriverjs/package-lock.json +++ b/packages/webdriverjs/package-lock.json @@ -33,7 +33,7 @@ "mocha": "^10.0.0", "nyc": "^15.1.0", "rimraf": "^3.0.2", - "selenium-webdriver": "4.3.0", + "selenium-webdriver": "^4.8.1", "sinon": "^14.0.1", "test-listen": "^1.1.0", "ts-node": "^10.9.1", @@ -3984,17 +3984,17 @@ "dev": true }, "node_modules/selenium-webdriver": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.3.0.tgz", - "integrity": "sha512-9XFr8w95BO7jageR61AtiB83fJNem3fdtOQcUpqIIDHWSxihomyG/yBlL1H4y/shi/dO/Ai3PJMAOG+OW3+JHw==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.8.1.tgz", + "integrity": "sha512-p4MtfhCQdcV6xxkS7eI0tQN6+WNReRULLCAuT4RDGkrjfObBNXMJ3WT8XdK+aXTr5nnBKuh+PxIevM0EjJgkxA==", "dev": true, "dependencies": { "jszip": "^3.10.0", "tmp": "^0.2.1", - "ws": ">=8.7.0" + "ws": ">=8.11.0" }, "engines": { - "node": ">= 10.15.0" + "node": ">= 14.20.0" } }, "node_modules/semver": { @@ -4727,16 +4727,16 @@ } }, "node_modules/ws": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz", - "integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "dev": true, "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -8044,14 +8044,14 @@ "dev": true }, "selenium-webdriver": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.3.0.tgz", - "integrity": "sha512-9XFr8w95BO7jageR61AtiB83fJNem3fdtOQcUpqIIDHWSxihomyG/yBlL1H4y/shi/dO/Ai3PJMAOG+OW3+JHw==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.8.1.tgz", + "integrity": "sha512-p4MtfhCQdcV6xxkS7eI0tQN6+WNReRULLCAuT4RDGkrjfObBNXMJ3WT8XdK+aXTr5nnBKuh+PxIevM0EjJgkxA==", "dev": true, "requires": { "jszip": "^3.10.0", "tmp": "^0.2.1", - "ws": ">=8.7.0" + "ws": ">=8.11.0" } }, "semver": { @@ -8621,9 +8621,9 @@ } }, "ws": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz", - "integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", "dev": true, "requires": {} }, diff --git a/packages/webdriverjs/package.json b/packages/webdriverjs/package.json index b5ac6fb20e..7cca6cd3fd 100644 --- a/packages/webdriverjs/package.json +++ b/packages/webdriverjs/package.json @@ -78,7 +78,7 @@ "mocha": "^10.0.0", "nyc": "^15.1.0", "rimraf": "^3.0.2", - "selenium-webdriver": "4.3.0", + "selenium-webdriver": "^4.8.1", "sinon": "^14.0.1", "test-listen": "^1.1.0", "ts-node": "^10.9.1",