From 49d68e84dedae79f3da73733438a767f63c228a3 Mon Sep 17 00:00:00 2001 From: Potapov Dmitriy Date: Mon, 8 Feb 2021 22:37:05 +0200 Subject: [PATCH] code cleanup first iteration --- javascript/node/selenium-webdriver/io/exec.js | 6 +- .../node/selenium-webdriver/io/index.js | 17 ++-- javascript/node/selenium-webdriver/io/zip.js | 11 +-- .../node/selenium-webdriver/lib/actions.js | 2 +- .../node/selenium-webdriver/lib/promise.js | 20 +--- .../node/selenium-webdriver/remote/index.js | 13 ++- .../selenium-webdriver/test/actions_test.js | 52 +++++----- .../selenium-webdriver/test/builder_test.js | 2 +- .../test/chrome/devtools_test.js | 28 +++--- .../test/chrome/options_test.js | 28 ++++-- .../selenium-webdriver/test/cookie_test.js | 17 ++-- .../test/elementAccessibleName_test.js | 16 +++- .../test/elementAriaRole_test.js | 6 +- .../test/element_finding_test.js | 50 +++++----- .../test/execute_script_test.js | 81 +++++++++------- .../selenium-webdriver/test/firefox_test.js | 15 +-- .../selenium-webdriver/test/frame_test.js | 4 +- .../selenium-webdriver/test/http/http_test.js | 50 +++++----- .../selenium-webdriver/test/http/util_test.js | 10 +- .../test/ie/options_test.js | 14 +-- .../selenium-webdriver/test/io/io_test.js | 37 ++++---- .../selenium-webdriver/test/io/zip_test.js | 4 +- .../selenium-webdriver/test/lib/by_test.js | 78 +++++++-------- .../test/lib/capabilities_test.js | 59 ++++++------ .../selenium-webdriver/test/lib/error_test.js | 24 ++--- .../selenium-webdriver/test/lib/http_test.js | 36 +++---- .../selenium-webdriver/test/lib/input_test.js | 87 ++++++++++------- .../test/lib/logging_test.js | 25 ++--- .../test/lib/promise_test.js | 95 ++++++++++--------- .../selenium-webdriver/test/lib/until_test.js | 36 +++---- .../test/lib/webdriver_test.js | 93 ++++++++++-------- .../selenium-webdriver/test/logging_test.js | 20 ++-- .../selenium-webdriver/test/net/index_test.js | 21 ++-- .../test/page_loading_test.js | 14 +-- .../selenium-webdriver/test/print_pdf_test.js | 14 +-- .../selenium-webdriver/test/proxy_test.js | 20 ++-- .../node/selenium-webdriver/test/rect_test.js | 2 +- .../selenium-webdriver/test/remote_test.js | 15 +-- .../test/stale_element_test.js | 2 +- .../selenium-webdriver/test/upload_test.js | 2 +- .../selenium-webdriver/test/window_test.js | 6 +- 41 files changed, 598 insertions(+), 534 deletions(-) diff --git a/javascript/node/selenium-webdriver/io/exec.js b/javascript/node/selenium-webdriver/io/exec.js index 9418d59ca96b8..0803ff97884f1 100644 --- a/javascript/node/selenium-webdriver/io/exec.js +++ b/javascript/node/selenium-webdriver/io/exec.js @@ -121,9 +121,9 @@ class Command { * @return {!Command} The launched command. */ module.exports = function exec(command, opt_options) { - var options = opt_options || {} + const options = opt_options || {} - var proc = childProcess.spawn(command, options.args || [], { + let proc = childProcess.spawn(command, options.args || [], { env: options.env || process.env, stdio: options.stdio || 'ignore', }) @@ -133,7 +133,7 @@ module.exports = function exec(command, opt_options) { proc.unref() process.once('exit', onProcessExit) - let result = new Promise((resolve) => { + const result = new Promise((resolve) => { proc.once('exit', (code, signal) => { proc = null process.removeListener('exit', onProcessExit) diff --git a/javascript/node/selenium-webdriver/io/index.js b/javascript/node/selenium-webdriver/io/index.js index 98b6f497514a0..41dc9b0038ce9 100644 --- a/javascript/node/selenium-webdriver/io/index.js +++ b/javascript/node/selenium-webdriver/io/index.js @@ -204,13 +204,12 @@ exports.tmpDir = function () { */ exports.tmpFile = function (opt_options) { return checkedCall((callback) => { - // |tmp.file| checks arguments length to detect options rather than doing a - // truthy check, so we must only pass options if there are some to pass. - if (opt_options) { - tmp.file(opt_options, callback) - } else { - tmp.file(callback) - } + /** check fixed in v > 0.2.1 if + * (typeof options === 'function') { + * return [{}, options]; + * } + */ + tmp.file(opt_options, callback) }) } @@ -224,7 +223,7 @@ exports.tmpFile = function (opt_options) { * not be found. */ exports.findInPath = function (file, opt_checkCwd) { - let dirs = [] + const dirs = [] if (opt_checkCwd) { dirs.push(process.cwd()) } @@ -329,7 +328,7 @@ exports.mkdirp = function mkdirp(dir) { * will be relative to `rootPath`. */ exports.walkDir = function (rootPath) { - let seen = [] + const seen = [] return (function walk(dir) { return checkedCall((callback) => fs.readdir(dir, callback)).then((files) => Promise.all( diff --git a/javascript/node/selenium-webdriver/io/zip.js b/javascript/node/selenium-webdriver/io/zip.js index e83732e856fff..c95816945004b 100644 --- a/javascript/node/selenium-webdriver/io/zip.js +++ b/javascript/node/selenium-webdriver/io/zip.js @@ -180,8 +180,8 @@ function load(path) { */ function unzip(src, dst) { return load(src).then((zip) => { - let promisedDirs = new Map() - let promises = [] + const promisedDirs = new Map() + const promises = [] zip.z_.forEach((relPath, file) => { let p @@ -218,7 +218,6 @@ function unzip(src, dst) { } // PUBLIC API - -exports.Zip = Zip -exports.load = load -exports.unzip = unzip +module.exports.Zip = Zip +module.exports.load = load +module.exports.unzip = unzip diff --git a/javascript/node/selenium-webdriver/lib/actions.js b/javascript/node/selenium-webdriver/lib/actions.js index cc35e258d2e8c..6fd2491bec54e 100644 --- a/javascript/node/selenium-webdriver/lib/actions.js +++ b/javascript/node/selenium-webdriver/lib/actions.js @@ -342,7 +342,7 @@ class LegacyActionSequence { * @private */ scheduleKeyboardAction_(description, keys) { - let cmd = new command.Command( + const cmd = new command.Command( command.Name.LEGACY_ACTION_SEND_KEYS ).setParameter('value', keys) this.schedule_(description, cmd) diff --git a/javascript/node/selenium-webdriver/lib/promise.js b/javascript/node/selenium-webdriver/lib/promise.js index 45150a71e3ed1..9e130a5945329 100644 --- a/javascript/node/selenium-webdriver/lib/promise.js +++ b/javascript/node/selenium-webdriver/lib/promise.js @@ -30,17 +30,7 @@ * @return {boolean} Whether the value is a promise. */ function isPromise(value) { - try { - // Use array notation so the Closure compiler does not obfuscate away our - // contract. - return ( - value && - (typeof value === 'object' || typeof value === 'function') && - typeof value['then'] === 'function' - ) - } catch (ex) { - return false - } + return Object.prototype.toString.call(value) === '[object Promise]' } /** @@ -50,9 +40,7 @@ function isPromise(value) { * @return {!Promise} The promise. */ function delayed(ms) { - return new Promise((resolve) => { - setTimeout(resolve, ms) - }) + return new Promise((resolve) => setTimeout(resolve, ms)) } /** @@ -199,8 +187,8 @@ async function filter(array, fn, self = undefined) { for (let i = 0; i < n; i++) { if (i in arr) { - let value = arr[i] - let include = await fn.call(self, value, i, arr) + const value = arr[i] + const include = await fn.call(self, value, i, arr) if (include) { values[valuesLength++] = value } diff --git a/javascript/node/selenium-webdriver/remote/index.js b/javascript/node/selenium-webdriver/remote/index.js index 276354289f83b..cb6d97f48fb5a 100644 --- a/javascript/node/selenium-webdriver/remote/index.js +++ b/javascript/node/selenium-webdriver/remote/index.js @@ -210,7 +210,7 @@ class DriverService { } return resolveCommandLineFlags(this.args_).then((args) => { - var command = exec(self.executable_, { + const command = exec(self.executable_, { args: args, env: self.env_, stdio: self.stdio_, @@ -218,8 +218,8 @@ class DriverService { resolveCommand(command) - var earlyTermination = command.result().then(function (result) { - var error = + const earlyTermination = command.result().then(function (result) { + const error = result.code == null ? Error('Server was killed with ' + result.signal) : Error('Server terminated early with status ' + result.code) @@ -229,7 +229,7 @@ class DriverService { throw error }) - var hostname = self.hostname_ + let hostname = self.hostname_ if (!hostname) { hostname = (!self.loopbackOnly_ && net.getAddress()) || @@ -338,9 +338,8 @@ DriverService.Builder = class { * @this {THIS} * @template THIS */ - addArguments(var_args) { // eslint-disable-line - let args = Array.prototype.slice.call(arguments, 0) - this.options_.args = this.options_.args.concat(args) + addArguments(...arguments_) { + this.options_.args = this.options_.args.concat(arguments_) return this } diff --git a/javascript/node/selenium-webdriver/test/actions_test.js b/javascript/node/selenium-webdriver/test/actions_test.js index 10dc6ec227107..8d65b900b9e04 100644 --- a/javascript/node/selenium-webdriver/test/actions_test.js +++ b/javascript/node/selenium-webdriver/test/actions_test.js @@ -54,10 +54,10 @@ test.suite(function (env) { await driver.get(fileServer.whereIs('/data/actions/click.html')) let box = await driver.findElement(By.id('box')) - assert.equal(await box.getAttribute('class'), '') + assert.strictEqual(await box.getAttribute('class'), '') await driver.actions().click(box).perform() - assert.equal(await box.getAttribute('class'), 'green') + assert.strictEqual(await box.getAttribute('class'), 'green') }) it('click(element) clicks in center of element', async function () { @@ -65,12 +65,12 @@ test.suite(function (env) { const div = await driver.findElement(By.css('div')) const rect = await div.getRect() - assert.deepEqual(rect, { width: 500, height: 500, x: 0, y: 0 }) + assert.deepStrictEqual(rect, { width: 500, height: 500, x: 0, y: 0 }) await driver.actions().click(div).perform() const clicks = await driver.executeScript('return clicks') - assert.deepEqual(clicks, [[250, 250]]) + assert.deepStrictEqual(clicks, [[250, 250]]) }) it('can move relative to element center', async function () { @@ -78,7 +78,7 @@ test.suite(function (env) { const div = await driver.findElement(By.css('div')) const rect = await div.getRect() - assert.deepEqual(rect, { width: 500, height: 500, x: 0, y: 0 }) + assert.deepStrictEqual(rect, { width: 500, height: 500, x: 0, y: 0 }) await driver .actions() @@ -87,7 +87,7 @@ test.suite(function (env) { .perform() const clicks = await driver.executeScript('return clicks') - assert.deepEqual(clicks, [[260, 260]]) + assert.deepStrictEqual(clicks, [[260, 260]]) }) test @@ -96,10 +96,10 @@ test.suite(function (env) { await driver.get(fileServer.whereIs('/data/actions/click.html')) let box = await driver.findElement(By.id('box')) - assert.equal(await box.getAttribute('class'), '') + assert.strictEqual(await box.getAttribute('class'), '') await driver.actions().doubleClick(box).perform() - assert.equal(await box.getAttribute('class'), 'blue') + assert.strictEqual(await box.getAttribute('class'), 'blue') }) // For some reason for Chrome 75 we need to wrap this test in an extra @@ -112,18 +112,18 @@ test.suite(function (env) { await driver.get(fileServer.whereIs('/data/actions/drag.html')) let slide = await driver.findElement(By.id('slide')) - assert.equal(await slide.getCssValue('left'), '0px') - assert.equal(await slide.getCssValue('top'), '0px') + assert.strictEqual(await slide.getCssValue('left'), '0px') + assert.strictEqual(await slide.getCssValue('top'), '0px') let br = await driver.findElement(By.id('BR')) await driver.actions().dragAndDrop(slide, br).perform() - assert.equal(await slide.getCssValue('left'), '206px') - assert.equal(await slide.getCssValue('top'), '206px') + assert.strictEqual(await slide.getCssValue('left'), '206px') + assert.strictEqual(await slide.getCssValue('top'), '206px') let tr = await driver.findElement(By.id('TR')) await driver.actions().dragAndDrop(slide, tr).perform() - assert.equal(await slide.getCssValue('left'), '206px') - assert.equal(await slide.getCssValue('top'), '1px') + assert.strictEqual(await slide.getCssValue('left'), '206px') + assert.strictEqual(await slide.getCssValue('top'), '1px') }) }) @@ -131,8 +131,8 @@ test.suite(function (env) { await driver.get(fileServer.whereIs('/data/actions/drag.html')) let slide = await driver.findElement(By.id('slide')) - assert.equal(await slide.getCssValue('left'), '0px') - assert.equal(await slide.getCssValue('top'), '0px') + assert.strictEqual(await slide.getCssValue('left'), '0px') + assert.strictEqual(await slide.getCssValue('top'), '0px') await driver .actions() @@ -141,8 +141,8 @@ test.suite(function (env) { .move({ x: 100, y: 100, origin: Origin.POINTER }) .release() .perform() - assert.equal(await slide.getCssValue('left'), '101px') - assert.equal(await slide.getCssValue('top'), '101px') + assert.strictEqual(await slide.getCssValue('left'), '101px') + assert.strictEqual(await slide.getCssValue('top'), '101px') }) it('can move to and click element in an iframe', async function () { @@ -163,33 +163,33 @@ test.suite(function (env) { await driver.get(test.Pages.formPage) let el = await driver.findElement(By.id('email')) - assert.equal(await el.getAttribute('value'), '') + assert.strictEqual(await el.getAttribute('value'), '') await driver.executeScript('arguments[0].focus()', el) await driver.actions().sendKeys('foobar').perform() - assert.equal(await el.getAttribute('value'), 'foobar') + assert.strictEqual(await el.getAttribute('value'), 'foobar') }) it('can get the property of element', async function () { await driver.get(test.Pages.formPage) let el = await driver.findElement(By.id('email')) - assert.equal(await el.getProperty('value'), '') + assert.strictEqual(await el.getProperty('value'), '') await driver.executeScript('arguments[0].focus()', el) await driver.actions().sendKeys('foobar').perform() - assert.equal(await el.getProperty('value'), 'foobar') + assert.strictEqual(await el.getProperty('value'), 'foobar') }) it('can send keys to focused element (with modifiers)', async function () { await driver.get(test.Pages.formPage) let el = await driver.findElement(By.id('email')) - assert.equal(await el.getAttribute('value'), '') + assert.strictEqual(await el.getAttribute('value'), '') await driver.executeScript('arguments[0].focus()', el) @@ -202,18 +202,18 @@ test.suite(function (env) { .sendKeys('ar') .perform() - assert.equal(await el.getAttribute('value'), 'foOBar') + assert.strictEqual(await el.getAttribute('value'), 'foOBar') }) it('can interact with simple form elements', async function () { await driver.get(test.Pages.formPage) let el = await driver.findElement(By.id('email')) - assert.equal(await el.getAttribute('value'), '') + assert.strictEqual(await el.getAttribute('value'), '') await driver.actions().click(el).sendKeys('foobar').perform() - assert.equal(await el.getAttribute('value'), 'foobar') + assert.strictEqual(await el.getAttribute('value'), 'foobar') }) }) }) diff --git a/javascript/node/selenium-webdriver/test/builder_test.js b/javascript/node/selenium-webdriver/test/builder_test.js index 79fce6cf3c43e..ad64991603311 100644 --- a/javascript/node/selenium-webdriver/test/builder_test.js +++ b/javascript/node/selenium-webdriver/test/builder_test.js @@ -53,7 +53,7 @@ test.suite(function (env) { driver instanceof want, `want ${want.name}, but got ${driver.name}` ) - assert.equal(typeof driver.then, 'function') + assert.strictEqual(typeof driver.then, 'function') return ( driver diff --git a/javascript/node/selenium-webdriver/test/chrome/devtools_test.js b/javascript/node/selenium-webdriver/test/chrome/devtools_test.js index 13ac9e9d838f0..dcf5755ee5b93 100644 --- a/javascript/node/selenium-webdriver/test/chrome/devtools_test.js +++ b/javascript/node/selenium-webdriver/test/chrome/devtools_test.js @@ -43,31 +43,31 @@ test.suite( it('can send commands to devtools', async function () { await driver.get(test.Pages.ajaxyPage) - assert.equal(await driver.getCurrentUrl(), test.Pages.ajaxyPage) + assert.strictEqual(await driver.getCurrentUrl(), test.Pages.ajaxyPage) await driver.sendDevToolsCommand('Page.navigate', { url: test.Pages.echoPage, }) - assert.equal(await driver.getCurrentUrl(), test.Pages.echoPage) + assert.strictEqual(await driver.getCurrentUrl(), test.Pages.echoPage) }) it('can send commands to devtools and get return', async function () { await driver.get(test.Pages.ajaxyPage) - assert.equal(await driver.getCurrentUrl(), test.Pages.ajaxyPage) + assert.strictEqual(await driver.getCurrentUrl(), test.Pages.ajaxyPage) await driver.get(test.Pages.echoPage) - assert.equal(await driver.getCurrentUrl(), test.Pages.echoPage) + assert.strictEqual(await driver.getCurrentUrl(), test.Pages.echoPage) let history = await driver.sendAndGetDevToolsCommand( 'Page.getNavigationHistory' ) assert(history) assert(history.currentIndex >= 2) - assert.equal( + assert.strictEqual( history.entries[history.currentIndex].url, test.Pages.echoPage ) - assert.equal( + assert.strictEqual( history.entries[history.currentIndex - 1].url, test.Pages.ajaxyPage ) @@ -100,7 +100,7 @@ test.suite( it('calls the event listener for console.log', async function () { const cdpConnection = await driver.createCDPConnection('page') await driver.onLogEvent(cdpConnection, function (event) { - assert.equal(event['args'][0]['value'], 'here') + assert.strictEqual(event['args'][0]['value'], 'here') }) await driver.executeScript('console.log("here")') }) @@ -108,7 +108,7 @@ test.suite( it('calls the event listener for js exceptions', async function () { const cdpConnection = await driver.createCDPConnection('page') await driver.onLogException(cdpConnection, function (event) { - assert.equal( + assert.strictEqual( event['exceptionDetails']['stackTrace']['callFrames'][0][ 'functionName' ], @@ -125,9 +125,9 @@ test.suite( it('calls the event listener on dom mutations', async function () { const cdpConnection = await driver.createCDPConnection('page') await driver.logMutationEvents(cdpConnection, function (event) { - assert.equal(event['attribute_name'], 'style') - assert.equal(event['current_value'], '') - assert.equal(event['old_value'], 'display:none;') + assert.strictEqual(event['attribute_name'], 'style') + assert.strictEqual(event['current_value'], '') + assert.strictEqual(event['old_value'], 'display:none;') }) await driver.get(test.Pages.dynamicPage) @@ -175,7 +175,7 @@ test.suite( await driver.register('random', 'random', pageCdpConnection) await driver.get(server.url() + '/protected') let source = await driver.getPageSource() - assert.equal(source.includes('Access granted!'), false) + assert.strictEqual(source.includes('Access granted!'), false) }) it('grants access if username and password are a match', async function () { @@ -184,7 +184,7 @@ test.suite( await driver.register('genie', 'bottle', pageCdpConnection) await driver.get(server.url() + '/protected') let source = await driver.getPageSource() - assert.equal(source.includes('Access granted!'), true) + assert.strictEqual(source.includes('Access granted!'), true) await server.stop() }) }) @@ -207,7 +207,7 @@ test.suite( __dirname, '../../lib/test/data/firefox/webextension.xpi' ) - assert.equal( + assert.strictEqual( fs.readFileSync(downloadPath, 'binary'), fs.readFileSync(goldenPath, 'binary') ) diff --git a/javascript/node/selenium-webdriver/test/chrome/options_test.js b/javascript/node/selenium-webdriver/test/chrome/options_test.js index 69b373ffc0282..6ac430ecd2f0a 100644 --- a/javascript/node/selenium-webdriver/test/chrome/options_test.js +++ b/javascript/node/selenium-webdriver/test/chrome/options_test.js @@ -28,13 +28,13 @@ describe('chrome.Options', function () { describe('addArguments', function () { it('takes var_args', function () { let options = new chrome.Options() - assert.deepEqual(options[symbols.serialize](), { + assert.deepStrictEqual(options[symbols.serialize](), { browserName: 'chrome', 'goog:chromeOptions': {}, }) options.addArguments('a', 'b') - assert.deepEqual(options[symbols.serialize](), { + assert.deepStrictEqual(options[symbols.serialize](), { browserName: 'chrome', 'goog:chromeOptions': { args: ['a', 'b'], @@ -44,13 +44,13 @@ describe('chrome.Options', function () { it('flattens input arrays', function () { let options = new chrome.Options() - assert.deepEqual(options[symbols.serialize](), { + assert.deepStrictEqual(options[symbols.serialize](), { browserName: 'chrome', 'goog:chromeOptions': {}, }) options.addArguments(['a', 'b'], 'c', [1, 2], 3) - assert.deepEqual(options[symbols.serialize](), { + assert.deepStrictEqual(options[symbols.serialize](), { browserName: 'chrome', 'goog:chromeOptions': { args: ['a', 'b', 'c', 1, 2, 3], @@ -65,7 +65,7 @@ describe('chrome.Options', function () { assert.strictEqual(options.options_.extensions, undefined) options.addExtensions('a', 'b') - assert.deepEqual(options.options_.extensions, ['a', 'b']) + assert.deepStrictEqual(options.options_.extensions, ['a', 'b']) }) it('flattens input arrays', function () { @@ -73,7 +73,14 @@ describe('chrome.Options', function () { assert.strictEqual(options.options_.extensions, undefined) options.addExtensions(['a', 'b'], 'c', [1, 2], 3) - assert.deepEqual(options.options_.extensions, ['a', 'b', 'c', 1, 2, 3]) + assert.deepStrictEqual(options.options_.extensions, [ + 'a', + 'b', + 'c', + 1, + 2, + 3, + ]) }) }) @@ -84,8 +91,11 @@ describe('chrome.Options', function () { .addExtensions(__filename) [symbols.serialize]() - assert.equal(wire['goog:chromeOptions'].extensions.length, 1) - assert.equal(await wire['goog:chromeOptions'].extensions[0], expected) + assert.strictEqual(wire['goog:chromeOptions'].extensions.length, 1) + assert.strictEqual( + await wire['goog:chromeOptions'].extensions[0], + expected + ) }) }) }) @@ -109,7 +119,7 @@ test.suite( var userAgent = await driver.executeScript( 'return window.navigator.userAgent' ) - assert.equal(userAgent, 'foo;bar') + assert.strictEqual(userAgent, 'foo;bar') }) }) }, diff --git a/javascript/node/selenium-webdriver/test/cookie_test.js b/javascript/node/selenium-webdriver/test/cookie_test.js index bd3bfa666a341..8e4c336535548 100644 --- a/javascript/node/selenium-webdriver/test/cookie_test.js +++ b/javascript/node/selenium-webdriver/test/cookie_test.js @@ -50,7 +50,7 @@ suite(function (env) { .manage() .getCookie(cookie.name) .then(function (actual) { - assert.equal(actual.value, cookie.value) + assert.strictEqual(actual.value, cookie.value) }) }) @@ -178,10 +178,13 @@ suite(function (env) { .manage() .getCookie(cookie.name) .then(function (actual) { - assert.equal(actual.value, cookie.value) + assert.strictEqual(actual.value, cookie.value) // expiry times should be in seconds since January 1, 1970 UTC - assert.equal(actual.expiry, Math.floor(expiry.getTime() / 1000)) + assert.strictEqual( + actual.expiry, + Math.floor(expiry.getTime() / 1000) + ) }) await driver.sleep(expirationDelay) @@ -197,7 +200,7 @@ suite(function (env) { await driver.get(childUrl) await driver.manage().addCookie(cookie) const actual = await driver.manage().getCookie(cookie.name) - assert.equal(actual.sameSite, 'Strict') + assert.strictEqual(actual.sameSite, 'Strict') } ) @@ -209,7 +212,7 @@ suite(function (env) { await driver.get(childUrl) await driver.manage().addCookie(cookie) const actualCookie = await driver.manage().getCookie(cookie.name) - assert.equal(actualCookie.sameSite, 'Lax') + assert.strictEqual(actualCookie.sameSite, 'Lax') } ) @@ -294,7 +297,7 @@ suite(function (env) { .manage() .getCookies() .then(function (cookies) { - assert.equal( + assert.strictEqual( cookies.length, expected.length, 'Wrong # of cookies.' + @@ -306,7 +309,7 @@ suite(function (env) { const map = buildCookieMap(cookies) for (let i = 0; i < expected.length; ++i) { - assert.equal(expected[i].value, map[expected[i].name].value) + assert.strictEqual(expected[i].value, map[expected[i].name].value) } }) } diff --git a/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js b/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js index fb03fc43ad051..fdbb37e3bbf21 100644 --- a/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js +++ b/javascript/node/selenium-webdriver/test/elementAccessibleName_test.js @@ -37,14 +37,14 @@ test.suite( await driver.get(`data:text/html,

Level 1 Header

`) let header = driver.findElement(By.css('h1')) - assert.equal(await header.getAccessibleName(), 'Level 1 Header') + assert.strictEqual(await header.getAccessibleName(), 'Level 1 Header') }) it('Should return computed label for img', async function () { await driver.get(`data:text/html, Test Image`) let imgLabel = driver.findElement(By.css('img')) - assert.equal(await imgLabel.getAccessibleName(), 'Test Image') + assert.strictEqual(await imgLabel.getAccessibleName(), 'Test Image') }) it('Should return computed label for label', async function () { @@ -52,14 +52,17 @@ test.suite( `) let computedLabel = driver.findElement(By.css('input')) - assert.equal(await computedLabel.getAccessibleName(), 'Test Label') + assert.strictEqual( + await computedLabel.getAccessibleName(), + 'Test Label' + ) }) it('Should return computed label for aria-label', async function () { await driver.get(`data:text/html, `) let computedAriaLabel = driver.findElement(By.css('button')) - assert.equal( + assert.strictEqual( await computedAriaLabel.getAccessibleName(), 'Add sample button to cart' ) @@ -70,7 +73,10 @@ test.suite( `) let computedAriaLabel = driver.findElement(By.css('input')) - assert.equal(await computedAriaLabel.getAccessibleName(), 'Search') + assert.strictEqual( + await computedAriaLabel.getAccessibleName(), + 'Search' + ) }) }) }, diff --git a/javascript/node/selenium-webdriver/test/elementAriaRole_test.js b/javascript/node/selenium-webdriver/test/elementAriaRole_test.js index 2ac2af862f6fb..093ffce6f79c6 100644 --- a/javascript/node/selenium-webdriver/test/elementAriaRole_test.js +++ b/javascript/node/selenium-webdriver/test/elementAriaRole_test.js @@ -37,21 +37,21 @@ test.suite( await driver.get(`data:text/html,
Level 1 Header
`) let header = driver.findElement(By.css('div')) - assert.equal(await header.getAriaRole(), 'heading') + assert.strictEqual(await header.getAriaRole(), 'heading') }) it('Should return implicit role defined by tagName', async function () { await driver.get(`data:text/html,

Level 1 Header

`) let header = driver.findElement(By.css('h1')) - assert.equal(await header.getAriaRole(), 'heading') + assert.strictEqual(await header.getAriaRole(), 'heading') }) it('Should return explicit role even if it contradicts TagName', async function () { await driver.get(`data:text/html,

Level 1 Header

`) let header = driver.findElement(By.css('h1')) - assert.equal(await header.getAriaRole(), 'alert') + assert.strictEqual(await header.getAriaRole(), 'alert') }) }) }, diff --git a/javascript/node/selenium-webdriver/test/element_finding_test.js b/javascript/node/selenium-webdriver/test/element_finding_test.js index 6f1adb0c6eb63..4664269ec302e 100644 --- a/javascript/node/selenium-webdriver/test/element_finding_test.js +++ b/javascript/node/selenium-webdriver/test/element_finding_test.js @@ -66,7 +66,7 @@ suite(function (env) { await driver.get(Pages.nestedPage) let elements = await driver.findElements(By.id('2')) - assert.equal(elements.length, 8) + assert.strictEqual(elements.length, 8) } ) }) @@ -89,7 +89,7 @@ suite(function (env) { let el = await driver.findElement(By.linkText('Link=equalssign')) let id = await el.getAttribute('id') - assert.equal(id, 'linkWithEqualsSign') + assert.strictEqual(id, 'linkWithEqualsSign') }) it('matches by partial text when containing equals sign', async function () { @@ -97,39 +97,39 @@ suite(function (env) { let link = await driver.findElement(By.partialLinkText('Link=')) let id = await link.getAttribute('id') - assert.equal(id, 'linkWithEqualsSign') + assert.strictEqual(id, 'linkWithEqualsSign') }) it('works when searching for multiple and text contains =', async function () { await driver.get(Pages.xhtmlTestPage) let elements = await driver.findElements(By.linkText('Link=equalssign')) - assert.equal(elements.length, 1) + assert.strictEqual(elements.length, 1) let id = await elements[0].getAttribute('id') - assert.equal(id, 'linkWithEqualsSign') + assert.strictEqual(id, 'linkWithEqualsSign') }) it('works when searching for multiple with partial text containing =', async function () { await driver.get(Pages.xhtmlTestPage) let elements = await driver.findElements(By.partialLinkText('Link=')) - assert.equal(elements.length, 1) + assert.strictEqual(elements.length, 1) let id = await elements[0].getAttribute('id') - assert.equal(id, 'linkWithEqualsSign') + assert.strictEqual(id, 'linkWithEqualsSign') }) it('should be able to find multiple exact matches', async function () { await driver.get(Pages.xhtmlTestPage) let elements = await driver.findElements(By.linkText('click me')) - assert.equal(elements.length, 2) + assert.strictEqual(elements.length, 2) }) it('should be able to find multiple partial matches', async function () { await driver.get(Pages.xhtmlTestPage) let elements = await driver.findElements(By.partialLinkText('ick me')) - assert.equal(elements.length, 2) + assert.strictEqual(elements.length, 2) }) ignore(browsers(Browser.SAFARI)).it( @@ -138,7 +138,7 @@ suite(function (env) { await driver.get(whereIs('actualXhtmlPage.xhtml')) let el = await driver.findElement(By.linkText('Foo')) - assert.equal(await el.getText(), 'Foo') + assert.strictEqual(await el.getText(), 'Foo') } ) }) @@ -148,7 +148,7 @@ suite(function (env) { await driver.get(Pages.formPage) let el = await driver.findElement(By.name('checky')) - assert.equal(await el.getAttribute('value'), 'furrfu') + assert.strictEqual(await el.getAttribute('value'), 'furrfu') }) it('should find multiple elements with same name', async function () { @@ -187,28 +187,28 @@ suite(function (env) { await driver.get(Pages.xhtmlTestPage) let el = await driver.findElement(By.className('nameA')) - assert.equal(await el.getText(), 'An H2 title') + assert.strictEqual(await el.getText(), 'An H2 title') }) it('should work when name is last name among many', async function () { await driver.get(Pages.xhtmlTestPage) let el = await driver.findElement(By.className('nameC')) - assert.equal(await el.getText(), 'An H2 title') + assert.strictEqual(await el.getText(), 'An H2 title') }) it('should work when name is middle of many', async function () { await driver.get(Pages.xhtmlTestPage) let el = await driver.findElement(By.className('nameBnoise')) - assert.equal(await el.getText(), 'An H2 title') + assert.strictEqual(await el.getText(), 'An H2 title') }) it('should work when name surrounded by whitespace', async function () { await driver.get(Pages.xhtmlTestPage) let el = await driver.findElement(By.className('spaceAround')) - assert.equal(await el.getText(), 'Spaced out') + assert.strictEqual(await el.getText(), 'Spaced out') }) it('should fail if queried name only partially matches', async function () { @@ -255,7 +255,7 @@ suite(function (env) { .get(Pages.xhtmlTestPage) .then(() => driver.findElement(By.className('nameA nameC'))) .then((el) => el.getText()) - .then((text) => assert.equal(text, 'An H2 title')) + .then((text) => assert.strictEqual(text, 'An H2 title')) }) }) @@ -278,7 +278,7 @@ suite(function (env) { await driver.get(Pages.formPage) let el = await driver.findElement(By.tagName('input')) - assert.equal((await el.getTagName()).toLowerCase(), 'input') + assert.strictEqual((await el.getTagName()).toLowerCase(), 'input') }) it('can find multiple elements', async function () { @@ -311,7 +311,7 @@ suite(function (env) { await driver.get(Pages.xhtmlTestPage) let el = await driver.findElement(By.css('div.extraDiv, div.content')) - assert.equal(await el.getAttribute('class'), 'content') + assert.strictEqual(await el.getAttribute('class'), 'content') } ) @@ -328,7 +328,7 @@ suite(function (env) { async function assertClassIs(el, expected) { let clazz = await el.getAttribute('class') - assert.equal(clazz, expected) + assert.strictEqual(clazz, expected) } }) @@ -343,7 +343,7 @@ suite(function (env) { let el = await driver.findElement( By.css('option[selected="selected"]') ) - assert.equal(await el.getAttribute('value'), 'two') + assert.strictEqual(await el.getAttribute('value'), 'two') } ) @@ -356,7 +356,7 @@ suite(function (env) { ) let el = await driver.findElement(By.css('option[selected]')) - assert.equal(await el.getAttribute('value'), 'two') + assert.strictEqual(await el.getAttribute('value'), 'two') } ) @@ -369,7 +369,7 @@ suite(function (env) { ) let el = await driver.findElement(By.css('option[selected]')) - assert.equal(await el.getAttribute('value'), 'two') + assert.strictEqual(await el.getAttribute('value'), 'two') } ) }) @@ -399,7 +399,7 @@ suite(function (env) { return driver.findElements(By.tagName('a')) }) - assert.equal(await link.getText(), 'Change the page title!') + assert.strictEqual(await link.getText(), 'Change the page title!') }) it('fails if locator returns non-webelement value', async function () { @@ -422,11 +422,11 @@ suite(function (env) { let below = await driver.findElement(By.id('below')) let elements = await driver.findElements(withTagName('p').above(below)) let ids = [] - assert.equal(elements.length, 2) + assert.strictEqual(elements.length, 2) for (let i = 0; i < elements.length; i++) { ids.push(await elements[i].getAttribute('id')) } - assert.deepEqual(ids, ['mid', 'above']) + assert.deepStrictEqual(ids, ['mid', 'above']) }) it('should combine filters', async function () { diff --git a/javascript/node/selenium-webdriver/test/execute_script_test.js b/javascript/node/selenium-webdriver/test/execute_script_test.js index 7aea31a67967f..60510d054803d 100644 --- a/javascript/node/selenium-webdriver/test/execute_script_test.js +++ b/javascript/node/selenium-webdriver/test/execute_script_test.js @@ -67,19 +67,19 @@ suite(function (env) { describe('scripts;', function () { it('do not pollute the global scope', async function () { await execute('var x = 1;') - assert.equal(await execute('return typeof x;'), 'undefined') + assert.strictEqual(await execute('return typeof x;'), 'undefined') }) it('can set global variables', async function () { await execute('window.x = 1234;') - assert.equal(await execute('return x;'), 1234) + assert.strictEqual(await execute('return x;'), 1234) }) it('may be defined as a function expression', async function () { let result = await execute(function () { return 1234 + 'abc' }) - assert.equal(result, '1234abc') + assert.strictEqual(result, '1234abc') }) }) @@ -93,17 +93,17 @@ suite(function (env) { }) it('can return numbers', async function () { - assert.equal(await execute('return 1234'), 1234) - assert.equal(await execute('return 3.1456'), 3.1456) + assert.strictEqual(await execute('return 1234'), 1234) + assert.strictEqual(await execute('return 3.1456'), 3.1456) }) it('can return strings', async function () { - assert.equal(await execute('return "hello"'), 'hello') + assert.strictEqual(await execute('return "hello"'), 'hello') }) it('can return booleans', async function () { - assert.equal(await execute('return true'), true) - assert.equal(await execute('return false'), false) + assert.strictEqual(await execute('return true'), true) + assert.strictEqual(await execute('return false'), false) }) it('can return an array of primitives', function () { @@ -126,8 +126,8 @@ suite(function (env) { it('can return object literals', function () { return execute('return {a: 1, b: false, c: null}').then((result) => { verifyJson(['a', 'b', 'c'])(Object.keys(result).sort()) - assert.equal(result.a, 1) - assert.equal(result.b, false) + assert.strictEqual(result.a, 1) + assert.strictEqual(result.b, false) assert.strictEqual(result.c, null) }) }) @@ -153,7 +153,7 @@ suite(function (env) { 'var nodes = document.querySelectorAll(".request,.host");' + 'return [nodes[0], nodes[1]];' ) - assert.equal(result.length, 2) + assert.strictEqual(result.length, 2) assert.ok(result[0] instanceof WebElement) assert.ok((await result[0].getText()).startsWith('GET ')) @@ -167,7 +167,7 @@ suite(function (env) { 'return document.querySelectorAll(".request,.host");' ) - assert.equal(result.length, 2) + assert.strictEqual(result.length, 2) assert.ok(result[0] instanceof WebElement) assert.ok((await result[0].getText()).startsWith('GET ')) @@ -180,39 +180,48 @@ suite(function (env) { let result = await execute('return {a: document.body}') assert.ok(result.a instanceof WebElement) - assert.equal((await result.a.getTagName()).toLowerCase(), 'body') + assert.strictEqual((await result.a.getTagName()).toLowerCase(), 'body') }) }) describe('parameters;', function () { it('can pass numeric arguments', async function () { - assert.equal(await execute('return arguments[0]', 12), 12) - assert.equal(await execute('return arguments[0]', 3.14), 3.14) + assert.strictEqual(await execute('return arguments[0]', 12), 12) + assert.strictEqual(await execute('return arguments[0]', 3.14), 3.14) }) it('can pass boolean arguments', async function () { - assert.equal(await execute('return arguments[0]', true), true) - assert.equal(await execute('return arguments[0]', false), false) + assert.strictEqual(await execute('return arguments[0]', true), true) + assert.strictEqual(await execute('return arguments[0]', false), false) }) it('can pass string arguments', async function () { - assert.equal(await execute('return arguments[0]', 'hi'), 'hi') + assert.strictEqual(await execute('return arguments[0]', 'hi'), 'hi') }) it('can pass null arguments', async function () { - assert.equal(await execute('return arguments[0] === null', null), true) - assert.equal(await execute('return arguments[0]', null), null) + assert.strictEqual( + await execute('return arguments[0] === null', null), + true + ) + assert.strictEqual(await execute('return arguments[0]', null), null) }) it('passes undefined as a null argument', async function () { var x - assert.equal(await execute('return arguments[0] === null', x), true) - assert.equal(await execute('return arguments[0]', x), null) + assert.strictEqual( + await execute('return arguments[0] === null', x), + true + ) + assert.strictEqual(await execute('return arguments[0]', x), null) }) it('can pass multiple arguments', async function () { - assert.equal(await execute('return arguments.length'), 0) - assert.equal(await execute('return arguments.length', 1, 'a', false), 3) + assert.strictEqual(await execute('return arguments.length'), 0) + assert.strictEqual( + await execute('return arguments.length', 1, 'a', false), + 3 + ) }) ignore(env.browsers(Browser.FIREFOX, Browser.SAFARI)).it( @@ -220,10 +229,10 @@ suite(function (env) { async function () { let val = await execute('return arguments', 1, 'a', false) - assert.equal(val.length, 3) - assert.equal(val[0], 1) - assert.equal(val[1], 'a') - assert.equal(val[2], false) + assert.strictEqual(val.length, 3) + assert.strictEqual(val[0], 1) + assert.strictEqual(val[1], 'a') + assert.strictEqual(val[2], false) } ) @@ -232,8 +241,8 @@ suite(function (env) { 'return [typeof arguments[0], arguments[0].a]', { a: 'hello' } ) - assert.equal(result[0], 'object') - assert.equal(result[1], 'hello') + assert.strictEqual(result[0], 'object') + assert.strictEqual(result[1], 'hello') }) it('WebElement arguments are passed as DOM elements', async function () { @@ -242,13 +251,13 @@ suite(function (env) { 'return arguments[0].tagName.toLowerCase();', el ) - assert.equal(result, 'div') + assert.strictEqual(result, 'div') }) it('can pass array containing object literals', async function () { let result = await execute('return arguments[0]', [{ color: 'red' }]) - assert.equal(result.length, 1) - assert.equal(result[0].color, 'red') + assert.strictEqual(result.length, 1) + assert.strictEqual(result[0].color, 'red') }) it('does not modify object literal parameters', function () { @@ -351,9 +360,9 @@ suite(function (env) { }) .catch(function (e) { if (env.browser.name === Browser.SAFARI) { - assert.equal(e.name, error.TimeoutError.name) + assert.strictEqual(e.name, error.TimeoutError.name) } else { - assert.equal(e.name, error.ScriptTimeoutError.name) + assert.strictEqual(e.name, error.ScriptTimeoutError.name) } }) }) @@ -369,7 +378,7 @@ suite(function (env) { function verifyJson(expected) { return function (actual) { - assert.equal(JSON.stringify(actual), JSON.stringify(expected)) + assert.strictEqual(JSON.stringify(actual), JSON.stringify(expected)) } } diff --git a/javascript/node/selenium-webdriver/test/firefox_test.js b/javascript/node/selenium-webdriver/test/firefox_test.js index cb8eb2fa42983..0676de8cba1a0 100644 --- a/javascript/node/selenium-webdriver/test/firefox_test.js +++ b/javascript/node/selenium-webdriver/test/firefox_test.js @@ -192,17 +192,17 @@ suite( }) it('can get context', async function () { - assert.equal(await driver.getContext(), Context.CONTENT) + assert.strictEqual(await driver.getContext(), Context.CONTENT) }) it('can set context', async function () { await driver.setContext(Context.CHROME) let ctxt = await driver.getContext() - assert.equal(ctxt, Context.CHROME) + assert.strictEqual(ctxt, Context.CHROME) await driver.setContext(Context.CONTENT) ctxt = await driver.getContext() - assert.equal(ctxt, Context.CONTENT) + assert.strictEqual(ctxt, Context.CONTENT) }) it('throws on unknown context', function () { @@ -233,14 +233,14 @@ suite( let userAgent = await driver.executeScript( 'return window.navigator.userAgent' ) - assert.equal(userAgent, 'foo;bar') + assert.strictEqual(userAgent, 'foo;bar') } async function verifyWebExtensionNotInstalled() { let found = await driver.findElements({ id: 'webextensions-selenium-example', }) - assert.equal(found.length, 0) + assert.strictEqual(found.length, 0) } async function verifyWebExtensionWasInstalled() { @@ -248,7 +248,10 @@ suite( id: 'webextensions-selenium-example', }) let text = await footer.getText() - assert.equal(text, 'Content injected by webextensions-selenium-example') + assert.strictEqual( + text, + 'Content injected by webextensions-selenium-example' + ) } }) }, diff --git a/javascript/node/selenium-webdriver/test/frame_test.js b/javascript/node/selenium-webdriver/test/frame_test.js index 2216ed01bcf79..26bc6c1ae7d3c 100644 --- a/javascript/node/selenium-webdriver/test/frame_test.js +++ b/javascript/node/selenium-webdriver/test/frame_test.js @@ -40,12 +40,12 @@ test.suite(function (env) { let frame = await driver.findElement(By.name('iframe1-name')) await driver.switchTo().frame(frame) - assert.equal( + assert.strictEqual( await driver.executeScript('return document.title'), 'We Leave From Here' ) await driver.switchTo().parentFrame() - assert.equal( + assert.strictEqual( await driver.executeScript('return document.title'), 'This page has iframes' ) diff --git a/javascript/node/selenium-webdriver/test/http/http_test.js b/javascript/node/selenium-webdriver/test/http/http_test.js index 8ac3d6f85ced9..532c56bb22eb1 100644 --- a/javascript/node/selenium-webdriver/test/http/http_test.js +++ b/javascript/node/selenium-webdriver/test/http/http_test.js @@ -113,12 +113,12 @@ describe('HttpClient', function () { const client = new HttpClient(server.url(), agent) return client.send(request).then(function (response) { - assert.equal(200, response.status) + assert.strictEqual(200, response.status) const headers = JSON.parse(response.body) - assert.equal(headers['content-length'], '0') - assert.equal(headers['connection'], 'keep-alive') - assert.equal(headers['host'], server.host()) + assert.strictEqual(headers['content-length'], '0') + assert.strictEqual(headers['connection'], 'keep-alive') + assert.strictEqual(headers['host'], server.host()) const regex = /^selenium\/.* \(js (windows|mac|linux)\)$/ assert.ok( @@ -126,8 +126,8 @@ describe('HttpClient', function () { `${headers['user-agent']} does not match ${regex}` ) - assert.equal(request.headers.get('Foo'), 'Bar') - assert.equal( + assert.strictEqual(request.headers.get('Foo'), 'Bar') + assert.strictEqual( request.headers.get('Accept'), 'application/json; charset=utf-8' ) @@ -139,8 +139,8 @@ describe('HttpClient', function () { let client = new HttpClient(server.url()) return client.send(request).then((response) => { - assert.equal(200, response.status) - assert.equal(response.body, '

Hello, world!

') + assert.strictEqual(200, response.status) + assert.strictEqual(response.body, '

Hello, world!

') }) }) @@ -152,9 +152,9 @@ describe('HttpClient', function () { const client = new HttpClient(url.format(parsed)) const request = new HttpRequest('GET', '/protected') return client.send(request).then(function (response) { - assert.equal(200, response.status) - assert.equal(response.headers.get('content-type'), 'text/plain') - assert.equal(response.body, 'Access granted!') + assert.strictEqual(200, response.status) + assert.strictEqual(response.headers.get('content-type'), 'text/plain') + assert.strictEqual(response.body, 'Access granted!') }) }) @@ -162,8 +162,8 @@ describe('HttpClient', function () { const client = new HttpClient(server.url()) const request = new HttpRequest('GET', '/protected') return client.send(request).then(function (response) { - assert.equal(401, response.status) - assert.equal(response.body, 'Access denied') + assert.strictEqual(401, response.status) + assert.strictEqual(response.body, 'Access denied') }) }) @@ -171,9 +171,9 @@ describe('HttpClient', function () { const request = new HttpRequest('GET', '/redirect') const client = new HttpClient(server.url()) return client.send(request).then(function (response) { - assert.equal(200, response.status) - assert.equal(response.headers.get('content-type'), 'text/plain') - assert.equal(response.body, 'hello, world!') + assert.strictEqual(200, response.status) + assert.strictEqual(response.headers.get('content-type'), 'text/plain') + assert.strictEqual(response.body, 'hello, world!') }) }) @@ -197,9 +197,9 @@ describe('HttpClient', function () { server.url() ) return client.send(request).then(function (response) { - assert.equal(200, response.status) - assert.equal(response.headers.get('host'), 'another.server.com') - assert.equal( + assert.strictEqual(200, response.status) + assert.strictEqual(response.headers.get('host'), 'another.server.com') + assert.strictEqual( response.headers.get('x-proxy-request-uri'), 'http://another.server.com/proxy' ) @@ -214,9 +214,9 @@ describe('HttpClient', function () { server.url() ) return client.send(request).then(function (response) { - assert.equal(200, response.status) - assert.equal(response.headers.get('host'), 'another.server.com') - assert.equal( + assert.strictEqual(200, response.status) + assert.strictEqual(response.headers.get('host'), 'another.server.com') + assert.strictEqual( response.headers.get('x-proxy-request-uri'), 'http://another.server.com/proxy' ) @@ -231,9 +231,9 @@ describe('HttpClient', function () { server.url() ) return client.send(request).then(function (response) { - assert.equal(200, response.status) - assert.equal(response.headers.get('host'), 'another.server.com') - assert.equal( + assert.strictEqual(200, response.status) + assert.strictEqual(response.headers.get('host'), 'another.server.com') + assert.strictEqual( response.headers.get('x-proxy-request-uri'), 'http://another.server.com/proxy?foo#bar' ) diff --git a/javascript/node/selenium-webdriver/test/http/util_test.js b/javascript/node/selenium-webdriver/test/http/util_test.js index e515cd94d35c9..b772881996e95 100644 --- a/javascript/node/selenium-webdriver/test/http/util_test.js +++ b/javascript/node/selenium-webdriver/test/http/util_test.js @@ -67,7 +67,7 @@ describe('selenium-webdriver/http/util', function () { describe('#getStatus', function () { it('should return value field on success', function () { return util.getStatus(baseUrl).then(function (response) { - assert.equal('abc123', response) + assert.strictEqual('abc123', response) }) }) @@ -79,8 +79,8 @@ describe('selenium-webdriver/http/util', function () { }, function (err) { assert.ok(err instanceof error.WebDriverError) - assert.equal(err.code, error.WebDriverError.code) - assert.equal(err.message, value) + assert.strictEqual(err.code, error.WebDriverError.code) + assert.strictEqual(err.message, value) } ) }) @@ -110,8 +110,8 @@ describe('selenium-webdriver/http/util', function () { }, function (err) { assert.ok(err instanceof error.WebDriverError) - assert.equal(err.code, error.WebDriverError.code) - assert.equal(err.message, value) + assert.strictEqual(err.code, error.WebDriverError.code) + assert.strictEqual(err.message, value) } ) }) diff --git a/javascript/node/selenium-webdriver/test/ie/options_test.js b/javascript/node/selenium-webdriver/test/ie/options_test.js index d07d3d87c951b..baaf0a18c1442 100644 --- a/javascript/node/selenium-webdriver/test/ie/options_test.js +++ b/javascript/node/selenium-webdriver/test/ie/options_test.js @@ -37,7 +37,7 @@ test.suite( caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[ ie.Key.FILE_UPLOAD_DIALOG_TIMEOUT ] - assert.equal(caps, timeOut) + assert.strictEqual(caps, timeOut) await driver.quit() }) @@ -51,7 +51,7 @@ test.suite( caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[ ie.Key.BROWSER_ATTACH_TIMEOUT ] - assert.equal(caps, timeOut) + assert.strictEqual(caps, timeOut) await driver.quit() }) @@ -63,7 +63,7 @@ test.suite( caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[ ie.Key.ELEMENT_SCROLL_BEHAVIOR ] - assert.equal(caps, ie.Behavior.TOP) + assert.strictEqual(caps, ie.Behavior.TOP) await driver.quit() }) @@ -75,7 +75,7 @@ test.suite( caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[ ie.Key.ELEMENT_SCROLL_BEHAVIOR ] - assert.equal(caps, ie.Behavior.TOP) + assert.strictEqual(caps, ie.Behavior.TOP) await driver.quit() }) @@ -90,16 +90,16 @@ test.suite( caps = caps.map_.get(ie.VENDOR_COMMAND_PREFIX)[ ie.Key.BROWSER_COMMAND_LINE_SWITCHES ] - assert.equal(caps, '-k -private') + assert.strictEqual(caps, '-k -private') await driver.quit() }) it('can set capability', async function () { let caps = Capabilities.ie() assert.ok(!caps.has('silent')) - assert.equal(undefined, caps.get('silent')) + assert.strictEqual(undefined, caps.get('silent')) caps.set('silent', true) - assert.equal(true, caps.get('silent')) + assert.strictEqual(true, caps.get('silent')) assert.ok(caps.has('silent')) }) }) diff --git a/javascript/node/selenium-webdriver/test/io/io_test.js b/javascript/node/selenium-webdriver/test/io/io_test.js index 88b3cad22b596..8ca1079b7a63a 100644 --- a/javascript/node/selenium-webdriver/test/io/io_test.js +++ b/javascript/node/selenium-webdriver/test/io/io_test.js @@ -38,8 +38,8 @@ describe('io', function () { it('can copy one file to another', function () { return io.tmpFile().then(function (f) { return io.copy(path.join(tmpDir, 'foo'), f).then(function (p) { - assert.equal(p, f) - assert.equal('Hello, world', fs.readFileSync(p)) + assert.strictEqual(p, f) + assert.strictEqual('Hello, world', fs.readFileSync(p)) }) }) }) @@ -56,8 +56,8 @@ describe('io', function () { return io .copy(path.join(tmpDir, 'symlinked-foo'), f) .then(function (p) { - assert.equal(p, f) - assert.equal('Hello, world', fs.readFileSync(p)) + assert.strictEqual(p, f) + assert.strictEqual('Hello, world', fs.readFileSync(p)) }) }) }) @@ -89,10 +89,13 @@ describe('io', function () { return io.tmpDir().then(function (dst) { return io.copyDir(dir, dst).then(function (ret) { - assert.equal(dst, ret) + assert.strictEqual(dst, ret) - assert.equal('hello', fs.readFileSync(path.join(dst, 'file1'))) - assert.equal( + assert.strictEqual( + 'hello', + fs.readFileSync(path.join(dst, 'file1')) + ) + assert.strictEqual( 'goodbye', fs.readFileSync(path.join(dst, 'sub/folder/file2')) ) @@ -111,8 +114,8 @@ describe('io', function () { }) }) .then(function (p) { - assert.equal('sub', path.basename(p)) - assert.equal('hi', fs.readFileSync(path.join(p, 'foo'))) + assert.strictEqual('sub', path.basename(p)) + assert.strictEqual('hi', fs.readFileSync(path.join(p, 'foo'))) }) }) @@ -132,9 +135,9 @@ describe('io', function () { }) }) .then(function (dir) { - assert.equal('a', fs.readFileSync(path.join(dir, 'foo'))) - assert.equal('c', fs.readFileSync(path.join(dir, 'baz'))) - assert.equal('e', fs.readFileSync(path.join(dir, 'sub/quot'))) + assert.strictEqual('a', fs.readFileSync(path.join(dir, 'foo'))) + assert.strictEqual('c', fs.readFileSync(path.join(dir, 'baz'))) + assert.strictEqual('e', fs.readFileSync(path.join(dir, 'sub/quot'))) assert.ok(!fs.existsSync(path.join(dir, 'bar'))) assert.ok(!fs.existsSync(path.join(dir, 'sub/quux'))) @@ -161,9 +164,9 @@ describe('io', function () { }) }) .then(function (dir) { - assert.equal('b', fs.readFileSync(path.join(dir, 'bar'))) - assert.equal('c', fs.readFileSync(path.join(dir, 'baz'))) - assert.equal('d', fs.readFileSync(path.join(dir, 'sub/quux'))) + assert.strictEqual('b', fs.readFileSync(path.join(dir, 'bar'))) + assert.strictEqual('c', fs.readFileSync(path.join(dir, 'baz'))) + assert.strictEqual('d', fs.readFileSync(path.join(dir, 'sub/quux'))) assert.ok(!fs.existsSync(path.join(dir, 'foo'))) assert.ok(!fs.existsSync(path.join(dir, 'sub/quot'))) @@ -328,7 +331,7 @@ describe('io', function () { it('can read a file', function () { return io.read(path.join(tmpDir, 'foo')).then((buff) => { assert.ok(buff instanceof Buffer) - assert.equal('Hello, world', buff.toString()) + assert.strictEqual('Hello, world', buff.toString()) }) }) @@ -342,7 +345,7 @@ describe('io', function () { it('rejects returned promise if file does not exist', function () { return io.read(path.join(tmpDir, 'not-there')).then( () => assert.fail('should have failed'), - (e) => assert.equal('ENOENT', e.code) + (e) => assert.strictEqual('ENOENT', e.code) ) }) }) diff --git a/javascript/node/selenium-webdriver/test/io/zip_test.js b/javascript/node/selenium-webdriver/test/io/zip_test.js index b53ae742e4298..280281414c9a7 100644 --- a/javascript/node/selenium-webdriver/test/io/zip_test.js +++ b/javascript/node/selenium-webdriver/test/io/zip_test.js @@ -94,7 +94,7 @@ describe('io/zip', function () { return z.getFile('foo') }) .then((buffer) => - assert.equal(buffer.toString('utf8'), 'hello, world!') + assert.strictEqual(buffer.toString('utf8'), 'hello, world!') ) }) @@ -120,7 +120,7 @@ describe('io/zip', function () { (e) => assert.strictEqual(e.constructor, InvalidArgumentError) ) .then(() => z.getFile('foo/aFile')) - .then((b) => assert.equal(b.toString('utf8'), 'hello, world!')) + .then((b) => assert.strictEqual(b.toString('utf8'), 'hello, world!')) }) }) }) diff --git a/javascript/node/selenium-webdriver/test/lib/by_test.js b/javascript/node/selenium-webdriver/test/lib/by_test.js index 005b613dc6782..3fa92f8834b85 100644 --- a/javascript/node/selenium-webdriver/test/lib/by_test.js +++ b/javascript/node/selenium-webdriver/test/lib/by_test.js @@ -25,64 +25,64 @@ describe('by', function () { describe('className', function () { it('delegates to By.css', function () { let locator = by.By.className('foo') - assert.equal('css selector', locator.using) - assert.equal('.foo', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('.foo', locator.value) }) it('escapes class name', function () { let locator = by.By.className('foo#bar') - assert.equal('css selector', locator.using) - assert.equal('.foo\\#bar', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('.foo\\#bar', locator.value) }) it('translates compound class names', function () { let locator = by.By.className('a b') - assert.equal('css selector', locator.using) - assert.equal('.a.b', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('.a.b', locator.value) locator = by.By.className(' x y z-1 "g" ') - assert.equal('css selector', locator.using) - assert.equal('.x.y.z-1.\\"g\\"', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('.x.y.z-1.\\"g\\"', locator.value) }) }) describe('id', function () { it('delegates to By.css', function () { let locator = by.By.id('foo') - assert.equal('css selector', locator.using) - assert.equal('*[id="foo"]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[id="foo"]', locator.value) }) it('escapes the ID', function () { let locator = by.By.id('foo#bar') - assert.equal('css selector', locator.using) - assert.equal('*[id="foo\\#bar"]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[id="foo\\#bar"]', locator.value) }) }) describe('name', function () { it('delegates to By.css', function () { let locator = by.By.name('foo') - assert.equal('css selector', locator.using) - assert.equal('*[name="foo"]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[name="foo"]', locator.value) }) it('escapes the name', function () { let locator = by.By.name('foo"bar"') - assert.equal('css selector', locator.using) - assert.equal('*[name="foo\\"bar\\""]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[name="foo\\"bar\\""]', locator.value) }) it('escapes the name when it starts with a number', function () { let locator = by.By.name('123foo"bar"') - assert.equal('css selector', locator.using) - assert.equal('*[name="\\31 23foo\\"bar\\""]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[name="\\31 23foo\\"bar\\""]', locator.value) }) it('escapes the name when it starts with a negative number', function () { let locator = by.By.name('-123foo"bar"') - assert.equal('css selector', locator.using) - assert.equal('*[name="-\\31 23foo\\"bar\\""]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[name="-\\31 23foo\\"bar\\""]', locator.value) }) }) }) @@ -98,7 +98,7 @@ describe('by', function () { ], }, } - assert.deepEqual(relative.marshall(), expected) + assert.deepStrictEqual(relative.marshall(), expected) }) }) @@ -120,56 +120,56 @@ describe('by', function () { let fakeBy = { using: 'id', value: 'foo' } let locator = by.checkedLocator(fakeBy) assert.strictEqual(locator.constructor, by.By) - assert.equal(locator.using, 'id') - assert.equal(locator.value, 'foo') + assert.strictEqual(locator.using, 'id') + assert.strictEqual(locator.value, 'foo') }) it('accepts class name', function () { let locator = by.checkedLocator({ className: 'foo' }) - assert.equal('css selector', locator.using) - assert.equal('.foo', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('.foo', locator.value) }) it('accepts css', function () { let locator = by.checkedLocator({ css: 'a > b' }) - assert.equal('css selector', locator.using) - assert.equal('a > b', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('a > b', locator.value) }) it('accepts id', function () { let locator = by.checkedLocator({ id: 'foobar' }) - assert.equal('css selector', locator.using) - assert.equal('*[id="foobar"]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[id="foobar"]', locator.value) }) it('accepts linkText', function () { let locator = by.checkedLocator({ linkText: 'hello' }) - assert.equal('link text', locator.using) - assert.equal('hello', locator.value) + assert.strictEqual('link text', locator.using) + assert.strictEqual('hello', locator.value) }) it('accepts name', function () { let locator = by.checkedLocator({ name: 'foobar' }) - assert.equal('css selector', locator.using) - assert.equal('*[name="foobar"]', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('*[name="foobar"]', locator.value) }) it('accepts partialLinkText', function () { let locator = by.checkedLocator({ partialLinkText: 'hello' }) - assert.equal('partial link text', locator.using) - assert.equal('hello', locator.value) + assert.strictEqual('partial link text', locator.using) + assert.strictEqual('hello', locator.value) }) it('accepts tagName', function () { let locator = by.checkedLocator({ tagName: 'div' }) - assert.equal('css selector', locator.using) - assert.equal('div', locator.value) + assert.strictEqual('css selector', locator.using) + assert.strictEqual('div', locator.value) }) it('accepts xpath', function () { let locator = by.checkedLocator({ xpath: '//div[1]' }) - assert.equal('xpath', locator.using) - assert.equal('//div[1]', locator.value) + assert.strictEqual('xpath', locator.using) + assert.strictEqual('//div[1]', locator.value) }) }) }) diff --git a/javascript/node/selenium-webdriver/test/lib/capabilities_test.js b/javascript/node/selenium-webdriver/test/lib/capabilities_test.js index a620c5e3a9310..e691535d7dc28 100644 --- a/javascript/node/selenium-webdriver/test/lib/capabilities_test.js +++ b/javascript/node/selenium-webdriver/test/lib/capabilities_test.js @@ -33,15 +33,15 @@ const Pages = test.Pages describe('Capabilities', function () { it('can set and unset a capability', function () { let caps = new Capabilities() - assert.equal(undefined, caps.get('foo')) + assert.strictEqual(undefined, caps.get('foo')) assert.ok(!caps.has('foo')) caps.set('foo', 'bar') - assert.equal('bar', caps.get('foo')) + assert.strictEqual('bar', caps.get('foo')) assert.ok(caps.has('foo')) caps.set('foo', null) - assert.equal(null, caps.get('foo')) + assert.strictEqual(null, caps.get('foo')) assert.ok(caps.has('foo')) }) @@ -55,39 +55,39 @@ describe('Capabilities', function () { const caps2 = new Capabilities().set('color', 'green') - assert.equal('bar', caps1.get('foo')) - assert.equal('red', caps1.get('color')) - assert.equal('green', caps2.get('color')) - assert.equal(undefined, caps2.get('foo')) + assert.strictEqual('bar', caps1.get('foo')) + assert.strictEqual('red', caps1.get('color')) + assert.strictEqual('green', caps2.get('color')) + assert.strictEqual(undefined, caps2.get('foo')) caps2.merge(caps1) - assert.equal('bar', caps1.get('foo')) - assert.equal('red', caps1.get('color')) - assert.equal('red', caps2.get('color')) - assert.equal('bar', caps2.get('foo')) + assert.strictEqual('bar', caps1.get('foo')) + assert.strictEqual('red', caps1.get('color')) + assert.strictEqual('red', caps2.get('color')) + assert.strictEqual('bar', caps2.get('foo')) const caps3 = new Map().set('color', 'blue') caps2.merge(caps3) - assert.equal('blue', caps2.get('color')) - assert.equal('bar', caps2.get('foo')) + assert.strictEqual('blue', caps2.get('color')) + assert.strictEqual('bar', caps2.get('foo')) const caps4 = { foo: 'baz' } const caps5 = caps2.merge(caps4) - assert.equal('blue', caps2.get('color')) - assert.equal('baz', caps2.get('foo')) - assert.equal('blue', caps5.get('color')) - assert.equal('baz', caps5.get('foo')) - assert.equal(true, caps5 instanceof Capabilities) - assert.equal(caps2, caps5) + assert.strictEqual('blue', caps2.get('color')) + assert.strictEqual('baz', caps2.get('foo')) + assert.strictEqual('blue', caps5.get('color')) + assert.strictEqual('baz', caps5.get('foo')) + assert.strictEqual(true, caps5 instanceof Capabilities) + assert.strictEqual(caps2, caps5) }) it('can be initialized from a hash object', function () { let caps = new Capabilities({ one: 123, abc: 'def' }) - assert.equal(123, caps.get('one')) - assert.equal('def', caps.get('abc')) + assert.strictEqual(123, caps.get('one')) + assert.strictEqual('def', caps.get('abc')) }) it('can be initialized from a map', function () { @@ -97,8 +97,8 @@ describe('Capabilities', function () { ]) let caps = new Capabilities(m) - assert.equal(123, caps.get('one')) - assert.equal('def', caps.get('abc')) + assert.strictEqual(123, caps.get('one')) + assert.strictEqual('def', caps.get('abc')) }) describe('serialize', function () { @@ -108,7 +108,10 @@ describe('Capabilities', function () { ['abc', 'def'], ]) let caps = new Capabilities(m) - assert.deepEqual({ one: 123, abc: 'def' }, caps[Symbols.serialize]()) + assert.deepStrictEqual( + { one: 123, abc: 'def' }, + caps[Symbols.serialize]() + ) }) it('does not omit capabilities set to a false-like value', function () { @@ -117,7 +120,7 @@ describe('Capabilities', function () { caps.set('number', 0) caps.set('string', '') - assert.deepEqual( + assert.deepStrictEqual( { bool: false, number: 0, string: '' }, caps[Symbols.serialize]() ) @@ -127,14 +130,14 @@ describe('Capabilities', function () { let caps = new Capabilities() caps.set('foo', null) caps.set('bar', 123) - assert.deepEqual({ bar: 123 }, caps[Symbols.serialize]()) + assert.deepStrictEqual({ bar: 123 }, caps[Symbols.serialize]()) }) it('omits capabilities with an undefined value', function () { let caps = new Capabilities() caps.set('foo', undefined) caps.set('bar', 123) - assert.deepEqual({ bar: 123 }, caps[Symbols.serialize]()) + assert.deepStrictEqual({ bar: 123 }, caps[Symbols.serialize]()) }) }) }) @@ -207,7 +210,7 @@ test.suite(function (env) { var frame = await driver.findElement(By.id('upload_target')) await driver.switchTo().frame(frame) - assert.equal( + assert.strictEqual( await driver.findElement(By.css('body')).getText(), LOREM_IPSUM_TEXT ) diff --git a/javascript/node/selenium-webdriver/test/lib/error_test.js b/javascript/node/selenium-webdriver/test/lib/error_test.js index 599f7d60d47b5..d313a3e2cd39c 100644 --- a/javascript/node/selenium-webdriver/test/lib/error_test.js +++ b/javascript/node/selenium-webdriver/test/lib/error_test.js @@ -26,7 +26,7 @@ describe('error', function () { assert.throws( () => error.checkResponse({ error: 'foo', message: 'hi there' }), (e) => { - assert.equal(e.constructor, error.WebDriverError) + assert.strictEqual(e.constructor, error.WebDriverError) return true } ) @@ -71,8 +71,8 @@ describe('error', function () { assert.throws( () => error.checkResponse({ error: status, message: 'oops' }), (e) => { - assert.equal(expectedType, e.constructor) - assert.equal(e.message, 'oops') + assert.strictEqual(expectedType, e.constructor) + assert.strictEqual(e.message, 'oops') return true } ) @@ -139,7 +139,7 @@ describe('error', function () { assert.throws( () => error.throwDecodedError({ error: 'foo', message: 'hi there' }), (e) => { - assert.equal(e.constructor, error.WebDriverError) + assert.strictEqual(e.constructor, error.WebDriverError) return true } ) @@ -302,9 +302,9 @@ describe('error', function () { assert.throws( () => error.checkLegacyResponse(response), (e) => { - assert.equal(error.UnexpectedAlertOpenError, e.constructor) - assert.equal(e.message, 'hi') - assert.equal(e.getAlertText(), 'alert text here') + assert.strictEqual(error.UnexpectedAlertOpenError, e.constructor) + assert.strictEqual(e.message, 'hi') + assert.strictEqual(e.getAlertText(), 'alert text here') return true } ) @@ -320,9 +320,9 @@ describe('error', function () { assert.throws( () => error.checkLegacyResponse(response), (e) => { - assert.equal(error.UnexpectedAlertOpenError, e.constructor) - assert.equal(e.message, 'hi') - assert.equal(e.getAlertText(), '') + assert.strictEqual(error.UnexpectedAlertOpenError, e.constructor) + assert.strictEqual(e.message, 'hi') + assert.strictEqual(e.getAlertText(), '') return true } ) @@ -336,8 +336,8 @@ describe('error', function () { assert.throws( () => error.checkLegacyResponse(resp), (e) => { - assert.equal(expectedType, e.constructor) - assert.equal(e.message, 'hi') + assert.strictEqual(expectedType, e.constructor) + assert.strictEqual(e.message, 'hi') return true } ) diff --git a/javascript/node/selenium-webdriver/test/lib/http_test.js b/javascript/node/selenium-webdriver/test/lib/http_test.js index 2e37ee3a32252..2519f9f4e1a35 100644 --- a/javascript/node/selenium-webdriver/test/lib/http_test.js +++ b/javascript/node/selenium-webdriver/test/lib/http_test.js @@ -33,8 +33,8 @@ describe('http', function () { it('properly replaces path segments with command parameters', function () { var parameters = { sessionId: 'foo', url: 'http://www.google.com' } var finalPath = http.buildPath('/session/:sessionId/url', parameters) - assert.equal(finalPath, '/session/foo/url') - assert.deepEqual(parameters, { url: 'http://www.google.com' }) + assert.strictEqual(finalPath, '/session/foo/url') + assert.deepStrictEqual(parameters, { url: 'http://www.google.com' }) }) it('handles web element references', function () { @@ -44,8 +44,8 @@ describe('http', function () { '/session/:sessionId/element/:id/click', parameters ) - assert.equal(finalPath, '/session/foo/element/bar/click') - assert.deepEqual(parameters, {}) + assert.strictEqual(finalPath, '/session/foo/element/bar/click') + assert.deepStrictEqual(parameters, {}) }) it('throws if missing a parameter', function () { @@ -74,7 +74,7 @@ describe('http', function () { }) it('does not match on segments that do not start with a colon', function () { - assert.equal( + assert.strictEqual( http.buildPath('/session/foo:bar/baz', {}), '/session/foo:bar/baz' ) @@ -144,7 +144,7 @@ describe('http', function () { return Promise.reject(Error('should have thrown')) } catch (err) { assert.strictEqual(err.constructor, error.InvalidArgumentError) - assert.equal(err.message, 'Missing required parameter: id') + assert.strictEqual(err.message, 'Missing required parameter: id') } assert.ok(!send.called) }) @@ -330,11 +330,11 @@ describe('http', function () { assert.ok(!executor.w3c) return executor.execute(command).then(function (response) { assert.ok(response instanceof Session) - assert.equal(response.getId(), 's123') + assert.strictEqual(response.getId(), 's123') let caps = response.getCapabilities() assert.ok(caps instanceof Capabilities) - assert.equal(caps.get('name'), 'Bob') + assert.strictEqual(caps.get('name'), 'Bob') assert.ok(!executor.w3c) }) @@ -359,11 +359,11 @@ describe('http', function () { assert.ok(!executor.w3c) return executor.execute(command).then(function (response) { assert.ok(response instanceof Session) - assert.equal(response.getId(), 's123') + assert.strictEqual(response.getId(), 's123') let caps = response.getCapabilities() assert.ok(caps instanceof Capabilities) - assert.equal(caps.get('name'), 'Bob') + assert.strictEqual(caps.get('name'), 'Bob') assert.ok(executor.w3c) }) @@ -381,8 +381,8 @@ describe('http', function () { executor.w3c = true return executor.execute(command).then(function (response) { assert.ok(response instanceof Session) - assert.equal(response.getId(), 's123') - assert.equal(response.getCapabilities().size, 0) + assert.strictEqual(response.getId(), 's123') + assert.strictEqual(response.getCapabilities().size, 0) assert.ok(executor.w3c, 'should never downgrade') }) }) @@ -403,7 +403,7 @@ describe('http', function () { () => assert.fail('should have failed'), (e) => { assert.ok(e instanceof error.NoSuchElementError) - assert.equal(e.message, 'hi') + assert.strictEqual(e.message, 'hi') } ) }) @@ -423,7 +423,7 @@ describe('http', function () { () => assert.fail('should have failed'), (e) => { assert.ok(e instanceof error.NoSuchElementError) - assert.equal(e.message, 'oops') + assert.strictEqual(e.message, 'oops') } ) }) @@ -676,10 +676,10 @@ describe('http', function () { assert.ok( send.calledWith( sinon.match(function (value) { - assert.equal(value.method, method) - assert.equal(value.path, path) - assert.deepEqual(value.data, data) - assert.deepEqual(entries(value.headers), headers) + assert.strictEqual(value.method, method) + assert.strictEqual(value.path, path) + assert.deepStrictEqual(value.data, data) + assert.deepStrictEqual(entries(value.headers), headers) return true }) ) diff --git a/javascript/node/selenium-webdriver/test/lib/input_test.js b/javascript/node/selenium-webdriver/test/lib/input_test.js index 0f90ccc36cb92..53f03de70f03d 100644 --- a/javascript/node/selenium-webdriver/test/lib/input_test.js +++ b/javascript/node/selenium-webdriver/test/lib/input_test.js @@ -51,13 +51,13 @@ describe('input.Actions', function () { ) await new input.Actions(executor).perform() - assert.deepEqual(executor.commands, []) + assert.deepStrictEqual(executor.commands, []) await new input.Actions(executor).pause().perform() - assert.deepEqual(executor.commands, []) + assert.deepStrictEqual(executor.commands, []) await new input.Actions(executor).pause(1).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -81,7 +81,7 @@ describe('input.Actions', function () { executor.commands.length = 0 let actions = new input.Actions(executor) await actions.pause(1, actions.keyboard()).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -115,10 +115,10 @@ describe('input.Actions', function () { } await actions.perform() - assert.deepEqual(executor.commands, [expected]) + assert.deepStrictEqual(executor.commands, [expected]) await actions.perform() - assert.deepEqual(executor.commands, [expected, expected]) + assert.deepStrictEqual(executor.commands, [expected, expected]) }) }) @@ -128,7 +128,7 @@ describe('input.Actions', function () { await new input.Actions(executor).pause(3).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -155,7 +155,7 @@ describe('input.Actions', function () { await new input.Actions(executor).pause().pause(3).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -192,7 +192,7 @@ describe('input.Actions', function () { .pause(100, actions.mouse()) .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -229,7 +229,7 @@ describe('input.Actions', function () { .pause(100, actions.mouse()) .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -257,7 +257,7 @@ describe('input.Actions', function () { await actions.pause(100, actions.keyboard(), actions.keyboard()).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -282,7 +282,7 @@ describe('input.Actions', function () { let executor = new StubExecutor(Promise.resolve()) await new input.Actions(executor).keyDown('\u0041\u030a').perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -313,7 +313,7 @@ describe('input.Actions', function () { let executor = new StubExecutor(Promise.resolve()) await new input.Actions(executor).keyUp('\u0041\u030a').perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -345,7 +345,7 @@ describe('input.Actions', function () { const actions = new input.Actions(executor) await actions.sendKeys('a').perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -369,7 +369,7 @@ describe('input.Actions', function () { const actions = new input.Actions(executor) await actions.sendKeys('a', 'b').perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -395,7 +395,7 @@ describe('input.Actions', function () { const actions = new input.Actions(executor) await actions.sendKeys('a', 'bc', 'd').perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -425,7 +425,7 @@ describe('input.Actions', function () { const actions = new input.Actions(executor) await actions.sendKeys('ab').pause(100, actions.mouse()).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -464,7 +464,7 @@ describe('input.Actions', function () { const actions = new input.Actions(executor, { async: true }) await actions.sendKeys('ab').pause(100, actions.mouse()).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -490,6 +490,21 @@ describe('input.Actions', function () { }, ]) }) + + it('string length > 500', async function () { + const executor = new StubExecutor(Promise.resolve()) + const actions = new input.Actions(executor, { async: true }) + let str = '' + for (let i = 0; i < 501; i++) { + str += i + } + const executionResult = await actions + .sendKeys(str) + .perform() + .then(() => true) + .catch(() => false) + assert.strictEqual(executionResult, true) + }) }) describe('click()', function () { @@ -498,7 +513,7 @@ describe('input.Actions', function () { const actions = new input.Actions(executor) await actions.click().perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -525,7 +540,7 @@ describe('input.Actions', function () { const fakeElement = {} await actions.click(fakeElement).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -559,7 +574,7 @@ describe('input.Actions', function () { const fakeElement = {} await actions.click(fakeElement).sendKeys('a').perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -609,7 +624,7 @@ describe('input.Actions', function () { await actions.dragAndDrop(e1, e2).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -650,7 +665,7 @@ describe('input.Actions', function () { await actions.dragAndDrop(e1, { x: 30, y: 40 }).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -781,7 +796,7 @@ describe('input.Actions', function () { .sendKeys('de') .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -859,7 +874,7 @@ describe('input.Actions', function () { .release(input.Button.LEFT) .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -901,7 +916,7 @@ describe('input.Actions', function () { .release(input.Button.RIGHT) .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -949,7 +964,7 @@ describe('input.Actions', function () { await actions.click().perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -986,7 +1001,7 @@ describe('input.Actions', function () { .release(input.Button.RIGHT) .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1020,7 +1035,7 @@ describe('input.Actions', function () { await actions.contextClick().perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1057,7 +1072,7 @@ describe('input.Actions', function () { await actions.click(element).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1120,7 +1135,7 @@ describe('input.Actions', function () { .release(input.Button.LEFT) .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1156,7 +1171,7 @@ describe('input.Actions', function () { await actions.doubleClick().perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1193,7 +1208,7 @@ describe('input.Actions', function () { await actions.click().contextClick().perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1236,7 +1251,7 @@ describe('input.Actions', function () { await actions.doubleClick(element).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1305,7 +1320,7 @@ describe('input.Actions', function () { .doubleClick() .perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { @@ -1387,7 +1402,7 @@ describe('input.Actions', function () { await actions.dragAndDrop(e1, e2).perform() - assert.deepEqual(executor.commands, [ + assert.deepStrictEqual(executor.commands, [ { name: command.Name.ACTIONS, parameters: { diff --git a/javascript/node/selenium-webdriver/test/lib/logging_test.js b/javascript/node/selenium-webdriver/test/lib/logging_test.js index c847aec886c4d..d683125611fa1 100644 --- a/javascript/node/selenium-webdriver/test/lib/logging_test.js +++ b/javascript/node/selenium-webdriver/test/lib/logging_test.js @@ -171,9 +171,9 @@ describe('logging', function () { log4.warning('this is a warning message') log4.severe('this is a severe message') - assert.equal(4, cb1.callCount) - assert.equal(4, cb2.callCount) - assert.equal(4, cb3.callCount) + assert.strictEqual(4, cb1.callCount) + assert.strictEqual(4, cb2.callCount) + assert.strictEqual(4, cb3.callCount) const entry1 = new logging.Entry( logging.Level.FINER, @@ -212,9 +212,9 @@ describe('logging', function () { check(cb3.getCall(3).args[0], entry4) function check(entry, expected) { - assert.equal(entry.level, expected.level, 'wrong level') - assert.equal(entry.message, expected.message, 'wrong message') - assert.equal(entry.timestamp, expected.timestamp, 'wrong time') + assert.strictEqual(entry.level, expected.level, 'wrong level') + assert.strictEqual(entry.message, expected.message, 'wrong message') + assert.strictEqual(entry.timestamp, expected.timestamp, 'wrong time') } }) @@ -224,11 +224,11 @@ describe('logging', function () { root.addHandler(cb) root.info('hi') - assert.equal(1, cb.callCount) + assert.strictEqual(1, cb.callCount) assert(root.removeHandler(cb)) root.info('bye') - assert.equal(1, cb.callCount) + assert.strictEqual(1, cb.callCount) assert(!root.removeHandler(cb)) }) @@ -268,13 +268,16 @@ describe('logging', function () { describe('Preferences', function () { it('can be converted to JSON', function () { let prefs = new logging.Preferences() - assert.equal('{}', JSON.stringify(prefs)) + assert.strictEqual('{}', JSON.stringify(prefs)) prefs.setLevel('foo', logging.Level.DEBUG) - assert.equal('{"foo":"DEBUG"}', JSON.stringify(prefs)) + assert.strictEqual('{"foo":"DEBUG"}', JSON.stringify(prefs)) prefs.setLevel(logging.Type.BROWSER, logging.Level.FINE) - assert.equal('{"foo":"DEBUG","browser":"FINE"}', JSON.stringify(prefs)) + assert.strictEqual( + '{"foo":"DEBUG","browser":"FINE"}', + JSON.stringify(prefs) + ) }) }) }) diff --git a/javascript/node/selenium-webdriver/test/lib/promise_test.js b/javascript/node/selenium-webdriver/test/lib/promise_test.js index 67333e92b42ac..ac99823948cc2 100644 --- a/javascript/node/selenium-webdriver/test/lib/promise_test.js +++ b/javascript/node/selenium-webdriver/test/lib/promise_test.js @@ -50,7 +50,7 @@ describe('promise', function () { if (promise.USE_PROMISE_MANAGER) { app.reset() promise.setDefaultFlow(new promise.ControlFlow()) - assert.deepEqual( + assert.deepStrictEqual( [], uncaughtExceptions, 'Did not expect any uncaught exceptions' @@ -82,7 +82,7 @@ describe('promise', function () { function runTest(value) { return promise .fullyResolved(value) - .then((resolved) => assert.equal(value, resolved)) + .then((resolved) => assert.strictEqual(value, resolved)) } return runTest(true) .then(() => runTest(function () {})) @@ -96,8 +96,11 @@ describe('promise', function () { var fn = function () {} var array = [true, fn, null, 123, '', undefined, 1] return promise.fullyResolved(array).then(function (resolved) { - assert.equal(array, resolved) - assert.deepEqual([true, fn, null, 123, '', undefined, 1], resolved) + assert.strictEqual(array, resolved) + assert.deepStrictEqual( + [true, fn, null, 123, '', undefined, 1], + resolved + ) }) }) @@ -105,9 +108,9 @@ describe('promise', function () { var fn = function () {} var array = [true, [fn, null, 123], '', undefined] return promise.fullyResolved(array).then(function (resolved) { - assert.equal(array, resolved) - assert.deepEqual([true, [fn, null, 123], '', undefined], resolved) - assert.deepEqual([fn, null, 123], resolved[1]) + assert.strictEqual(array, resolved) + assert.deepStrictEqual([true, [fn, null, 123], '', undefined], resolved) + assert.deepStrictEqual([fn, null, 123], resolved[1]) }) }) @@ -115,14 +118,14 @@ describe('promise', function () { return promise .fullyResolved([Promise.resolve(123)]) .then(function (resolved) { - assert.deepEqual([123], resolved) + assert.deepStrictEqual([123], resolved) }) }) it('promiseResolvesToPrimitive', function () { return promise .fullyResolved(Promise.resolve(123)) - .then((resolved) => assert.equal(123, resolved)) + .then((resolved) => assert.strictEqual(123, resolved)) }) it('promiseResolvesToArray', function () { @@ -132,9 +135,9 @@ describe('promise', function () { var result = promise.fullyResolved(aPromise) return result.then(function (resolved) { - assert.equal(array, resolved) - assert.deepEqual([true, [fn, null, 123], '', undefined], resolved) - assert.deepEqual([fn, null, 123], resolved[1]) + assert.strictEqual(array, resolved) + assert.deepStrictEqual([true, [fn, null, 123], '', undefined], resolved) + assert.deepStrictEqual([fn, null, 123], resolved[1]) }) }) @@ -142,7 +145,7 @@ describe('promise', function () { var nestedPromise = Promise.resolve(123) var aPromise = Promise.resolve([true, nestedPromise]) return promise.fullyResolved(aPromise).then(function (resolved) { - assert.deepEqual([true, 123], resolved) + assert.deepStrictEqual([true, 123], resolved) }) }) @@ -184,7 +187,7 @@ describe('promise', function () { var hash = { a: 123 } return promise.fullyResolved(hash).then(function (resolved) { assert.strictEqual(hash, resolved) - assert.deepEqual(hash, { a: 123 }) + assert.deepStrictEqual(hash, { a: 123 }) }) }) @@ -194,7 +197,7 @@ describe('promise', function () { return promise.fullyResolved(hash).then(function (resolved) { assert.strictEqual(hash, resolved) - assert.deepEqual({ a: 123, b: { foo: 'bar' } }, resolved) + assert.deepStrictEqual({ a: 123, b: { foo: 'bar' } }, resolved) assert.strictEqual(nestedHash, resolved['b']) }) }) @@ -216,7 +219,7 @@ describe('promise', function () { return promise.fullyResolved(aPromise).then(function (resolved) { assert.strictEqual(hash, resolved) assert.strictEqual(nestedHash, resolved['b']) - assert.deepEqual(hash, { a: 123, b: { foo: 'bar' } }) + assert.deepStrictEqual(hash, { a: 123, b: { foo: 'bar' } }) }) }) @@ -226,7 +229,7 @@ describe('promise', function () { }) return promise.fullyResolved(aPromise).then(function (resolved) { - assert.deepEqual({ a: 123 }, resolved) + assert.deepStrictEqual({ a: 123 }, resolved) }) }) @@ -257,21 +260,21 @@ describe('promise', function () { var foo = new Foo() return promise.fullyResolved(foo).then(function (resolvedFoo) { - assert.equal(foo, resolvedFoo) + assert.strictEqual(foo, resolvedFoo) assert.ok(resolvedFoo instanceof Foo) - assert.deepEqual(new Foo(), resolvedFoo) + assert.deepStrictEqual(new Foo(), resolvedFoo) }) }) it('withEmptyArray', function () { return promise.fullyResolved([]).then(function (resolved) { - assert.deepEqual([], resolved) + assert.deepStrictEqual([], resolved) }) }) it('withEmptyHash', function () { return promise.fullyResolved({}).then(function (resolved) { - assert.deepEqual({}, resolved) + assert.deepStrictEqual({}, resolved) }) }) @@ -280,7 +283,7 @@ describe('promise', function () { var array = [Promise.resolve(obj)] return promise.fullyResolved(array).then(function (resolved) { - assert.deepEqual(resolved, [obj]) + assert.deepStrictEqual(resolved, [obj]) }) }) }) @@ -334,7 +337,7 @@ describe('promise', function () { it('returned promise resolves with callback result', async () => { let value = await promise.finally(Promise.resolve(1), () => 2) - assert.equal(value, 2) + assert.strictEqual(value, 2) }) }) @@ -359,7 +362,7 @@ describe('promise', function () { .checkedNodeCall(function (callback) { callback(null, success) }) - .then((value) => assert.equal(success, value)) + .then((value) => assert.strictEqual(success, value)) }) it('functionReturnsAndThrows', function () { @@ -370,7 +373,7 @@ describe('promise', function () { callback(error) throw error2 }) - .then(assert.fail, (e) => assert.equal(error, e)) + .then(assert.fail, (e) => assert.strictEqual(error, e)) }) it('functionThrowsAndReturns', function () { @@ -381,7 +384,7 @@ describe('promise', function () { setTimeout(() => callback(error), 10) throw error2 }) - .then(assert.fail, (e) => assert.equal(error2, e)) + .then(assert.fail, (e) => assert.strictEqual(error2, e)) }) }) @@ -390,12 +393,12 @@ describe('promise', function () { var a = [1, 2, 3] return promise .map(a, function (value, index, a2) { - assert.equal(a, a2) - assert.equal('number', typeof index, 'not a number') + assert.strictEqual(a, a2) + assert.strictEqual('number', typeof index, 'not a number') return value + 1 }) .then(function (value) { - assert.deepEqual([2, 3, 4], value) + assert.deepStrictEqual([2, 3, 4], value) }) }) @@ -417,7 +420,7 @@ describe('promise', function () { return value * value }) .then(function (value) { - assert.deepEqual(expected, value) + assert.deepStrictEqual(expected, value) }) }) @@ -427,7 +430,7 @@ describe('promise', function () { return value + 1 }) .then(function (value) { - assert.deepEqual([], value) + assert.deepStrictEqual([], value) }) }) @@ -438,7 +441,7 @@ describe('promise', function () { }) var pair = callbackPair(function (value) { - assert.deepEqual([2, 3, 4], value) + assert.deepStrictEqual([2, 3, 4], value) }) result = result.then(pair.callback, pair.errback) @@ -458,7 +461,7 @@ describe('promise', function () { }) var pair = callbackPair(function (value) { - assert.deepEqual(['a', 'b'], value) + assert.deepStrictEqual(['a', 'b'], value) }) result = result.then(pair.callback, pair.errback) @@ -500,7 +503,7 @@ describe('promise', function () { }) .then(assert.fail, function (e) { assertIsStubError(e) - assert.equal(3, count) + assert.strictEqual(3, count) }) }) @@ -518,7 +521,7 @@ describe('promise', function () { }) .then(assert.fail, function (e) { assertIsStubError(e) - assert.equal(2, count) + assert.strictEqual(2, count) }) }) @@ -529,7 +532,7 @@ describe('promise', function () { }) var pair = callbackPair(function (value) { - assert.deepEqual([0, 1, 2, 3], value) + assert.deepStrictEqual([0, 1, 2, 3], value) }) result = result.then(pair.callback, pair.errback) @@ -550,12 +553,12 @@ describe('promise', function () { var a = [0, 1, 2, 3] return promise .filter(a, function (val, index, a2) { - assert.equal(a, a2) - assert.equal('number', typeof index, 'not a number') + assert.strictEqual(a, a2) + assert.strictEqual('number', typeof index, 'not a number') return val > 1 }) .then(function (val) { - assert.deepEqual([2, 3], val) + assert.deepStrictEqual([2, 3], val) }) }) @@ -569,7 +572,7 @@ describe('promise', function () { return value > 1 && value < 6 }) .then(function (val) { - assert.deepEqual([2, 5], val) + assert.deepStrictEqual([2, 5], val) }) }) @@ -578,14 +581,14 @@ describe('promise', function () { return promise .filter(a, function (_value, i, a2) { - assert.equal(a, a2) + assert.strictEqual(a, a2) // Even if a function modifies the input array, the original value // should be inserted into the new array. a2[i] = a2[i] - 1 return a2[i] >= 1 }) .then(function (val) { - assert.deepEqual([2, 3], val) + assert.deepStrictEqual([2, 3], val) }) }) @@ -596,7 +599,7 @@ describe('promise', function () { }) var pair = callbackPair(function (value) { - assert.deepEqual([2], value) + assert.deepStrictEqual([2], value) }) result = result.then(pair.callback, pair.errback) return NativePromise.resolve() @@ -616,7 +619,7 @@ describe('promise', function () { }) var pair = callbackPair(function (value) { - assert.deepEqual([2], value) + assert.deepStrictEqual([2], value) }) result = result.then(pair.callback, pair.errback) return NativePromise.resolve() @@ -651,7 +654,7 @@ describe('promise', function () { }) .then(assert.fail, function (e) { assertIsStubError(e) - assert.equal(3, count) + assert.strictEqual(3, count) }) }) @@ -677,7 +680,7 @@ describe('promise', function () { }) var pair = callbackPair(function (value) { - assert.deepEqual([1, 2], value) + assert.deepStrictEqual([1, 2], value) }) result = result.then(pair.callback, pair.errback) diff --git a/javascript/node/selenium-webdriver/test/lib/until_test.js b/javascript/node/selenium-webdriver/test/lib/until_test.js index 96b589cd95ee8..84fa8ef4b82b4 100644 --- a/javascript/node/selenium-webdriver/test/lib/until_test.js +++ b/javascript/node/selenium-webdriver/test/lib/until_test.js @@ -77,10 +77,14 @@ describe('until', function () { if (typeof expectedId === 'string') { expectedId = WebElement.buildId(expectedId) } else { - assert.equal(typeof expectedId, 'number', 'must be string or number') + assert.strictEqual( + typeof expectedId, + 'number', + 'must be string or number' + ) } return (cmd) => { - assert.deepEqual( + assert.deepStrictEqual( cmd.getParameter('id'), expectedId, 'frame ID not specified' @@ -125,7 +129,7 @@ describe('until', function () { return driver .wait(until.ableToSwitchToFrame(By.id('foo')), 2000) - .then(() => assert.deepEqual(foundResponses, [])) + .then(() => assert.deepStrictEqual(foundResponses, [])) }) it('timesOutIfNeverAbletoSwitchFrames', function () { @@ -151,7 +155,7 @@ describe('until', function () { it('failsFastForNonAlertSwitchErrors', function () { return driver.wait(until.alertIsPresent(), 100).then(fail, function (e) { assert.ok(e instanceof error.UnknownCommandError) - assert.equal(e.message, CommandName.GET_ALERT_TEXT) + assert.strictEqual(e.message, CommandName.GET_ALERT_TEXT) }) }) @@ -168,7 +172,7 @@ describe('until', function () { .on(CommandName.DISMISS_ALERT, () => true) return driver.wait(until.alertIsPresent(), 1000).then(function (alert) { - assert.equal(count, 4) + assert.strictEqual(count, 4) return alert.dismiss() }) }) @@ -189,7 +193,7 @@ describe('until', function () { .on(CommandName.DISMISS_ALERT, () => true) return driver.wait(until.alertIsPresent(), 1000).then(function (alert) { - assert.equal(count, 4) + assert.strictEqual(count, 4) return alert.dismiss() }) }) @@ -206,7 +210,7 @@ describe('until', function () { throw new Error('driver did not fail against WebDriverError') }, function (error) { - assert.equal(error, webDriverError) + assert.strictEqual(error, webDriverError) } ) }) @@ -285,7 +289,7 @@ describe('until', function () { assert.ok(element instanceof webdriver.WebElementPromise) return element.getId().then(function (id) { assert.deepStrictEqual(responses, [['end']]) - assert.equal(id, 'abc123') + assert.strictEqual(id, 'abc123') }) }) @@ -302,7 +306,7 @@ describe('until', function () { .then(expectedFailure, function (error) { var expected = 'Waiting for element to be located ' + locatorStr var lines = error.message.split(/\n/, 2) - assert.equal(lines[0], expected) + assert.strictEqual(lines[0], expected) let regex = /^Wait timed out after \d+ms$/ assert.ok( @@ -346,9 +350,9 @@ describe('until', function () { }) .then(function (ids) { assert.deepStrictEqual(responses, [['end']]) - assert.equal(ids.length, 2) - assert.equal(ids[0], 'abc123') - assert.equal(ids[1], 'foo') + assert.strictEqual(ids.length, 2) + assert.strictEqual(ids[0], 'abc123') + assert.strictEqual(ids[1], 'foo') }) }) @@ -366,7 +370,7 @@ describe('until', function () { var expected = 'Waiting for at least one element to be located ' + locatorStr var lines = error.message.split(/\n/, 2) - assert.equal(lines[0], expected) + assert.strictEqual(lines[0], expected) let regex = /^Wait timed out after \d+ms$/ assert.ok( @@ -408,7 +412,7 @@ describe('until', function () { var el = new webdriver.WebElement(driver, { ELEMENT: 'foo' }) return driver .wait(until.stalenessOf(el), 2000) - .then(() => assert.equal(count, 3)) + .then(() => assert.strictEqual(count, 3)) }) describe('element state conditions', function () { @@ -435,7 +439,7 @@ describe('until', function () { return value.getId() }) .then(function (id) { - assert.equal('foo', id) + assert.strictEqual('foo', id) assert.deepStrictEqual(responses, ['end']) }) } @@ -527,7 +531,7 @@ describe('until', function () { () => assert.fail('expected to fail'), function (e) { assert.ok(e instanceof TypeError) - assert.equal( + assert.strictEqual( 'WebElementCondition did not resolve to a WebElement: ' + '[object Number]', e.message diff --git a/javascript/node/selenium-webdriver/test/lib/webdriver_test.js b/javascript/node/selenium-webdriver/test/lib/webdriver_test.js index eba2f26f50340..10e26d1afd690 100644 --- a/javascript/node/selenium-webdriver/test/lib/webdriver_test.js +++ b/javascript/node/selenium-webdriver/test/lib/webdriver_test.js @@ -60,7 +60,7 @@ describe('WebDriver', function () { function expectedError(ctor, message) { return function (e) { assertIsInstance(ctor, e) - assert.equal(message, e.message) + assert.strictEqual(message, e.message) } } @@ -133,7 +133,7 @@ describe('WebDriver', function () { } execute(command) { - assert.deepEqual(command.getParameters(), this.parameters_) + assert.deepStrictEqual(command.getParameters(), this.parameters_) return this.toDo_(command) } } @@ -297,7 +297,7 @@ describe('WebDriver', function () { var driver = executor.createDriver() return driver .getTitle() - .then((title) => assert.equal('Google Search', title)) + .then((title) => assert.strictEqual('Google Search', title)) }) it('testStopsCommandExecutionWhenAnErrorOccurs', function () { @@ -352,7 +352,7 @@ describe('WebDriver', function () { return driver.getCurrentUrl() }) .then(function (value) { - assert.equal('http://www.google.com', value) + assert.strictEqual('http://www.google.com', value) }) }) @@ -375,7 +375,7 @@ describe('WebDriver', function () { assertIsStubError(e) return driver.getCurrentUrl() }) - .then((url) => assert.equal('http://www.google.com', url)) + .then((url) => assert.strictEqual('http://www.google.com', url)) }) }) @@ -402,7 +402,10 @@ describe('WebDriver', function () { el.resolve(new WebElement(driver, { ELEMENT: 'foo' })) return Promise.all(steps).then(function () { - assert.deepEqual(['element resolved', 'wire value resolved'], messages) + assert.deepStrictEqual( + ['element resolved', 'wire value resolved'], + messages + ) }) }) @@ -429,7 +432,7 @@ describe('WebDriver', function () { var driver = executor.createDriver() return driver .executeScript('return document.body;') - .then((result) => assert.equal(null, result)) + .then((result) => assert.strictEqual(null, result)) }) it('primitiveReturnValue', function () { @@ -445,7 +448,7 @@ describe('WebDriver', function () { var driver = executor.createDriver() return driver .executeScript('return document.body;') - .then((result) => assert.equal(123, result)) + .then((result) => assert.strictEqual(123, result)) }) it('webElementReturnValue', function () { @@ -464,7 +467,7 @@ describe('WebDriver', function () { return driver .executeScript('return document.body;') .then((element) => element.getId()) - .then((id) => assert.equal(id, 'foo')) + .then((id) => assert.strictEqual(id, 'foo')) }) it('arrayReturnValue', function () { @@ -483,10 +486,10 @@ describe('WebDriver', function () { return driver .executeScript('return document.body;') .then(function (array) { - assert.equal(1, array.length) + assert.strictEqual(1, array.length) return array[0].getId() }) - .then((id) => assert.equal('foo', id)) + .then((id) => assert.strictEqual('foo', id)) }) it('objectReturnValue', function () { @@ -505,7 +508,7 @@ describe('WebDriver', function () { return driver .executeScript('return document.body;') .then((obj) => obj['foo'].getId()) - .then((id) => assert.equal(id, 'foo')) + .then((id) => assert.strictEqual(id, 'foo')) }) it('scriptAsFunction', function () { @@ -729,7 +732,10 @@ describe('WebDriver', function () { .findElement(By.js('return 123')) .then(assert.fail, function (e) { assertIsInstance(TypeError, e) - assert.equal('Custom locator did not return a WebElement', e.message) + assert.strictEqual( + 'Custom locator did not return a WebElement', + e.message + ) }) }) @@ -759,7 +765,7 @@ describe('WebDriver', function () { var driver = executor.createDriver() var element = driver.findElement(function (d) { - assert.equal(driver, d) + assert.strictEqual(driver, d) return d.findElements(By.tagName('a')) }) return element.click() @@ -771,7 +777,10 @@ describe('WebDriver', function () { .findElement((_) => 1) .then(assert.fail, function (e) { assertIsInstance(TypeError, e) - assert.equal('Custom locator did not return a WebElement', e.message) + assert.strictEqual( + 'Custom locator did not return a WebElement', + e.message + ) }) }) }) @@ -795,7 +804,7 @@ describe('WebDriver', function () { }) ) }) - .then((actual) => assert.deepEqual(ids, actual)) + .then((actual) => assert.deepStrictEqual(ids, actual)) }) it('byJs', function () { @@ -820,7 +829,7 @@ describe('WebDriver', function () { }) ) }) - .then((actual) => assert.deepEqual(ids, actual)) + .then((actual) => assert.deepStrictEqual(ids, actual)) }) it('byJs_filtersOutNonWebElementResponses', function () { @@ -853,7 +862,7 @@ describe('WebDriver', function () { }) ) }) - .then((actual) => assert.deepEqual(ids, actual)) + .then((actual) => assert.deepStrictEqual(ids, actual)) }) it('byJs_convertsSingleWebElementResponseToArray', function () { @@ -876,7 +885,7 @@ describe('WebDriver', function () { }) ) }) - .then((actual) => assert.deepEqual(['foo'], actual)) + .then((actual) => assert.deepStrictEqual(['foo'], actual)) }) it('byJs_canPassScriptArguments', function () { @@ -903,7 +912,7 @@ describe('WebDriver', function () { }) ) }) - .then((actual) => assert.deepEqual(['one', 'two'], actual)) + .then((actual) => assert.deepStrictEqual(['one', 'two'], actual)) }) }) @@ -965,7 +974,7 @@ describe('WebDriver', function () { let driver = executor.createDriver() let handleFile = function (d, path) { assert.strictEqual(driver, d) - assert.equal(path, 'original/path') + assert.strictEqual(path, 'original/path') return Promise.resolve('modified/path') } driver.setFileDetector({ handleFile }) @@ -1035,7 +1044,7 @@ describe('WebDriver', function () { count++ return true } - return driver.wait(condition, 1).then(() => assert.equal(1, count)) + return driver.wait(condition, 1).then(() => assert.strictEqual(1, count)) }) it('on a simple counting condition', function () { @@ -1045,7 +1054,9 @@ describe('WebDriver', function () { function condition() { return ++count === 3 } - return driver.wait(condition, 250).then(() => assert.equal(3, count)) + return driver + .wait(condition, 250) + .then(() => assert.strictEqual(3, count)) }) it('on a condition that returns a promise that resolves to true after a short timeout', function () { @@ -1060,7 +1071,7 @@ describe('WebDriver', function () { }) } - return driver.wait(condition, 75).then(() => assert.equal(1, count)) + return driver.wait(condition, 75).then(() => assert.strictEqual(1, count)) }) it('on a condition that returns a promise', function () { @@ -1077,7 +1088,7 @@ describe('WebDriver', function () { return driver .wait(condition, 100, null, 25) - .then(() => assert.equal(3, count)) + .then(() => assert.strictEqual(3, count)) }) it('fails if condition throws', function () { @@ -1215,7 +1226,7 @@ describe('WebDriver', function () { ) return wait.then(fail, function (e) { - assert.equal(2, count) + assert.strictEqual(2, count) assert.ok(e instanceof error.TimeoutError, 'Unexpected error: ' + e) assert.ok(/^counting to 3\nWait timed out after \d+ms$/.test(e.message)) }) @@ -1251,19 +1262,19 @@ describe('WebDriver', function () { let driver = executor.createDriver() let waitResult = driver.wait(d.promise).then(function (value) { messages.push('b') - assert.equal(1234, value) + assert.strictEqual(1234, value) }) setTimeout(() => messages.push('a'), 5) return driver .sleep(10) .then(function () { - assert.deepEqual(['a'], messages) + assert.deepStrictEqual(['a'], messages) d.resolve(1234) return waitResult }) .then(function () { - assert.deepEqual(['a', 'b'], messages) + assert.deepStrictEqual(['a', 'b'], messages) }) }) @@ -1314,7 +1325,7 @@ describe('WebDriver', function () { .then((els) => els.length > 0) }, 25) .then(fail, function (e) { - assert.equal( + assert.strictEqual( 'Wait timed out after ', e.message.substring(0, 'Wait timed out after '.length) ) @@ -1366,7 +1377,7 @@ describe('WebDriver', function () { }) let driver = new FakeExecutor().createDriver() - return driver.wait(promise, 200).then((v) => assert.equal(v, 1)) + return driver.wait(promise, 200).then((v) => assert.strictEqual(v, 1)) }) it('wait times out', function () { @@ -1403,7 +1414,7 @@ describe('WebDriver', function () { let alert = new AlertPromise(driver, deferredText.promise) deferredText.resolve(new Alert(driver, 'foo')) - return alert.getText().then((text) => assert.equal(text, 'foo')) + return alert.getText().then((text) => assert.strictEqual(text, 'foo')) }) it('cannotSwitchToAlertThatIsNotPresent', function () { @@ -1459,17 +1470,17 @@ describe('WebDriver', function () { .logs() .get('browser') .then(function (entries) { - assert.equal(2, entries.length) + assert.strictEqual(2, entries.length) assert.ok(entries[0] instanceof logging.Entry) - assert.equal(logging.Level.INFO.value, entries[0].level.value) - assert.equal('hello', entries[0].message) - assert.equal(1234, entries[0].timestamp) + assert.strictEqual(logging.Level.INFO.value, entries[0].level.value) + assert.strictEqual('hello', entries[0].message) + assert.strictEqual(1234, entries[0].timestamp) assert.ok(entries[1] instanceof logging.Entry) - assert.equal(logging.Level.DEBUG.value, entries[1].level.value) - assert.equal('abc123', entries[1].message) - assert.equal(5678, entries[1].timestamp) + assert.strictEqual(logging.Level.DEBUG.value, entries[1].level.value) + assert.strictEqual('abc123', entries[1].message) + assert.strictEqual(5678, entries[1].timestamp) }) }) @@ -1861,7 +1872,7 @@ describe('WebDriver', function () { .end() let driver = executor.createDriver() return driver.getCurrentUrl().then(function (got) { - assert.deepEqual(got, want) + assert.deepStrictEqual(got, want) }) } @@ -1870,7 +1881,7 @@ describe('WebDriver', function () { runDeserializeTest(1, 1), runDeserializeTest('', ''), runDeserializeTest(true, true), - runDeserializeTest(undefined, undefined), + runDeserializeTest(undefined, null), runDeserializeTest(null, null), ]) }) diff --git a/javascript/node/selenium-webdriver/test/logging_test.js b/javascript/node/selenium-webdriver/test/logging_test.js index 1936e4bc8faec..96d24856d69b6 100644 --- a/javascript/node/selenium-webdriver/test/logging_test.js +++ b/javascript/node/selenium-webdriver/test/logging_test.js @@ -59,7 +59,7 @@ test.suite(function (env) { .manage() .logs() .get(logging.Type.BROWSER) - .then((entries) => assert.equal(entries.length, 0)) + .then((entries) => assert.strictEqual(entries.length, 0)) }) // Firefox does not capture JS error console log messages. @@ -85,8 +85,8 @@ test.suite(function (env) { .logs() .get(logging.Type.BROWSER) .then(function (entries) { - assert.equal(entries.length, 1) - assert.equal(entries[0].level.name, 'SEVERE') + assert.strictEqual(entries.length, 1) + assert.strictEqual(entries[0].level.name, 'SEVERE') // eslint-disable-next-line no-useless-escape assert.ok(/.*\"?and this is an error\"?/.test(entries[0].message)) }) @@ -115,16 +115,16 @@ test.suite(function (env) { .logs() .get(logging.Type.BROWSER) .then(function (entries) { - assert.equal(entries.length, 3) - assert.equal(entries[0].level.name, 'DEBUG') + assert.strictEqual(entries.length, 3) + assert.strictEqual(entries[0].level.name, 'DEBUG') // eslint-disable-next-line no-useless-escape assert.ok(/.*\"?hello\"?/.test(entries[0].message)) - assert.equal(entries[1].level.name, 'WARNING') + assert.strictEqual(entries[1].level.name, 'WARNING') // eslint-disable-next-line no-useless-escape assert.ok(/.*\"?this is a warning\"?/.test(entries[1].message)) - assert.equal(entries[2].level.name, 'SEVERE') + assert.strictEqual(entries[2].level.name, 'SEVERE') // eslint-disable-next-line no-useless-escape assert.ok(/.*\"?and this is an error\"?/.test(entries[2].message)) }) @@ -152,12 +152,12 @@ test.suite(function (env) { .manage() .logs() .get(logging.Type.BROWSER) - .then((entries) => assert.equal(entries.length, 3)) + .then((entries) => assert.strictEqual(entries.length, 3)) return driver .manage() .logs() .get(logging.Type.BROWSER) - .then((entries) => assert.equal(entries.length, 0)) + .then((entries) => assert.strictEqual(entries.length, 0)) }) it('does not mix log types', async function () { @@ -180,7 +180,7 @@ test.suite(function (env) { .manage() .logs() .get(logging.Type.DRIVER) - .then((entries) => assert.equal(entries.length, 0)) + .then((entries) => assert.strictEqual(entries.length, 0)) }) }) diff --git a/javascript/node/selenium-webdriver/test/net/index_test.js b/javascript/node/selenium-webdriver/test/net/index_test.js index ca9db2c097f25..c0c2037777ba9 100644 --- a/javascript/node/selenium-webdriver/test/net/index_test.js +++ b/javascript/node/selenium-webdriver/test/net/index_test.js @@ -22,42 +22,45 @@ var net = require('../../net') describe('net.splitHostAndPort', function () { it('hostname with no port', function () { - assert.deepEqual(net.splitHostAndPort('www.example.com'), { + assert.deepStrictEqual(net.splitHostAndPort('www.example.com'), { host: 'www.example.com', port: null, }) }) it('hostname with port', function () { - assert.deepEqual(net.splitHostAndPort('www.example.com:80'), { + assert.deepStrictEqual(net.splitHostAndPort('www.example.com:80'), { host: 'www.example.com', port: 80, }) }) it('IPv4 with no port', function () { - assert.deepEqual(net.splitHostAndPort('127.0.0.1'), { + assert.deepStrictEqual(net.splitHostAndPort('127.0.0.1'), { host: '127.0.0.1', port: null, }) }) it('IPv4 with port', function () { - assert.deepEqual(net.splitHostAndPort('127.0.0.1:1234'), { + assert.deepStrictEqual(net.splitHostAndPort('127.0.0.1:1234'), { host: '127.0.0.1', port: 1234, }) }) it('IPv6 with no port', function () { - assert.deepEqual(net.splitHostAndPort('1234:0:1000:5768:1234:5678:90'), { - host: '1234:0:1000:5768:1234:5678:90', - port: null, - }) + assert.deepStrictEqual( + net.splitHostAndPort('1234:0:1000:5768:1234:5678:90'), + { + host: '1234:0:1000:5768:1234:5678:90', + port: null, + } + ) }) it('IPv6 with port', function () { - assert.deepEqual( + assert.deepStrictEqual( net.splitHostAndPort('[1234:0:1000:5768:1234:5678:90]:1234'), { host: '1234:0:1000:5768:1234:5678:90', port: 1234 } ) diff --git a/javascript/node/selenium-webdriver/test/page_loading_test.js b/javascript/node/selenium-webdriver/test/page_loading_test.js index 7b80cbbb5363f..d8c1b3bed1cbf 100644 --- a/javascript/node/selenium-webdriver/test/page_loading_test.js +++ b/javascript/node/selenium-webdriver/test/page_loading_test.js @@ -43,12 +43,12 @@ test.suite(function (env) { it('should wait for document to be loaded', async function () { await driver.get(Pages.simpleTestPage) - assert.equal(await driver.getTitle(), 'Hello WebDriver') + assert.strictEqual(await driver.getTitle(), 'Hello WebDriver') }) it('should follow redirects sent in the http response headers', async function () { await driver.get(Pages.redirectPage) - assert.equal(await driver.getTitle(), 'We Arrive Here') + assert.strictEqual(await driver.getTitle(), 'We Arrive Here') }) it('should be able to get a fragment on the current page', async function () { @@ -62,13 +62,13 @@ test.suite(function (env) { await driver.switchTo().frame(0) let txt = await driver.findElement(By.css('span#pageNumber')).getText() - assert.equal(txt.trim(), '1') + assert.strictEqual(txt.trim(), '1') await driver.switchTo().defaultContent() await driver.switchTo().frame(1) txt = await driver.findElement(By.css('span#pageNumber')).getText() - assert.equal(txt.trim(), '2') + assert.strictEqual(txt.trim(), '2') // For safari, need to make sure browser is focused on the main frame or // subsequent tests will fail. @@ -115,15 +115,15 @@ test.suite(function (env) { await driver.navigate().refresh() - assert.equal(await driver.getTitle(), 'XHTML Test Page') + assert.strictEqual(await driver.getTitle(), 'XHTML Test Page') }) it('should return title of page if set', async function () { await driver.get(Pages.xhtmlTestPage) - assert.equal(await driver.getTitle(), 'XHTML Test Page') + assert.strictEqual(await driver.getTitle(), 'XHTML Test Page') await driver.get(Pages.simpleTestPage) - assert.equal(await driver.getTitle(), 'Hello WebDriver') + assert.strictEqual(await driver.getTitle(), 'Hello WebDriver') }) describe('timeouts', function () { diff --git a/javascript/node/selenium-webdriver/test/print_pdf_test.js b/javascript/node/selenium-webdriver/test/print_pdf_test.js index 2a9018ad67816..46197332704a5 100644 --- a/javascript/node/selenium-webdriver/test/print_pdf_test.js +++ b/javascript/node/selenium-webdriver/test/print_pdf_test.js @@ -41,7 +41,7 @@ test.suite( await driver.get(Pages.printPage) base64Code = await driver.printPage({ pageRanges: ['1-2'] }) base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) it('Should Print pdf with total pages', async function () { @@ -49,7 +49,7 @@ test.suite( await driver.get(Pages.printPage) base64Code = await driver.printPage() base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) it('Check with all valid params', async function () { @@ -69,7 +69,7 @@ test.suite( pageRanges: ['1-2'], }) base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) it('Check with page params', async function () { @@ -77,7 +77,7 @@ test.suite( await driver.get(Pages.printPage) base64Code = await driver.printPage({ width: 30, height: 30 }) base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) it('Check with margin params', async function () { @@ -90,7 +90,7 @@ test.suite( right: 1, }) base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) }, { browsers: [Browser.FIREFOX] } @@ -114,7 +114,7 @@ test.suite( await driver.get(Pages.printPage) base64Code = await driver.printPage({ pageRanges: ['1-2'] }) base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) it('Should Print pdf with total pages', async function () { @@ -122,7 +122,7 @@ test.suite( await driver.get(Pages.printPage) base64Code = await driver.printPage() base64Code = base64Code.slice(startIndex, endIndex) - assert.equal(base64Code, pdfMagicNumber) + assert.strictEqual(base64Code, pdfMagicNumber) }) }, { browsers: [Browser.CHROME] } diff --git a/javascript/node/selenium-webdriver/test/proxy_test.js b/javascript/node/selenium-webdriver/test/proxy_test.js index a1686d6edc6d8..084919d79f61a 100644 --- a/javascript/node/selenium-webdriver/test/proxy_test.js +++ b/javascript/node/selenium-webdriver/test/proxy_test.js @@ -136,8 +136,8 @@ test.suite(function (env) { ) await driver.get(helloServer.url()) - assert.equal(await driver.getTitle(), 'Proxy page') - assert.equal( + assert.strictEqual(await driver.getTitle(), 'Proxy page') + assert.strictEqual( await driver.findElement({ tagName: 'h3' }).getText(), 'This is the proxy landing page' ) @@ -152,8 +152,8 @@ test.suite(function (env) { ) await driver.get(helloServer.url()) - assert.equal(await driver.getTitle(), 'Hello') - assert.equal( + assert.strictEqual(await driver.getTitle(), 'Hello') + assert.strictEqual( await driver.findElement({ tagName: 'h3' }).getText(), 'Hello, world!' ) @@ -161,8 +161,8 @@ test.suite(function (env) { // For firefox the no proxy settings appear to match on hostname only. let url = goodbyeServer.url().replace(/127\.0\.0\.1/, 'localhost') await driver.get(url) - assert.equal(await driver.getTitle(), 'Proxy page') - assert.equal( + assert.strictEqual(await driver.getTitle(), 'Proxy page') + assert.strictEqual( await driver.findElement({ tagName: 'h3' }).getText(), 'This is the proxy landing page' ) @@ -182,15 +182,15 @@ test.suite(function (env) { await createDriver(proxy.pac(proxyServer.url('/proxy.pac'))) await driver.get(helloServer.url()) - assert.equal(await driver.getTitle(), 'Proxy page') - assert.equal( + assert.strictEqual(await driver.getTitle(), 'Proxy page') + assert.strictEqual( await driver.findElement({ tagName: 'h3' }).getText(), 'This is the proxy landing page' ) await driver.get(goodbyeServer.url()) - assert.equal(await driver.getTitle(), 'Goodbye') - assert.equal( + assert.strictEqual(await driver.getTitle(), 'Goodbye') + assert.strictEqual( await driver.findElement({ tagName: 'h3' }).getText(), 'Goodbye, world!' ) diff --git a/javascript/node/selenium-webdriver/test/rect_test.js b/javascript/node/selenium-webdriver/test/rect_test.js index 7be764d0a535f..2030020e7b6b4 100644 --- a/javascript/node/selenium-webdriver/test/rect_test.js +++ b/javascript/node/selenium-webdriver/test/rect_test.js @@ -46,7 +46,7 @@ test.suite(function (env) { ) const el = await driver.findElement(By.css('div')) const rect = await el.getRect() - assert.deepEqual(rect, { width: 35, height: 25, x: 40, y: 50 }) + assert.deepStrictEqual(rect, { width: 35, height: 25, x: 40, y: 50 }) }) }) }) diff --git a/javascript/node/selenium-webdriver/test/remote_test.js b/javascript/node/selenium-webdriver/test/remote_test.js index 86a50ba10c7ff..0cb6fab0096a7 100644 --- a/javascript/node/selenium-webdriver/test/remote_test.js +++ b/javascript/node/selenium-webdriver/test/remote_test.js @@ -45,7 +45,7 @@ describe('DriverService', function () { function verifyFailure(e) { assert.ok(!(e instanceof CancellationError)) - assert.equal('Server terminated early with status 1', e.message) + assert.strictEqual('Server terminated early with status 1', e.message) } function expectFailure() { @@ -66,7 +66,7 @@ describe('FileDetector', function () { let theFile = path.join(dir, 'not-there') return new remote.FileDetector() .handleFile(new ExplodingDriver(), theFile) - .then((f) => assert.equal(f, theFile)) + .then((f) => assert.strictEqual(f, theFile)) }) }) @@ -74,7 +74,7 @@ describe('FileDetector', function () { return io.tmpDir().then((dir) => { return new remote.FileDetector() .handleFile(new ExplodingDriver(), dir) - .then((f) => assert.equal(f, dir)) + .then((f) => assert.strictEqual(f, dir)) }) }) @@ -84,14 +84,17 @@ describe('FileDetector', function () { .handleFile( new (class FakeDriver { execute(command) { - assert.equal(command.getName(), cmd.Name.UPLOAD_FILE) - assert.equal(typeof command.getParameters()['file'], 'string') + assert.strictEqual(command.getName(), cmd.Name.UPLOAD_FILE) + assert.strictEqual( + typeof command.getParameters()['file'], + 'string' + ) return Promise.resolve('success!') } })(), theFile ) - .then((f) => assert.equal(f, 'success!')) + .then((f) => assert.strictEqual(f, 'success!')) }) }) }) diff --git a/javascript/node/selenium-webdriver/test/stale_element_test.js b/javascript/node/selenium-webdriver/test/stale_element_test.js index 5115db6261c32..5670f91aba8e9 100644 --- a/javascript/node/selenium-webdriver/test/stale_element_test.js +++ b/javascript/node/selenium-webdriver/test/stale_element_test.js @@ -41,7 +41,7 @@ test.suite(function (env) { await driver.get(Pages.javascriptPage) var toBeDeleted = await driver.findElement(By.id('deleted')) - assert.equal(await toBeDeleted.getTagName(), 'p') + assert.strictEqual(await toBeDeleted.getTagName(), 'p') await driver.findElement(By.id('delete')).click() await driver.wait(until.stalenessOf(toBeDeleted), 5000) diff --git a/javascript/node/selenium-webdriver/test/upload_test.js b/javascript/node/selenium-webdriver/test/upload_test.js index 5326098d23e00..f2c4749af9fd8 100644 --- a/javascript/node/selenium-webdriver/test/upload_test.js +++ b/javascript/node/selenium-webdriver/test/upload_test.js @@ -74,7 +74,7 @@ test.suite(function (env) { var frame = await driver.findElement(By.id('upload_target')) await driver.switchTo().frame(frame) - assert.equal( + assert.strictEqual( await driver.findElement(By.css('body')).getText(), LOREM_IPSUM_TEXT ) diff --git a/javascript/node/selenium-webdriver/test/window_test.js b/javascript/node/selenium-webdriver/test/window_test.js index b61780f0665d3..e434d9132cb85 100644 --- a/javascript/node/selenium-webdriver/test/window_test.js +++ b/javascript/node/selenium-webdriver/test/window_test.js @@ -65,12 +65,12 @@ test.suite(function (env) { await driver.findElement(By.linkText('Open new window')).click() await driver.wait(forNewWindowToBeOpened(originalHandles), 2000) - assert.equal(await driver.getTitle(), 'XHTML Test Page') + assert.strictEqual(await driver.getTitle(), 'XHTML Test Page') let newHandle = await getNewWindowHandle(originalHandles) await driver.switchTo().window(newHandle) - assert.equal(await driver.getTitle(), 'We Arrive Here') + assert.strictEqual(await driver.getTitle(), 'We Arrive Here') }) it('can set the window position of the current window', async function () { @@ -120,7 +120,7 @@ test.suite(function (env) { } } - assert.equal( + assert.strictEqual( (await driver.getAllWindowHandles()).length, originalHandles.length + 1 )