selenium-webdriver 4.8.2 → 4.9.1

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,27 @@
1
+ ## v4.9.1
2
+
3
+ #### :nail_care: Polish
4
+
5
+ * Add CDP files for v113 and remove v110
6
+
7
+ ## v4.9.0
8
+
9
+ #### :nail_care: Polish
10
+
11
+ * Adding CDP v112 and removing v109
12
+
13
+ #### :bug: Bug Fix
14
+
15
+ * Fix: return statement in submit() (#11883)
16
+ * [grid] Refining the UI configuration to allow sub paths work properly.
17
+ * Replace `execSync` with `spawnSync` in `seleniumManager.js` (#11649) (#11873)
18
+
19
+ #### :rocket: New Feature
20
+
21
+ * [BiDi] Add Script module commands and types (#11847)
22
+ * Selenium Manager get Browser Version from Options classes
23
+ * Selenium Manager use binary from Browser Options
24
+
1
25
  ## v4.8.2
2
26
 
3
27
  #### :nail_care: Polish
@@ -7,7 +31,7 @@
7
31
 
8
32
  #### :bug: Bug Fix
9
33
 
10
- fix: Using status from response (#11742)
34
+ * fix: Using status from response (#11742)
11
35
 
12
36
  ## v4.8.1
13
37
 
@@ -0,0 +1,34 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ const { LocalValue } = require('./protocolValue')
19
+ class ArgumentValue {
20
+ constructor(value) {
21
+ this.value = value
22
+ }
23
+
24
+ asMap() {
25
+ if (this.value instanceof LocalValue) {
26
+ return this.value.toJson()
27
+ } else {
28
+ // ReferenceValue
29
+ return this.value.asMap()
30
+ }
31
+ }
32
+ }
33
+
34
+ module.exports = { ArgumentValue }
@@ -15,6 +15,7 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
+ const { BrowsingContextInfo } = require('./browsingContextTypes')
18
19
  class BrowsingContext {
19
20
  constructor(driver) {
20
21
  this._driver = driver
@@ -145,31 +146,6 @@ class NavigateResult {
145
146
  }
146
147
  }
147
148
 
148
- class BrowsingContextInfo {
149
- constructor(id, url, children, parentBrowsingContext) {
150
- this._id = id
151
- this._url = url
152
- this._children = children
153
- this._parentBrowsingContext = parentBrowsingContext
154
- }
155
-
156
- get id() {
157
- return this._id
158
- }
159
-
160
- get url() {
161
- return this._url
162
- }
163
-
164
- get children() {
165
- return this._children
166
- }
167
-
168
- get parentBrowsingContext() {
169
- return this._parentBrowsingContext
170
- }
171
- }
172
-
173
149
  /**
174
150
  * initiate browsing context instance and return
175
151
  * @param driver
@@ -0,0 +1,95 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ const {
19
+ BrowsingContextInfo,
20
+ NavigationInfo,
21
+ } = require('./browsingContextTypes')
22
+
23
+ class BrowsingContextInspector {
24
+ constructor(driver, browsingContextIds) {
25
+ this._driver = driver
26
+ this._browsingContextIds = browsingContextIds
27
+ }
28
+
29
+ async init() {
30
+ this.bidi = await this._driver.getBidi()
31
+ }
32
+
33
+ async onBrowsingContextCreated(callback) {
34
+ await this.subscribeAndHandleEvent(
35
+ 'browsingContext.contextCreated',
36
+ callback
37
+ )
38
+ }
39
+
40
+ async onDomContentLoaded(callback) {
41
+ await this.subscribeAndHandleEvent(
42
+ 'browsingContext.domContentLoaded',
43
+ callback
44
+ )
45
+ }
46
+
47
+ async onBrowsingContextLoaded(callback) {
48
+ await this.subscribeAndHandleEvent('browsingContext.load', callback)
49
+ }
50
+
51
+ async subscribeAndHandleEvent(eventType, callback) {
52
+ if (this._browsingContextIds != null) {
53
+ await this.bidi.subscribe(eventType, this._browsingContextIds)
54
+ } else {
55
+ await this.bidi.subscribe(eventType)
56
+ }
57
+ this._on(callback)
58
+ }
59
+
60
+ async _on(callback) {
61
+ this.ws = await this.bidi.socket
62
+ this.ws.on('message', (event) => {
63
+ const { params } = JSON.parse(Buffer.from(event.toString()))
64
+ if (params) {
65
+ let response = null
66
+ if ('navigation' in params) {
67
+ response = new NavigationInfo(
68
+ params.context,
69
+ params.navigation,
70
+ params.timestamp,
71
+ params.url
72
+ )
73
+ } else if ('accepted' in params) {
74
+ /* Needs to be updated when browsers implement other events */
75
+ } else {
76
+ response = new BrowsingContextInfo(
77
+ params.context,
78
+ params.url,
79
+ params.children,
80
+ params.parent
81
+ )
82
+ }
83
+ callback(response)
84
+ }
85
+ })
86
+ }
87
+ }
88
+
89
+ async function getBrowsingContextInstance(driver, browsingContextIds = null) {
90
+ let instance = new BrowsingContextInspector(driver, browsingContextIds)
91
+ await instance.init()
92
+ return instance
93
+ }
94
+
95
+ module.exports = getBrowsingContextInstance
@@ -0,0 +1,52 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ class BrowsingContextInfo {
19
+ constructor(id, url, children, parentBrowsingContext) {
20
+ this._id = id
21
+ this._url = url
22
+ this._children = children
23
+ this._parentBrowsingContext = parentBrowsingContext
24
+ }
25
+
26
+ get id() {
27
+ return this._id
28
+ }
29
+
30
+ get url() {
31
+ return this._url
32
+ }
33
+
34
+ get children() {
35
+ return this._children
36
+ }
37
+
38
+ get parentBrowsingContext() {
39
+ return this._parentBrowsingContext
40
+ }
41
+ }
42
+
43
+ class NavigationInfo {
44
+ constructor(browsingContextId, navigationId, timestamp, url) {
45
+ this.browsingContextId = browsingContextId
46
+ this.navigationId = navigationId
47
+ this.timestamp = timestamp
48
+ this.url = url
49
+ }
50
+ }
51
+
52
+ module.exports = { BrowsingContextInfo, NavigationInfo }
@@ -0,0 +1,60 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ const EvaluateResultType = {
19
+ SUCCESS: 'success',
20
+ EXCEPTION: 'exception',
21
+ }
22
+
23
+ class EvaluateResultSuccess {
24
+ constructor(realmId, value) {
25
+ this.resultType = EvaluateResultType.SUCCESS
26
+ this.realmId = realmId
27
+ this.result = value
28
+ }
29
+ }
30
+
31
+ class EvaluateResultException {
32
+ constructor(realmId, exceptionDetails) {
33
+ this.resultType = EvaluateResultType.EXCEPTION
34
+ this.realmId = realmId
35
+ this.exceptionDetails = exceptionDetails
36
+ }
37
+ }
38
+
39
+ class ExceptionDetails {
40
+ constructor(exceptionDetails) {
41
+ this.columnNumber =
42
+ 'columnNumber' in exceptionDetails
43
+ ? exceptionDetails['columnNumber']
44
+ : null
45
+ this.exception =
46
+ 'exception' in exceptionDetails ? exceptionDetails['exception'] : null
47
+ this.lineNumber =
48
+ 'lineNumber' in exceptionDetails ? exceptionDetails['lineNumber'] : null
49
+ this.stackTrace =
50
+ 'stackTrace' in exceptionDetails ? exceptionDetails['stackTrace'] : null
51
+ this.text = 'text' in exceptionDetails ? exceptionDetails['text'] : null
52
+ }
53
+ }
54
+
55
+ module.exports = {
56
+ EvaluateResultType,
57
+ EvaluateResultSuccess,
58
+ EvaluateResultException,
59
+ ExceptionDetails,
60
+ }
@@ -18,64 +18,64 @@
18
18
  'use strict'
