From 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 24 May 2017 15:10:37 +0200 Subject: fix build issues and add typedoc --- node_modules/selenium-webdriver/CHANGES.md | 25 ++++ node_modules/selenium-webdriver/README.md | 2 +- node_modules/selenium-webdriver/chrome.js | 49 +++++++- .../example/google_search_test.js | 2 +- node_modules/selenium-webdriver/lib/by.js | 8 ++ node_modules/selenium-webdriver/lib/command.js | 2 + .../selenium-webdriver/lib/firefox/webdriver.xpi | Bin 703396 -> 712979 bytes node_modules/selenium-webdriver/lib/http.js | 93 ++++++++------- .../test/data/click_tests/disabled_element.html | 12 ++ .../lib/test/data/nestedElements.html | 11 +- node_modules/selenium-webdriver/lib/test/index.js | 3 +- node_modules/selenium-webdriver/lib/webdriver.js | 127 +++++++++++++++++++-- node_modules/selenium-webdriver/net/portprober.js | 2 +- node_modules/selenium-webdriver/package.json | 2 +- .../selenium-webdriver/test/lib/by_test.js | 21 ++++ .../selenium-webdriver/test/lib/http_test.js | 14 ++- .../selenium-webdriver/test/lib/webdriver_test.js | 102 +++++++++++++++++ 17 files changed, 412 insertions(+), 63 deletions(-) create mode 100644 node_modules/selenium-webdriver/lib/test/data/click_tests/disabled_element.html (limited to 'node_modules/selenium-webdriver') diff --git a/node_modules/selenium-webdriver/CHANGES.md b/node_modules/selenium-webdriver/CHANGES.md index 1cdc96814..0260b0604 100644 --- a/node_modules/selenium-webdriver/CHANGES.md +++ b/node_modules/selenium-webdriver/CHANGES.md @@ -1,3 +1,28 @@ +## v3.4.0 + +### Notice + +This release requires [geckodriver 0.15.0](https://github.com/mozilla/geckodriver/releases/tag/v0.15.0) or newer. + +### API Changes + +* Added `Options#getTimeouts()` for retrieving the currently configured session + timeouts (i.e. implicit wait). This method will only work with W3C compatible + WebDriver implementations. +* Deprecated the `Timeouts` class in favor of `Options#setTimeouts()`, which + supports setting multiple timeouts at once. +* Added support for emulating different network conditions (e.g., offline, 2G, WiFi) on Chrome. + +### Changes for W3C WebDriver Spec Compliance + +* Fixed W3C response parsing, which expects response data to always be a JSON + object with a `value` key. +* Added W3C endpoints for interacting with various types of + [user prompts](https://w3c.github.io/webdriver/webdriver-spec.html#user-prompts). +* Added W3C endpoints for remotely executing scripts. +* Added W3C endpoints to get current window handle and all windows handles. + + ## v3.3.0 * Added warning log messages when the user creates new managed promises, or diff --git a/node_modules/selenium-webdriver/README.md b/node_modules/selenium-webdriver/README.md index 31708b186..2cf9ac924 100644 --- a/node_modules/selenium-webdriver/README.md +++ b/node_modules/selenium-webdriver/README.md @@ -193,7 +193,7 @@ the issue tracker - __Do not__ post empty "I see this too" or "Any updates?" comments. These provide no additional information and clutter the log. - __Do not__ report regressions on closed bugs as they are not actively - monitored for upates (especially bugs that are >6 months old). Please open a + monitored for updates (especially bugs that are >6 months old). Please open a new issue and reference the original bug in your report. ## License diff --git a/node_modules/selenium-webdriver/chrome.js b/node_modules/selenium-webdriver/chrome.js index 2dbc93351..b1e8a29e4 100644 --- a/node_modules/selenium-webdriver/chrome.js +++ b/node_modules/selenium-webdriver/chrome.js @@ -143,7 +143,9 @@ const CHROMEDRIVER_EXE = * @enum {string} */ const Command = { - LAUNCH_APP: 'launchApp' + LAUNCH_APP: 'launchApp', + GET_NETWORK_CONDITIONS: 'getNetworkConditions', + SET_NETWORK_CONDITIONS: 'setNetworkConditions' }; @@ -169,6 +171,14 @@ function configureExecutor(executor) { Command.LAUNCH_APP, 'POST', '/session/:sessionId/chromium/launch_app'); + executor.defineCommand( + Command.GET_NETWORK_CONDITIONS, + 'GET', + '/session/:sessionId/chromium/network_conditions'); + executor.defineCommand( + Command.SET_NETWORK_CONDITIONS, + 'POST', + '/session/:sessionId/chromium/network_conditions'); } @@ -727,6 +737,43 @@ class Driver extends webdriver.WebDriver { new command.Command(Command.LAUNCH_APP).setParameter('id', id), 'Driver.launchApp()'); } + + /** + * Schedules a command to get Chrome network emulation settings. + * @return {!promise.Thenable} A promise that will be resolved + * when network emulation settings are retrievied. + */ + getNetworkConditions() { + return this.schedule( + new command.Command(Command.GET_NETWORK_CONDITIONS), + 'Driver.getNetworkConditions()'); + } + + /** + * Schedules a command to set Chrome network emulation settings. + * + * __Sample Usage:__ + * + * driver.setNetworkConditions({ + * offline: false, + * latency: 5, // Additional latency (ms). + * download_throughput: 500 * 1024, // Maximal aggregated download throughput. + * upload_throughput: 500 * 1024 // Maximal aggregated upload throughput. + * }); + * + * @param {Object} spec Defines the network conditions to set + * @return {!promise.Thenable} A promise that will be resolved + * when network emulation settings are set. + */ + setNetworkConditions(spec) { + if (!spec || typeof spec !== 'object') { + throw TypeError('setNetworkConditions called with non-network-conditions parameter'); + } + + return this.schedule( + new command.Command(Command.SET_NETWORK_CONDITIONS).setParameter('network_conditions', spec), + 'Driver.setNetworkConditions(' + JSON.stringify(spec) + ')'); + } } diff --git a/node_modules/selenium-webdriver/example/google_search_test.js b/node_modules/selenium-webdriver/example/google_search_test.js index a29278258..0ca2f4370 100644 --- a/node_modules/selenium-webdriver/example/google_search_test.js +++ b/node_modules/selenium-webdriver/example/google_search_test.js @@ -41,7 +41,7 @@ test.describe('Google Search', function() { // You can write tests either using traditional promises. it('works with promises', function() { - return driver.get('http://www.google.com') + return driver.get('http://www.google.com/ncr') .then(_ => driver.findElement(By.name('q')).sendKeys('webdriver')) .then(_ => driver.findElement(By.name('btnG')).click()) .then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000)); diff --git a/node_modules/selenium-webdriver/lib/by.js b/node_modules/selenium-webdriver/lib/by.js index 8c718be64..fc74b2056 100644 --- a/node_modules/selenium-webdriver/lib/by.js +++ b/node_modules/selenium-webdriver/lib/by.js @@ -259,6 +259,14 @@ function check(locator) { if (locator instanceof By || typeof locator === 'function') { return locator; } + + if (locator + && typeof locator === 'object' + && typeof locator.using === 'string' + && typeof locator.value === 'string') { + return new By(locator.using, locator.value); + } + for (let key in locator) { if (locator.hasOwnProperty(key) && By.hasOwnProperty(key)) { return By[key](locator[key]); diff --git a/node_modules/selenium-webdriver/lib/command.js b/node_modules/selenium-webdriver/lib/command.js index c9a366e4e..39db8c451 100644 --- a/node_modules/selenium-webdriver/lib/command.js +++ b/node_modules/selenium-webdriver/lib/command.js @@ -150,6 +150,8 @@ const Name = { TAKE_ELEMENT_SCREENSHOT: 'takeElementScreenshot', IMPLICITLY_WAIT: 'implicitlyWait', SET_SCRIPT_TIMEOUT: 'setScriptTimeout', + + GET_TIMEOUT: 'getTimeout', SET_TIMEOUT: 'setTimeout', ACCEPT_ALERT: 'acceptAlert', diff --git a/node_modules/selenium-webdriver/lib/firefox/webdriver.xpi b/node_modules/selenium-webdriver/lib/firefox/webdriver.xpi index a7b0fa3a7..6c69f1d32 100644 Binary files a/node_modules/selenium-webdriver/lib/firefox/webdriver.xpi and b/node_modules/selenium-webdriver/lib/firefox/webdriver.xpi differ diff --git a/node_modules/selenium-webdriver/lib/http.js b/node_modules/selenium-webdriver/lib/http.js index 136a48e63..e141bf190 100644 --- a/node_modules/selenium-webdriver/lib/http.js +++ b/node_modules/selenium-webdriver/lib/http.js @@ -225,6 +225,7 @@ const COMMAND_MAP = new Map([ [cmd.Name.EXECUTE_SCRIPT, post('/session/:sessionId/execute')], [cmd.Name.EXECUTE_ASYNC_SCRIPT, post('/session/:sessionId/execute_async')], [cmd.Name.SCREENSHOT, get('/session/:sessionId/screenshot')], + [cmd.Name.GET_TIMEOUT, get('/session/:sessionId/timeouts')], [cmd.Name.SET_TIMEOUT, post('/session/:sessionId/timeouts')], [cmd.Name.MOVE_TO, post('/session/:sessionId/moveto')], [cmd.Name.CLICK, post('/session/:sessionId/click')], @@ -256,6 +257,10 @@ const COMMAND_MAP = new Map([ /** @const {!Map} */ const W3C_COMMAND_MAP = new Map([ [cmd.Name.GET_ACTIVE_ELEMENT, get('/session/:sessionId/element/active')], + [cmd.Name.GET_ALERT_TEXT, get('/session/:sessionId/alert/text')], + [cmd.Name.SET_ALERT_TEXT, post('/session/:sessionId/alert/text')], + [cmd.Name.ACCEPT_ALERT, post('/session/:sessionId/alert/accept')], + [cmd.Name.DISMISS_ALERT, post('/session/:sessionId/alert/dismiss')], [cmd.Name.GET_ELEMENT_ATTRIBUTE, (cmd) => { return toExecuteAtomCommand(cmd, Atom.GET_ATTRIBUTE, 'id', 'name'); }], @@ -264,11 +269,15 @@ const W3C_COMMAND_MAP = new Map([ [cmd.Name.IS_ELEMENT_DISPLAYED, (cmd) => { return toExecuteAtomCommand(cmd, Atom.IS_DISPLAYED, 'id'); }], + [cmd.Name.EXECUTE_SCRIPT, post('/session/:sessionId/execute/sync')], + [cmd.Name.EXECUTE_ASYNC_SCRIPT, post('/session/:sessionId/execute/async')], [cmd.Name.MAXIMIZE_WINDOW, post('/session/:sessionId/window/maximize')], [cmd.Name.GET_WINDOW_POSITION, get('/session/:sessionId/window/position')], [cmd.Name.SET_WINDOW_POSITION, post('/session/:sessionId/window/position')], [cmd.Name.GET_WINDOW_SIZE, get('/session/:sessionId/window/size')], [cmd.Name.SET_WINDOW_SIZE, post('/session/:sessionId/window/size')], + [cmd.Name.GET_CURRENT_WINDOW_HANDLE, get('/session/:sessionId/window')], + [cmd.Name.GET_WINDOW_HANDLES, get('/session/:sessionId/window/handles')], ]); @@ -428,34 +437,29 @@ class Executor { return doSend(this, request).then(response => { this.log_.finer(() => `>>>\n${request}\n<<<\n${response}`); - let parsed = - parseHttpResponse( - command, /** @type {!Response} */ (response), this.w3c); + let httpResponse = /** @type {!Response} */(response); + let {isW3C, value} = parseHttpResponse(command, httpResponse); if (command.getName() === cmd.Name.NEW_SESSION || command.getName() === cmd.Name.DESCRIBE_SESSION) { - if (!parsed || !parsed['sessionId']) { + if (!value || !value.sessionId) { throw new error.WebDriverError( - 'Unable to parse new session response: ' + response.body); + `Unable to parse new session response: ${response.body}`); } // The remote end is a W3C compliant server if there is no `status` // field in the response. This is not applicable for the DESCRIBE_SESSION // command, which is not defined in the W3C spec. if (command.getName() === cmd.Name.NEW_SESSION) { - this.w3c = this.w3c || !('status' in parsed); + this.w3c = this.w3c || isW3C; } - return new Session(parsed['sessionId'], parsed['value']); + // No implementations use the `capabilities` key yet... + let capabilities = value.capabilities || value.value; + return new Session(value.sessionId, capabilities); } - if (parsed - && typeof parsed === 'object' - && 'value' in parsed) { - let value = parsed['value']; - return typeof value === 'undefined' ? null : value; - } - return parsed; + return typeof value === 'undefined' ? null : value; }); }); } @@ -481,40 +485,45 @@ function tryParse(str) { * * @param {!cmd.Command} command The command the response is for. * @param {!Response} httpResponse The HTTP response to parse. - * @param {boolean} w3c Whether the response should be processed using the - * W3C wire protocol. - * @return {?} The parsed response. + * @return {{isW3C: boolean, value: ?}} An object describing the parsed + * response. This object will have two fields: `isW3C` indicates whether + * the response looks like it came from a remote end that conforms with the + * W3C WebDriver spec, and `value`, the actual response value. * @throws {WebDriverError} If the HTTP response is an error. */ -function parseHttpResponse(command, httpResponse, w3c) { - let parsed = tryParse(httpResponse.body); - if (parsed !== undefined) { - if (httpResponse.status < 200) { - // This should never happen, but throw the raw response so - // users report it. - throw new error.WebDriverError( - `Unexpected HTTP response:\n${httpResponse}`); - } +function parseHttpResponse(command, httpResponse) { + if (httpResponse.status < 200) { + // This should never happen, but throw the raw response so users report it. + throw new error.WebDriverError( + `Unexpected HTTP response:\n${httpResponse}`); + } - if (w3c) { - if (httpResponse.status > 399) { - error.throwDecodedError(parsed); + let parsed = tryParse(httpResponse.body); + if (parsed && typeof parsed === 'object') { + let value = parsed.value; + let isW3C = + value !== null && typeof value === 'object' + && typeof parsed.status === 'undefined'; + + if (!isW3C) { + error.checkLegacyResponse(parsed); + + // Adjust legacy new session responses to look like W3C to simplify + // later processing. + if (command.getName() === cmd.Name.NEW_SESSION + || command.getName() == cmd.Name.DESCRIBE_SESSION) { + value = parsed; } - return parsed; - } - // If this is a new session command, we need to check for a W3C compliant - // error object. This is necessary since a successful new session command - // is what puts the executor into W3C mode. - if (httpResponse.status > 399 - && (command.getName() == cmd.Name.NEW_SESSION - || command.getName() === cmd.Name.DESCRIBE_SESSION) - && error.isErrorResponse(parsed)) { - error.throwDecodedError(parsed); + } else if (httpResponse.status > 399) { + error.throwDecodedError(value); } - error.checkLegacyResponse(parsed); - return parsed; + return {isW3C, value}; + } + + if (parsed !== undefined) { + return {isW3C: false, value: parsed}; } let value = httpResponse.body.replace(/\r\n/g, '\n'); @@ -527,7 +536,7 @@ function parseHttpResponse(command, httpResponse, w3c) { throw new error.WebDriverError(value); } - return value || null; + return {isW3C: false, value: value || null}; } diff --git a/node_modules/selenium-webdriver/lib/test/data/click_tests/disabled_element.html b/node_modules/selenium-webdriver/lib/test/data/click_tests/disabled_element.html new file mode 100644 index 000000000..7113e1bc0 --- /dev/null +++ b/node_modules/selenium-webdriver/lib/test/data/click_tests/disabled_element.html @@ -0,0 +1,12 @@ + + + + Clicking on a disabled element + + +

See below

+
+ +
+ + \ No newline at end of file diff --git a/node_modules/selenium-webdriver/lib/test/data/nestedElements.html b/node_modules/selenium-webdriver/lib/test/data/nestedElements.html index cf00083cf..88eda51fe 100644 --- a/node_modules/selenium-webdriver/lib/test/data/nestedElements.html +++ b/node_modules/selenium-webdriver/lib/test/data/nestedElements.html @@ -5,6 +5,15 @@

inside

+
+

space

+

css escapes

+
+
+

second copy for testing plural findElements

+

second copy

+
+
Here's a checkbox: