selenium-webdriver 4.3.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.md CHANGED
@@ -1,3 +1,45 @@
1
+ ## v4.5.0
2
+
3
+ #### :rocket: New Feature
4
+
5
+ * Adds 'Select' support package
6
+ * selectByIndex
7
+ * selectByValue
8
+ * selectByVisibleText
9
+ * getAllSelectedOptions
10
+ * getFirstSelectedOption
11
+ * deselectAll
12
+ * deselectByVisibleText
13
+ * deselectByIndex
14
+ * deselectByValue
15
+ * Add support for Actions API sendKeys to designated element
16
+ * Adds mouse button enum for forward and backward navigation
17
+
18
+ #### :bug: Bug Fix
19
+
20
+ * Set min node support to 14.x.x (issue 1 in #10970)
21
+ * fix: geckodriver session with node 18.x.x (issue 2 in #10970)
22
+ * fix: JS firefox driver crashes on setting a profile (fixed with [commit](https://github.com/SeleniumHQ/selenium/commit/fa6deeea6bda1e73317157845772e114bd569b7d))
23
+ * fix: "SetExperimental" option is not available in webdriverjs (Javascript/Typescript) (#10959)
24
+ * fix: Do not allow Select class to select disabled options (#10812)
25
+
26
+ #### :nail_care: Polish
27
+
28
+ * Stop sending desiredCapabilities to local end and remote end
29
+ * tests: Quit driver instance after each test
30
+ * tests: Adds select by multiple(index,value, text) tests
31
+ * chore/code style changes, add util (#10975)
32
+ * chore/code style changes to common format (#10964)
33
+ * destructuring exports
34
+ * Moving from static to const to make js-dossier happy
35
+ * Removing circular dependency Between webdriver.js and http.js
36
+ * fix some typos in code and documentation
37
+ * add cdp v105 remove v102
38
+ * add cdp v106 remove v103
39
+
40
+ ## v4.4.0
41
+ * Add support CDP 104 and remove CDP 101
42
+
1
43
  ## v4.3.1
2
44
 
3
45
  * create new default service for every driver instance in chromium (#10796)
@@ -1126,3 +1168,4 @@ major version release (i.e. 1.0.0).
1126
1168
  * Initial release for npm:
1127
1169
 
1128
1170
  npm install selenium-webdriver
1171
+
package/README.md CHANGED
@@ -13,19 +13,19 @@ Selenium may be installed via npm with
13
13
  You will need to download additional components to work with each of the major
14
14
  browsers. The drivers for Chrome, Firefox, and Microsoft's IE and Edge web
15
15
  browsers are all standalone executables that should be placed on your system
16
- [PATH]. Apple's safaridriver is shipped with Safari 10 for OS X El Capitan and
17
- macOS Sierra. You will need to enable Remote Automation in the Develop menu of
18
- Safari 10 before testing.
16
+ [PATH]. Apple's safaridriver (v10 and above) can be found at the
17
+ following path – /usr/bin/safaridriver. To enable automation on safari,
18
+ you need to run command `safaridriver --enable`.
19
19
 
20
20
 
21
- | Browser | Component |
22
- | ----------------- | ---------------------------------- |
23
- | Chrome | [chromedriver(.exe)][chrome] |
24
- | Internet Explorer | [IEDriverServer.exe][release] |
25
- | Edge | [MicrosoftWebDriver.msi][edge] |
26
- | Firefox | [geckodriver(.exe)][geckodriver] |
27
- | Opera | [operadriver(.exe)][operadriver] |
28
- | Safari | [safaridriver] |
21
+ | Browser | Component |
22
+ |:-------------------|:------------------------------------|
23
+ | Chrome | [chromedriver(.exe)][chrome] |
24
+ | Internet Explorer | [IEDriverServer.exe][release] |
25
+ | Edge | [MicrosoftWebDriver.msi][edge] |
26
+ | Firefox | [geckodriver(.exe)][geckodriver] |
27
+ | Opera | [operadriver(.exe)][operadriver] |
28
+ | Safari | [safaridriver] |
29
29
 
30
30
  ## Usage
31
31
 
@@ -38,7 +38,7 @@ const {Builder, Browser, By, Key, until} = require('selenium-webdriver');
38
38
  (async function example() {
39
39
  let driver = await new Builder().forBrowser(Browser.FIREFOX).build();
40
40
  try {
41
- await driver.get('http://www.google.com/ncr');
41
+ await driver.get('https://www.google.com/ncr');
42
42
  await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
43
43
  await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
44
44
  } finally {
@@ -92,7 +92,7 @@ To use the Selenium Server, you will need to install the
92
92
  download the latest server from [Selenium][release]. Once downloaded, run the
93
93
  server with
94
94
 
95
- java -jar selenium-server-standalone-2.45.0.jar
95
+ java -jar selenium-server-4.4.0.jar standalone
96
96
 
97
97
  You may configure your tests to run against a remote server through the Builder
98
98
  API:
@@ -135,17 +135,17 @@ will also have "best effort" support. Releases older than the latest LTS,
135
135
  _semver-major_ releases, and all unstable release branches (e.g. "v.Next")
136
136
  are considered strictly unsupported.
137
137
 
138
- For example, suppose the current LTS and stable releases are v6.9.5 and v7.5.0,
138
+ For example, suppose the current LTS and stable releases are v14.20.0 and v18.8.0,
139
139
  respectively. Then a Selenium release would have the following support levels:
140
140
 
141
- | Version | Support |
142
- | ------- | ------------- |
143
- | <= 6.8 | _unsupported_ |
144
- | 6.9 | supported |
145
- | 7.0-4 | best effort |
146
- | 7.5 | supported |
147
- | >= 7.5 | best effort |
148
- | v.Next | _unsupported_ |
141
+ | Version | Support |
142
+ |:----------:|:---------------:|
143
+ | <= 14.19 | _unsupported_ |
144
+ | 14.20.0 | supported |
145
+ | 18.0-7 | best effort |
146
+ | 18.8.0 | supported |
147
+ | >= 18.8.0 | best effort |
148
+ | v.Next | _unsupported_ |
149
149
 
150
150
  ### Support Level Definitions
151
151
 
@@ -165,13 +165,13 @@ respectively. Then a Selenium release would have the following support levels:
165
165
  If Node releases a new [LTS] each October and a new major version every 6
166
166
  months, the support window for selenium-webdriver will be roughly:
167
167
 
168
- | Date | LTS | Stable |
169
- | --------- | ---: | -----: |
170
- | (current) | 8.9 | 9.0 |
171
- | 2018-04 | 8.x | 10.0 |
172
- | 2018-10 | 10.x | 11.0 |
173
- | 2019-04 | 10.x | 12.0 |
174
- | 2019-10 | 12.x | 13.0 |
168
+ | Release | Status | END-OF-LIFE |
169
+ |:---------:|:----------------:|:------------:|
170
+ | v14.x | Maintenance LTS | 2023-04-30 |
171
+ | v16.x | Active LTS | 2023-09-11 |
172
+ | v18.x | Current | 2025-04-30 |
173
+ | v19.x | Pending | 2023-06-01 |
174
+ | v20 | Pending | 2026-04-30 |
175
175
 
176
176
  ## Issues
177
177
 
package/index.js CHANGED
@@ -38,6 +38,7 @@ const safari = require('./safari')
38
38
  const session = require('./lib/session')
39
39
  const until = require('./lib/until')
40
40
  const webdriver = require('./lib/webdriver')
41
+ const select = require('./lib/select')
41
42
 
42
43
  const Browser = capabilities.Browser
43
44
  const Capabilities = capabilities.Capabilities
@@ -793,3 +794,4 @@ exports.error = error
793
794
  exports.logging = logging
794
795
  exports.promise = promise
795
796
  exports.until = until
797
+ exports.Select = select.Select
package/io/exec.js CHANGED
@@ -121,7 +121,7 @@ class Command {
121
121
  * @param {Options=} opt_options The command options.
122
122
  * @return {!Command} The launched command.
123
123
  */
124
- module.exports = function exec(command, opt_options) {
124
+ function exec(command, opt_options) {
125
125
  const options = opt_options || {}
126
126
 
127
127
  let proc = childProcess.spawn(command, options.args || [], {
@@ -158,6 +158,9 @@ module.exports = function exec(command, opt_options) {
158
158
 
159
159
  // Exported to improve generated API documentation.
160
160
 
161
- module.exports.Command = Command
162
- module.exports.Options = Options
163
- module.exports.Result = Result
161
+ module.exports = {
162
+ Command,
163
+ Options,
164
+ Result,
165
+ exec,
166
+ }
package/lib/by.js CHANGED
@@ -41,9 +41,8 @@
41
41
  * {name: string}|
42
42
  * {partialLinkText: string}|
43
43
  * {tagName: string}|
44
- * {xpath: string})}
44
+ * {xpath: string})} ByHash
45
45
  */
46
- var ByHash // eslint-disable-line
47
46
 
48
47
  /**
49
48
  * Error thrown if an invalid character is encountered while escaping a CSS
package/lib/command.js CHANGED
@@ -204,7 +204,7 @@ class Executor {
204
204
  // PUBLIC API
205
205
 
206
206
  module.exports = {
207
- Command: Command,
208
- Name: Name,
209
- Executor: Executor,
207
+ Command,
208
+ Name,
209
+ Executor,
210
210
  }
package/lib/error.js CHANGED
@@ -17,6 +17,8 @@
17
17
 
18
18
  'use strict'
19
19
 
20
+ const { isObject } = require('./util')
21
+
20
22
  /**
21
23
  * The base WebDriver error type. This error type is only used directly when a
22
24
  * more appropriate category is not defined for the offending error.
@@ -505,7 +507,7 @@ function encodeError(err) {
505
507
  * @see https://w3c.github.io/webdriver/webdriver-spec.html#protocol
506
508
  */
507
509
  function isErrorResponse(data) {
508
- return data && typeof data === 'object' && typeof data.error === 'string'
510
+ return isObject(data) && typeof data.error === 'string'
509
511
  }
510
512
 
511
513
  /**
@@ -540,15 +542,13 @@ function throwDecodedError(data) {
540
542
  function checkLegacyResponse(responseObj) {
541
543
  // Handle the legacy Selenium error response format.
542
544
  if (
543
- responseObj &&
544
- typeof responseObj === 'object' &&
545
- typeof responseObj['status'] === 'number' &&
546
- responseObj['status'] !== 0
545
+ isObject(responseObj) &&
546
+ typeof responseObj.status === 'number' &&
547
+ responseObj.status !== 0
547
548
  ) {
548
- let status = responseObj['status']
549
- let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError
549
+ const { status, value } = responseObj
550
550
 
551
- let value = responseObj['value']
551
+ let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError
552
552
 
553
553
  if (!value || typeof value !== 'object') {
554
554
  throw new ctor(value + '')
package/lib/http.js CHANGED
@@ -31,7 +31,8 @@ const error = require('./error')
31
31
  const logging = require('./logging')
32
32
  const promise = require('./promise')
33
33
  const { Session } = require('./session')
34
- const { WebElement } = require('./webdriver')
34
+ const webElement = require('./webelement')
35
+ const { isObject } = require('./util')
35
36
 
36
37
  const getAttribute = requireAtom(
37
38
  'get-attribute.js',
@@ -462,7 +463,7 @@ const CLIENTS =
462
463
  class Executor {
463
464
  /**
464
465
  * @param {!(Client|IThenable<!Client>)} client The client to use for sending
465
- * requests to the server, or a promise-like object that will resolve to
466
+ * requests to the server, or a promise-like object that will resolve
466
467
  * to the client.
467
468
  */
468
469
  constructor(client) {
@@ -572,10 +573,7 @@ function parseHttpResponse(command, httpResponse) {
572
573
 
573
574
  if (parsed && typeof parsed === 'object') {
574
575
  let value = parsed.value
575
- let isW3C =
576
- value !== null &&
577
- typeof value === 'object' &&
578
- typeof parsed.status === 'undefined'
576
+ let isW3C = isObject(value) && typeof parsed.status === 'undefined'
579
577
 
580
578
  if (!isW3C) {
581
579
  error.checkLegacyResponse(parsed)
@@ -625,10 +623,10 @@ function buildPath(path, parameters) {
625
623
  let key = pathParameters[i].substring(2) // Trim the /:
626
624
  if (key in parameters) {
627
625
  let value = parameters[key]
628
- if (WebElement.isId(value)) {
626
+ if (webElement.isId(value)) {
629
627
  // When inserting a WebElement into the URL, only use its ID value,
630
628
  // not the full JSON.
631
- value = WebElement.extractId(value)
629
+ value = webElement.extractId(value)
632
630
  }
633
631
  path = path.replace(pathParameters[i], '/' + value)
634
632
  delete parameters[key]
@@ -645,10 +643,10 @@ function buildPath(path, parameters) {
645
643
  // PUBLIC API
646
644
 
647
645
  module.exports = {
648
- Executor: Executor,
649
- Client: Client,
650
- Request: Request,
651
- Response: Response,
646
+ Executor,
647
+ Client,
648
+ Request,
649
+ Response,
652
650
  // Exported for testing.
653
- buildPath: buildPath,
651
+ buildPath,
654
652
  }
package/lib/input.js CHANGED
@@ -31,6 +31,8 @@ const Button = {
31
31
  LEFT: 0,
32
32
  MIDDLE: 1,
33
33
  RIGHT: 2,
34
+ BACK: 3,
35
+ FORWARD: 4,
34
36
  }
35
37
 
36
38
  /**
@@ -159,7 +161,8 @@ class FileDetector {
159
161
  * @return {!Promise<string>} A promise for the processed file path.
160
162
  * @package
161
163
  */
162
- handleFile(driver, path) { // eslint-disable-line
164
+ handleFile(_driver, path) {
165
+ // eslint-disable-line
163
166
  return Promise.resolve(path)
164
167
  }
165
168
  }
@@ -801,7 +804,13 @@ class Actions {
801
804
  * @return {!Actions} a self reference.
802
805
  */
803
806
  sendKeys(...keys) {
807
+ const { WebElement } = require('./webdriver')
808
+
804
809
  const actions = []
810
+ if (keys.length > 1 && keys[0] instanceof WebElement) {
811
+ this.click(keys[0])
812
+ keys.shift()
813
+ }
805
814
  for (const key of keys) {
806
815
  if (typeof key === 'string') {
807
816
  for (const symbol of key) {
package/lib/promise.js CHANGED
@@ -22,16 +22,7 @@
22
22
 
23
23
  'use strict'
24
24
 
25
- /**
26
- * Determines whether a {@code value} should be treated as a promise.
27
- * Any object whose "then" property is a function will be considered a promise.
28
- *
29
- * @param {?} value The value to test.
30
- * @return {boolean} Whether the value is a promise.
31
- */
32
- function isPromise(value) {
33
- return Object.prototype.toString.call(value) === '[object Promise]'
34
- }
25
+ const { isObject, isPromise } = require('./util')
35
26
 
36
27
  /**
37
28
  * Creates a promise that will be resolved at a set time in the future.
@@ -218,7 +209,7 @@ async function fullyResolved(value) {
218
209
  return fullyResolveKeys(/** @type {!Array} */ (value))
219
210
  }
220
211
 
221
- if (value && typeof value === 'object') {
212
+ if (isObject(value)) {
222
213
  return fullyResolveKeys(/** @type {!Object} */ (value))
223
214
  }
224
215