19
19
 
20
20
  class BaseLogEntry {
21
- constructor (level, text, timeStamp, stackTrace) {
21
+ constructor(level, text, timeStamp, stackTrace) {
22
22
  this._level = level
23
23
  this._text = text
24
24
  this._timeStamp = timeStamp
25
25
  this._stackTrace = stackTrace
26
26
  }
27
27
 
28
- get level () {
28
+ get level() {
29
29
  return this._level
30
30
  }
31
31
 
32
- get text () {
32
+ get text() {
33
33
  return this._text
34
34
  }
35
35
 
36
- get timeStamp () {
36
+ get timeStamp() {
37
37
  return this._timeStamp
38
38
  }
39
39
 
40
- get stackTrace () {
40
+ get stackTrace() {
41
41
  return this._stackTrace
42
42
  }
43
43
  }
44
44
 
45
45
  class GenericLogEntry extends BaseLogEntry {
46
- constructor (level, text, timeStamp, type, stackTrace) {
46
+ constructor(level, text, timeStamp, type, stackTrace) {
47
47
  super(level, text, timeStamp, stackTrace)
48
48
  this._type = type
49
49
  }
50
50
 
51
- get type () {
51
+ get type() {
52
52
  return this._type
53
53
  }
54
54
  }
55
55
 
56
56
  class ConsoleLogEntry extends GenericLogEntry {
57
- constructor (level, text, timeStamp, type, method, realm, args, stackTrace) {
57
+ constructor(level, text, timeStamp, type, method, realm, args, stackTrace) {
58
58
  super(level, text, timeStamp, type, stackTrace)
59
59
  this._method = method
60
60
  this._realm = realm
61
61
  this._args = args
62
62
  }
63
63
 
64
- get method () {
64
+ get method() {
65
65
  return this._method
66
66
  }
67
67
 
68
- get realm () {
68
+ get realm() {
69
69
  return this._realm
70
70
  }
71
71
 
72
- get args () {
72
+ get args() {
73
73
  return this._args
74
74
  }
75
75
  }
76
76
 
77
77
  class JavascriptLogEntry extends GenericLogEntry {
78
- constructor (level, text, timeStamp, type, stackTrace) {
78
+ constructor(level, text, timeStamp, type, stackTrace) {
79
79
  super(level, text, timeStamp, type, stackTrace)
80
80
  }
81
81
  }
@@ -83,5 +83,8 @@ class JavascriptLogEntry extends GenericLogEntry {
83
83
  // PUBLIC API
84
84
 
85
85
  module.exports = {
86
- BaseLogEntry, GenericLogEntry, ConsoleLogEntry, JavascriptLogEntry,
86
+ BaseLogEntry,
87
+ GenericLogEntry,
88
+ ConsoleLogEntry,
89
+ JavascriptLogEntry,
87
90
  }
@@ -0,0 +1,97 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ const PrimitiveType = {
19
+ UNDEFINED: 'undefined',
20
+ NULL: 'null',
21
+ STRING: 'string',
22
+ NUMBER: 'number',
23
+ SPECIAL_NUMBER: 'number',
24
+ BOOLEAN: 'boolean',
25
+ BIGINT: 'bigint',
26
+
27
+ findByName(name) {
28
+ return (
29
+ Object.values(this).find((type) => {
30
+ return (
31
+ typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
32
+ )
33
+ }) || null
34
+ )
35
+ },
36
+ }
37
+
38
+ const NonPrimitiveType = {
39
+ ARRAY: 'array',
40
+ DATE: 'date',
41
+ MAP: 'map',
42
+ OBJECT: 'object',
43
+ REGULAR_EXPRESSION: 'regexp',
44
+ SET: 'set',
45
+
46
+ findByName(name) {
47
+ return (
48
+ Object.values(this).find((type) => {
49
+ return (
50
+ typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
51
+ )
52
+ }) || null
53
+ )
54
+ },
55
+ }
56
+
57
+ const RemoteType = {
58
+ SYMBOL: 'symbol',
59
+ FUNCTION: 'function',
60
+ WEAK_MAP: 'weakmap',
61
+ WEAK_SET: 'weakset',
62
+ ITERATOR: 'iterator',
63
+ GENERATOR: 'generator',
64
+ ERROR: 'error',
65
+ PROXY: 'proxy',
66
+ PROMISE: 'promise',
67
+ TYPED_ARRAY: 'typedarray',
68
+ ARRAY_BUFFER: 'arraybuffer',
69
+ NODE_LIST: 'nodelist',
70
+ HTML_COLLECTION: 'htmlcollection',
71
+ NODE: 'node',
72
+ WINDOW: 'window',
73
+
74
+ findByName(name) {
75
+ return (
76
+ Object.values(this).find((type) => {
77
+ return (
78
+ typeof type === 'string' && name.toLowerCase() === type.toLowerCase()
79
+ )
80
+ }) || null
81
+ )
82
+ },
83
+ }
84
+
85
+ const SpecialNumberType = {
86
+ NAN: 'NaN',
87
+ MINUS_ZERO: '-0',
88
+ INFINITY: 'Infinity',
89
+ MINUS_INFINITY: '-Infinity',
90
+ }
91
+
92
+ module.exports = {
93
+ PrimitiveType,
94
+ NonPrimitiveType,
95
+ RemoteType,
96
+ SpecialNumberType,
97
+ }
@@ -0,0 +1,204 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
18
+ const {
19
+ PrimitiveType,
20
+ NonPrimitiveType,
21
+ RemoteType,
22
+ } = require('./protocolType')
23
+
24
+ const TYPE_CONSTANT = 'type'
25
+ const VALUE_CONSTANT = 'value'
26
+ const RemoteReferenceType = {
27
+ HANDLE: 'handle',
28
+ SHARED_ID: 'shareId',
29
+ }
30
+
31
+ class LocalValue {
32
+ constructor(type, value = null) {
33
+ if (type === PrimitiveType.UNDEFINED || type === PrimitiveType.NULL) {
34
+ this.type = type
35
+ } else {
36
+ this.type = type
37
+ this.value = value
38
+ }
39
+ }
40
+
41
+ static createStringValue(value) {
42
+ return new LocalValue(PrimitiveType.STRING, value)
43
+ }
44
+
45
+ static createNumberValue(value) {
46
+ return new LocalValue(PrimitiveType.NUMBER, value)
47
+ }
48
+
49
+ static createSpecialNumberValue(value) {
50
+ return new LocalValue(PrimitiveType.SPECIAL_NUMBER, value)
51
+ }
52
+
53
+ static createUndefinedValue() {
54
+ return new LocalValue(PrimitiveType.UNDEFINED)
55
+ }
56
+
57
+ static createNullValue() {
58
+ return new LocalValue(PrimitiveType.NULL)
59
+ }
60
+
61
+ static createBooleanValue(value) {
62
+ return new LocalValue(PrimitiveType.BOOLEAN, value)
63
+ }
64
+
65
+ static createBigIntValue(value) {
66
+ return new LocalValue(PrimitiveType.BIGINT, value)
67
+ }
68
+
69
+ static createArrayValue(value) {
70
+ return new LocalValue(NonPrimitiveType.ARRAY, value)
71
+ }
72
+
73
+ static createDateValue(value) {
74
+ return new LocalValue(NonPrimitiveType.DATE, value)
75
+ }
76
+
77
+ static createMapValue(map) {
78
+ let value = []
79
+ Object.entries(map).forEach((entry) => {
80
+ value.push(entry)
81
+ })
82
+ return new LocalValue(NonPrimitiveType.MAP, value)
83
+ }
84
+
85
+ static createObjectValue(map) {
86
+ let value = []
87
+ Object.entries(map).forEach((entry) => {
88
+ value.push(entry)
89
+ })
90
+ return new LocalValue(NonPrimitiveType.OBJECT, value)
91
+ }
92
+
93
+ static createRegularExpressionValue(value) {
94
+ return new LocalValue(NonPrimitiveType.REGULAR_EXPRESSION, value)
95
+ }
96
+
97
+ static createSetValue(value) {
98
+ return new LocalValue(NonPrimitiveType.SET, value)
99
+ }
100
+
101
+ toJson() {
102
+ let toReturn = {}
103
+ toReturn[TYPE_CONSTANT] = this.type
104
+
105
+ if (
106
+ !(
107
+ this.type === PrimitiveType.NULL ||
108
+ this.type === PrimitiveType.UNDEFINED
109
+ )
110
+ ) {
111
+ toReturn[VALUE_CONSTANT] = this.value
112
+ }
113
+ return toReturn
114
+ }
115
+ }
116
+
117
+ class RemoteValue {
118
+ constructor(remoteValue) {
119
+ this.type = null
120
+ this.handle = null
121
+ this.internalId = null
122
+ this.value = null
123
+ this.sharedId = null
124
+
125
+ if ('type' in remoteValue) {
126
+ var typeString = remoteValue['type']
127
+ if (PrimitiveType.findByName(typeString) != null) {
128
+ this.type = PrimitiveType.findByName(typeString)
129
+ } else if (NonPrimitiveType.findByName(typeString) != null) {
130
+ this.type = NonPrimitiveType.findByName(typeString)
131
+ } else {
132
+ this.type = RemoteType.findByName(typeString)
133
+ }
134
+ }
135
+
136
+ if ('handle' in remoteValue) {
137
+ this.handle = remoteValue['handle']
138
+ }
139
+
140
+ if ('internalId' in remoteValue) {
141
+ this.internalId = remoteValue['internalId']
142
+ }
143
+
144
+ if ('value' in remoteValue) {
145
+ this.value = remoteValue['value']
146
+ }
147
+
148
+ if ('sharedId' in remoteValue) {
149
+ this.sharedId = remoteValue['sharedId']
150
+ }
151
+
152
+ if (this.value != null) {
153
+ this.value = this.deserializeValue(this.value, this.type)
154
+ }
155
+ }
156
+
157
+ deserializeValue(value, type) {
158
+ if ([NonPrimitiveType.MAP, NonPrimitiveType.OBJECT].includes(type)) {
159
+ return Object.fromEntries(value)
160
+ } else if (type === NonPrimitiveType.REGULAR_EXPRESSION) {
161
+ return new RegExpValue(value.pattern, value.flags)
162
+ }
163
+ return value
164
+ }
165
+ }
166
+
167
+ class ReferenceValue {
168
+ constructor(handle, shareId) {
169
+ if (handle === RemoteReferenceType.HANDLE) {
170
+ this.handle = shareId
171
+ } else {
172
+ this.handle = handle
173
+ this.shareId = shareId
174
+ }
175
+ }
176
+
177
+ asMap() {
178
+ const toReturn = {}
179
+ if (this.handle != null) {
180
+ toReturn[RemoteReferenceType.HANDLE] = this.handle
181
+ }
182
+
183
+ if (this.shareId != null) {
184
+ toReturn[RemoteReferenceType.SHARED_ID] = this.shareId
185
+ }
186
+
187
+ return toReturn
188
+ }
189
+ }
190
+
191
+ class RegExpValue {
192
+ constructor(pattern, flags = null) {
193
+ this.pattern = pattern
194
+ this.flags = flags
195
+ }
196
+ }
197
+
198
+ module.exports = {
199
+ LocalValue,
200
+ RemoteValue,
201
+ ReferenceValue,
202
+ RemoteReferenceType,
203
+ RegExpValue,
204
+ }