selenium-webdriver 4.0.0-beta.4 → 4.1.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 +55 -1
- package/README.md +4 -2
- package/chromium.js +67 -25
- package/devtools/CDPConnection.js +9 -4
- package/devtools/networkinterceptor.js +88 -0
- package/edge.js +14 -20
- package/firefox.js +25 -1
- package/http/index.js +36 -15
- package/http/util.js +14 -20
- package/ie.js +8 -8
- package/index.js +17 -1
- package/io/index.js +47 -46
- package/lib/atoms/find-elements.js +2 -2
- package/lib/atoms/get-attribute.js +25 -25
- package/lib/by.js +42 -24
- package/lib/capabilities.js +11 -2
- package/lib/command.js +5 -0
- package/lib/error.js +24 -0
- package/lib/http.js +12 -7
- package/lib/input.js +4 -15
- package/lib/webdriver.js +372 -129
- package/net/portprober.js +1 -1
- package/opera.js +3 -3
- package/package.json +2 -3
- package/remote/index.js +3 -3
- package/testing/index.js +9 -10
package/lib/capabilities.js
CHANGED
|
@@ -83,7 +83,7 @@ const Platform = {
|
|
|
83
83
|
*
|
|
84
84
|
* @record
|
|
85
85
|
*/
|
|
86
|
-
function Timeouts() {
|
|
86
|
+
function Timeouts() {}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Defines when, in milliseconds, to interrupt a script that is being
|
|
@@ -263,7 +263,9 @@ class Capabilities {
|
|
|
263
263
|
* @return {!Capabilities} A basic set of capabilities for Firefox.
|
|
264
264
|
*/
|
|
265
265
|
static firefox() {
|
|
266
|
-
return new Capabilities()
|
|
266
|
+
return new Capabilities()
|
|
267
|
+
.setBrowserName(Browser.FIREFOX)
|
|
268
|
+
.set('moz:debuggerAddress', true)
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
/**
|
|
@@ -280,6 +282,13 @@ class Capabilities {
|
|
|
280
282
|
return new Capabilities().setBrowserName(Browser.SAFARI)
|
|
281
283
|
}
|
|
282
284
|
|
|
285
|
+
/**
|
|
286
|
+
* @return {!Capabilities} A basic set of capabilities for Opera
|
|
287
|
+
*/
|
|
288
|
+
static opera() {
|
|
289
|
+
return new Capabilities().setBrowserName(Browser.OPERA)
|
|
290
|
+
}
|
|
291
|
+
|
|
283
292
|
/**
|
|
284
293
|
* @return {!Object<string, ?>} The JSON representation of this instance.
|
|
285
294
|
* Note, the returned object may contain nested promised values.
|
package/lib/command.js
CHANGED
|
@@ -168,6 +168,11 @@ const Name = {
|
|
|
168
168
|
GET_ALERT_TEXT: 'getAlertText',
|
|
169
169
|
SET_ALERT_TEXT: 'setAlertValue',
|
|
170
170
|
|
|
171
|
+
// Shadow DOM Commands
|
|
172
|
+
GET_SHADOW_ROOT: 'getShadowRoot',
|
|
173
|
+
FIND_ELEMENT_FROM_SHADOWROOT: 'findElementFromShadowRoot',
|
|
174
|
+
FIND_ELEMENTS_FROM_SHADOWROOT: 'findElementsFromShadowRoot',
|
|
175
|
+
|
|
171
176
|
GET_AVAILABLE_LOG_TYPES: 'getAvailableLogTypes',
|
|
172
177
|
GET_LOG: 'getLog',
|
|
173
178
|
GET_SESSION_LOGS: 'getSessionLogs',
|
package/lib/error.js
CHANGED
|
@@ -39,6 +39,16 @@ class WebDriverError extends Error {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Indicates the shadow root is no longer attached to the DOM
|
|
44
|
+
*/
|
|
45
|
+
class DetachedShadowRootError extends WebDriverError {
|
|
46
|
+
/** @param {string=} opt_error the error message, if any. */
|
|
47
|
+
constructor(opt_error) {
|
|
48
|
+
super(opt_error)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
/**
|
|
43
53
|
* Indicates a {@linkplain ./webdriver.WebElement#click click command} could not
|
|
44
54
|
* completed because the click target is obscured by other elements on the
|
|
@@ -201,6 +211,16 @@ class NoSuchElementError extends WebDriverError {
|
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
|
|
214
|
+
/**
|
|
215
|
+
* A ShadowRoot could not be located on the element
|
|
216
|
+
*/
|
|
217
|
+
class NoSuchShadowRootError extends WebDriverError {
|
|
218
|
+
/** @param {string=} opt_error the error message, if any. */
|
|
219
|
+
constructor(opt_error) {
|
|
220
|
+
super(opt_error);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
204
224
|
/**
|
|
205
225
|
* A request to switch to a frame could not be satisfied because the frame
|
|
206
226
|
* could not be found.
|
|
@@ -420,6 +440,7 @@ const LEGACY_ERROR_CODE_TO_TYPE = new Map([
|
|
|
420
440
|
|
|
421
441
|
const ERROR_CODE_TO_TYPE = new Map([
|
|
422
442
|
['unknown error', WebDriverError],
|
|
443
|
+
['detached shadow root', DetachedShadowRootError],
|
|
423
444
|
['element click intercepted', ElementClickInterceptedError],
|
|
424
445
|
['element not interactable', ElementNotInteractableError],
|
|
425
446
|
['element not selectable', ElementNotSelectableError],
|
|
@@ -436,6 +457,7 @@ const ERROR_CODE_TO_TYPE = new Map([
|
|
|
436
457
|
['no such cookie', NoSuchCookieError],
|
|
437
458
|
['no such element', NoSuchElementError],
|
|
438
459
|
['no such frame', NoSuchFrameError],
|
|
460
|
+
['no such shadow root', NoSuchShadowRootError],
|
|
439
461
|
['no such window', NoSuchWindowError],
|
|
440
462
|
['script timeout', ScriptTimeoutError],
|
|
441
463
|
['session not created', SessionNotCreatedError],
|
|
@@ -569,6 +591,7 @@ module.exports = {
|
|
|
569
591
|
ErrorCode,
|
|
570
592
|
|
|
571
593
|
WebDriverError,
|
|
594
|
+
DetachedShadowRootError,
|
|
572
595
|
ElementClickInterceptedError,
|
|
573
596
|
ElementNotInteractableError,
|
|
574
597
|
ElementNotSelectableError,
|
|
@@ -584,6 +607,7 @@ module.exports = {
|
|
|
584
607
|
NoSuchCookieError,
|
|
585
608
|
NoSuchElementError,
|
|
586
609
|
NoSuchFrameError,
|
|
610
|
+
NoSuchShadowRootError,
|
|
587
611
|
NoSuchSessionError,
|
|
588
612
|
NoSuchWindowError,
|
|
589
613
|
ScriptTimeoutError,
|
package/lib/http.js
CHANGED
|
@@ -31,7 +31,7 @@ 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, ShadowRoot } = require('./webdriver')
|
|
35
35
|
|
|
36
36
|
const getAttribute = requireAtom(
|
|
37
37
|
'get-attribute.js',
|
|
@@ -63,8 +63,8 @@ function requireAtom(module, bazelTarget) {
|
|
|
63
63
|
console.log(ex2)
|
|
64
64
|
throw Error(
|
|
65
65
|
`Failed to import atoms module ${module}. If running in dev mode, you` +
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
` need to run \`bazel build ${bazelTarget}\` from the project` +
|
|
67
|
+
`root: ${ex}`
|
|
68
68
|
)
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -173,7 +173,7 @@ var CommandSpec // eslint-disable-line
|
|
|
173
173
|
/** @typedef {function(!cmd.Command): !cmd.Command} */
|
|
174
174
|
var CommandTransformer // eslint-disable-line
|
|
175
175
|
|
|
176
|
-
class InternalTypeError extends TypeError {}
|
|
176
|
+
class InternalTypeError extends TypeError { }
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* @param {!cmd.Command} command The initial command.
|
|
@@ -421,6 +421,10 @@ const W3C_COMMAND_MAP = new Map([
|
|
|
421
421
|
],
|
|
422
422
|
// print page.
|
|
423
423
|
[cmd.Name.PRINT_PAGE, post('/session/:sessionId/print')],
|
|
424
|
+
// Shadow Root
|
|
425
|
+
[cmd.Name.GET_SHADOW_ROOT, get('/session/:sessionId/element/:id/shadow')],
|
|
426
|
+
[cmd.Name.FIND_ELEMENT_FROM_SHADOWROOT, post('/session/:sessionId/shadow/:id/element')],
|
|
427
|
+
[cmd.Name.FIND_ELEMENTS_FROM_SHADOWROOT, post('/session/:sessionId/shadow/:id/elements')],
|
|
424
428
|
// Log extensions.
|
|
425
429
|
[cmd.Name.GET_LOG, post('/session/:sessionId/se/log')],
|
|
426
430
|
[cmd.Name.GET_AVAILABLE_LOG_TYPES, get('/session/:sessionId/se/log/types')],
|
|
@@ -441,7 +445,7 @@ class Client {
|
|
|
441
445
|
* @return {!Promise<Response>} A promise that will be fulfilled with the
|
|
442
446
|
* server's response.
|
|
443
447
|
*/
|
|
444
|
-
send(httpRequest) {} // eslint-disable-line
|
|
448
|
+
send(httpRequest) { } // eslint-disable-line
|
|
445
449
|
}
|
|
446
450
|
|
|
447
451
|
/**
|
|
@@ -490,7 +494,8 @@ function buildRequest(customCommands, w3c, command) {
|
|
|
490
494
|
}
|
|
491
495
|
}
|
|
492
496
|
|
|
493
|
-
const CLIENTS =
|
|
497
|
+
const CLIENTS =
|
|
498
|
+
/** !WeakMap<!Executor, !(Client|IThenable<!Client>)> */ new WeakMap()
|
|
494
499
|
|
|
495
500
|
/**
|
|
496
501
|
* A command executor that communicates with the server using JSON over HTTP.
|
|
@@ -583,7 +588,7 @@ class Executor {
|
|
|
583
588
|
// No implementations use the `capabilities` key yet...
|
|
584
589
|
let capabilities = value.capabilities || value.value
|
|
585
590
|
return new Session(
|
|
586
|
-
/** @type {{sessionId: string}} */
|
|
591
|
+
/** @type {{sessionId: string}} */(value).sessionId,
|
|
587
592
|
capabilities
|
|
588
593
|
)
|
|
589
594
|
}
|
package/lib/input.js
CHANGED
|
@@ -20,14 +20,8 @@
|
|
|
20
20
|
/**
|
|
21
21
|
* @fileoverview Defines types related to user input with the WebDriver API.
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
const promise = require('./promise')
|
|
25
23
|
const { Command, Name } = require('./command')
|
|
26
|
-
const {
|
|
27
|
-
InvalidArgumentError,
|
|
28
|
-
UnknownCommandError,
|
|
29
|
-
UnsupportedOperationError,
|
|
30
|
-
} = require('./error')
|
|
24
|
+
const { InvalidArgumentError } = require('./error')
|
|
31
25
|
|
|
32
26
|
/**
|
|
33
27
|
* Enumeration of the buttons used in the advanced interactions API.
|
|
@@ -503,7 +497,6 @@ class Actions {
|
|
|
503
497
|
* sequence (see class description for details).
|
|
504
498
|
*/
|
|
505
499
|
constructor(executor, { async = false } = {}) {
|
|
506
|
-
|
|
507
500
|
/** @private @const */
|
|
508
501
|
this.executor_ = executor
|
|
509
502
|
|
|
@@ -882,13 +875,9 @@ class Actions {
|
|
|
882
875
|
return Promise.resolve()
|
|
883
876
|
}
|
|
884
877
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
)
|
|
889
|
-
} catch (ex) {
|
|
890
|
-
throw ex
|
|
891
|
-
}
|
|
878
|
+
await this.executor_.execute(
|
|
879
|
+
new Command(Name.ACTIONS).setParameter('actions', _actions)
|
|
880
|
+
)
|
|
892
881
|
}
|
|
893
882
|
}
|
|
894
883
|
|