selenium-webdriver 4.17.0 → 4.18.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.
Files changed (59) hide show
  1. package/CHANGES.md +240 -196
  2. package/bidi/addInterceptParameters.js +86 -0
  3. package/bidi/browsingContext.js +144 -37
  4. package/bidi/browsingContextInspector.js +13 -40
  5. package/bidi/evaluateResult.js +4 -10
  6. package/bidi/filterBy.js +2 -6
  7. package/bidi/index.js +31 -29
  8. package/bidi/input.js +1 -4
  9. package/bidi/interceptPhase.js +24 -0
  10. package/bidi/logInspector.js +15 -20
  11. package/bidi/network.js +178 -0
  12. package/bidi/networkInspector.js +8 -2
  13. package/bidi/networkTypes.js +22 -49
  14. package/bidi/protocolType.js +3 -9
  15. package/bidi/protocolValue.js +6 -25
  16. package/bidi/realmInfo.js +2 -10
  17. package/bidi/scriptManager.js +20 -59
  18. package/bidi/urlPattern.js +58 -0
  19. package/bin/linux/selenium-manager +0 -0
  20. package/bin/macos/selenium-manager +0 -0
  21. package/bin/windows/selenium-manager.exe +0 -0
  22. package/chrome.js +1 -8
  23. package/chromium.js +27 -109
  24. package/common/driverFinder.js +1 -1
  25. package/common/seleniumManager.js +9 -18
  26. package/devtools/CDPConnection.js +1 -3
  27. package/edge.js +1 -3
  28. package/example/chrome_android.js +2 -5
  29. package/example/chrome_mobile_emulation.js +2 -4
  30. package/example/google_search.js +1 -3
  31. package/example/headless.js +4 -10
  32. package/example/logging.js +3 -9
  33. package/firefox.js +55 -109
  34. package/http/index.js +7 -10
  35. package/ie.js +5 -15
  36. package/index.js +7 -29
  37. package/io/exec.js +1 -2
  38. package/io/index.js +3 -3
  39. package/io/zip.js +8 -30
  40. package/lib/by.js +2 -9
  41. package/lib/capabilities.js +3 -9
  42. package/lib/command.js +3 -3
  43. package/lib/error.js +2 -9
  44. package/lib/http.js +34 -131
  45. package/lib/input.js +10 -34
  46. package/lib/logging.js +3 -11
  47. package/lib/promise.js +2 -7
  48. package/lib/select.js +3 -9
  49. package/lib/until.js +28 -49
  50. package/lib/util.js +1 -4
  51. package/lib/virtual_authenticator.js +4 -22
  52. package/lib/webdriver.js +118 -297
  53. package/lib/webelement.js +1 -5
  54. package/net/index.js +1 -4
  55. package/package.json +2 -1
  56. package/remote/index.js +9 -24
  57. package/remote/util.js +6 -19
  58. package/safari.js +3 -8
  59. package/testing/index.js +6 -11
@@ -55,11 +55,7 @@ class ScriptManager {
55
55
  await this.bidi.send(params)
56
56
  }
57
57
 
58
- async disownBrowsingContextScript(
59
- browsingContextId,
60
- handles,
61
- sandbox = null
62
- ) {
58
+ async disownBrowsingContextScript(browsingContextId, handles, sandbox = null) {
63
59
  const params = {
64
60
  method: 'script.disown',
65
61
  params: {
@@ -83,7 +79,7 @@ class ScriptManager {
83
79
  awaitPromise,
84
80
  argumentValueList = null,
85
81
  thisParameter = null,
86
- resultOwnership = null
82
+ resultOwnership = null,
87
83
  ) {
88
84
  const params = this.getCallFunctionParams(
89
85
  'realm',
@@ -93,7 +89,7 @@ class ScriptManager {
93
89
  awaitPromise,
94
90
  argumentValueList,
95
91
  thisParameter,
96
- resultOwnership
92
+ resultOwnership,
97
93
  )
98
94
 
99
95
  const command = {
@@ -112,7 +108,7 @@ class ScriptManager {
112
108
  argumentValueList = null,
113
109
  thisParameter = null,
114
110
  resultOwnership = null,
115
- sandbox = null
111
+ sandbox = null,
116
112
  ) {
117
113
  const params = this.getCallFunctionParams(
118
114
  'contextTarget',
@@ -122,7 +118,7 @@ class ScriptManager {
122
118
  awaitPromise,
123
119
  argumentValueList,
124
120
  thisParameter,
125
- resultOwnership
121
+ resultOwnership,
126
122
  )
127
123
 
128
124
  const command = {
@@ -133,20 +129,8 @@ class ScriptManager {
133
129
  return this.createEvaluateResult(response)
134
130
  }
135
131
 
136
- async evaluateFunctionInRealm(
137
- realmId,
138
- expression,
139
- awaitPromise,
140
- resultOwnership = null
141
- ) {
142
- const params = this.getEvaluateParams(
143
- 'realm',
144
- realmId,
145
- null,
146
- expression,
147
- awaitPromise,
148
- resultOwnership
149
- )
132
+ async evaluateFunctionInRealm(realmId, expression, awaitPromise, resultOwnership = null) {
133
+ const params = this.getEvaluateParams('realm', realmId, null, expression, awaitPromise, resultOwnership)
150
134
 
151
135
  const command = {
152
136
  method: 'script.evaluate',
@@ -162,7 +146,7 @@ class ScriptManager {
162
146
  expression,
163
147
  awaitPromise,
164
148
  resultOwnership = null,
165
- sandbox = null
149
+ sandbox = null,
166
150
  ) {
167
151
  const params = this.getEvaluateParams(
168
152
  'contextTarget',
@@ -170,7 +154,7 @@ class ScriptManager {
170
154
  sandbox,
171
155
  expression,
172
156
  awaitPromise,
173
- resultOwnership
157
+ resultOwnership,
174
158
  )
175
159
 
176
160
  const command = {
@@ -182,11 +166,7 @@ class ScriptManager {
182
166
  return this.createEvaluateResult(response)
183
167
  }
184
168
 
185
- async addPreloadScript(
186
- functionDeclaration,
187
- argumentValueList = [],
188
- sandbox = null
189
- ) {
169
+ async addPreloadScript(functionDeclaration, argumentValueList = [], sandbox = null) {
190
170
  const params = {
191
171
  functionDeclaration: functionDeclaration,
192
172
  arguments: argumentValueList,
@@ -223,7 +203,7 @@ class ScriptManager {
223
203
  awaitPromise,
224
204
  argumentValueList = null,
225
205
  thisParameter = null,
226
- resultOwnership = null
206
+ resultOwnership = null,
227
207
  ) {
228
208
  const params = {
229
209
  functionDeclaration: functionDeclaration,
@@ -258,14 +238,7 @@ class ScriptManager {
258
238
  return params
259
239
  }
260
240
 
261
- getEvaluateParams(
262
- targetType,
263
- id,
264
- sandbox,
265
- expression,
266
- awaitPromise,
267
- resultOwnership = null
268
- ) {
241
+ getEvaluateParams(targetType, id, sandbox, expression, awaitPromise, resultOwnership = null) {
269
242
  const params = {
270
243
  expression: expression,
271
244
  awaitPromise: awaitPromise,
@@ -293,16 +266,10 @@ class ScriptManager {
293
266
 
294
267
  if (type === EvaluateResultType.SUCCESS) {
295
268
  const result = response.result.result
296
- evaluateResult = new EvaluateResultSuccess(
297
- realmId,
298
- new RemoteValue(result)
299
- )
269
+ evaluateResult = new EvaluateResultSuccess(realmId, new RemoteValue(result))
300
270
  } else {
301
271
  const exceptionDetails = response.result.exceptionDetails
302
- evaluateResult = new EvaluateResultException(
303
- realmId,
304
- new ExceptionDetails(exceptionDetails)
305
- )
272
+ evaluateResult = new EvaluateResultException(realmId, new ExceptionDetails(exceptionDetails))
306
273
  }
307
274
  return evaluateResult
308
275
  }
@@ -359,6 +326,10 @@ class ScriptManager {
359
326
  await this.subscribeAndHandleEvent('script.realmCreated', callback)
360
327
  }
361
328
 
329
+ async onRealmDestroyed(callback) {
330
+ await this.subscribeAndHandleEvent('script.realmDestroyed', callback)
331
+ }
332
+
362
333
  async subscribeAndHandleEvent(eventType, callback) {
363
334
  if (this._browsingContextIds != null) {
364
335
  await this.bidi.subscribe(eventType, this._browsingContextIds)
@@ -375,20 +346,10 @@ class ScriptManager {
375
346
  if (params) {
376
347
  let response = null
377
348
  if ('channel' in params) {
378
- response = new Message(
379
- params.channel,
380
- new RemoteValue(params.data),
381
- new Source(params.source)
382
- )
349
+ response = new Message(params.channel, new RemoteValue(params.data), new Source(params.source))
383
350
  } else if ('realm' in params) {
384
351
  if (params.type === RealmType.WINDOW) {
385
- response = new WindowRealmInfo(
386
- params.realm,
387
- params.origin,
388
- params.type,
389
- params.context,
390
- params.sandbox
391
- )
352
+ response = new WindowRealmInfo(params.realm, params.origin, params.type, params.context, params.sandbox)
392
353
  } else if (params.realm !== null && params.type !== null) {
393
354
  response = new RealmInfo(params.realm, params.origin, params.type)
394
355
  } else if (params.realm !== null) {
@@ -0,0 +1,58 @@
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
+
20
+ class UrlPattern {
21
+ #map = new Map()
22
+
23
+ protocol(protocol) {
24
+ this.#map.set('protocol', protocol)
25
+ return this
26
+ }
27
+
28
+ hostname(hostname) {
29
+ this.#map.set('hostname', hostname)
30
+ return this
31
+ }
32
+
33
+ port(port) {
34
+ if (typeof port === 'number') {
35
+ this.#map.set('port', port.toString())
36
+ } else {
37
+ throw new Error(`Port must be a number. Received:'${port}'`)
38
+ }
39
+ return this
40
+ }
41
+
42
+ pathname(pathname) {
43
+ this.#map.set('pathname', pathname)
44
+ return this
45
+ }
46
+
47
+ search(search) {
48
+ this.#map.set('search', search)
49
+ return this
50
+ }
51
+
52
+ asMap() {
53
+ this.#map.set('type', 'pattern')
54
+ return this.#map
55
+ }
56
+ }
57
+
58
+ module.exports = {UrlPattern}
Binary file
Binary file
Binary file
package/chrome.js CHANGED
@@ -214,14 +214,7 @@ class Driver extends chromium.Driver {
214
214
  */
215
215
  static createSession(opt_config, opt_serviceExecutor) {
216
216
  let caps = opt_config || new Options()
217
- return /** @type {!Driver} */ (
218
- super.createSession(
219
- caps,
220
- opt_serviceExecutor,
221
- 'goog',
222
- CHROME_CAPABILITY_KEY
223
- )
224
- )
217
+ return /** @type {!Driver} */ (super.createSession(caps, opt_serviceExecutor, 'goog', CHROME_CAPABILITY_KEY))
225
218
  }
226
219
 
227
220
  /**
package/chromium.js CHANGED
@@ -119,71 +119,39 @@ function createExecutor(url, vendorPrefix) {
119
119
  * @param {!http.Executor} executor the executor to configure.
120
120
  */
121
121
  function configureExecutor(executor, vendorPrefix) {
122
- executor.defineCommand(
123
- Command.LAUNCH_APP,
124
- 'POST',
125
- '/session/:sessionId/chromium/launch_app'
126
- )
127
- executor.defineCommand(
128
- Command.GET_NETWORK_CONDITIONS,
129
- 'GET',
130
- '/session/:sessionId/chromium/network_conditions'
131
- )
132
- executor.defineCommand(
133
- Command.SET_NETWORK_CONDITIONS,
134
- 'POST',
135
- '/session/:sessionId/chromium/network_conditions'
136
- )
137
- executor.defineCommand(
138
- Command.DELETE_NETWORK_CONDITIONS,
139
- 'DELETE',
140
- '/session/:sessionId/chromium/network_conditions'
141
- )
142
- executor.defineCommand(
143
- Command.SEND_DEVTOOLS_COMMAND,
144
- 'POST',
145
- '/session/:sessionId/chromium/send_command'
146
- )
122
+ executor.defineCommand(Command.LAUNCH_APP, 'POST', '/session/:sessionId/chromium/launch_app')
123
+ executor.defineCommand(Command.GET_NETWORK_CONDITIONS, 'GET', '/session/:sessionId/chromium/network_conditions')
124
+ executor.defineCommand(Command.SET_NETWORK_CONDITIONS, 'POST', '/session/:sessionId/chromium/network_conditions')
125
+ executor.defineCommand(Command.DELETE_NETWORK_CONDITIONS, 'DELETE', '/session/:sessionId/chromium/network_conditions')
126
+ executor.defineCommand(Command.SEND_DEVTOOLS_COMMAND, 'POST', '/session/:sessionId/chromium/send_command')
147
127
  executor.defineCommand(
148
128
  Command.SEND_AND_GET_DEVTOOLS_COMMAND,
149
129
  'POST',
150
- '/session/:sessionId/chromium/send_command_and_get_result'
151
- )
152
- executor.defineCommand(
153
- Command.SET_PERMISSION,
154
- 'POST',
155
- '/session/:sessionId/permissions'
156
- )
157
- executor.defineCommand(
158
- Command.GET_CAST_SINKS,
159
- 'GET',
160
- `/session/:sessionId/${vendorPrefix}/cast/get_sinks`
130
+ '/session/:sessionId/chromium/send_command_and_get_result',
161
131
  )
132
+ executor.defineCommand(Command.SET_PERMISSION, 'POST', '/session/:sessionId/permissions')
133
+ executor.defineCommand(Command.GET_CAST_SINKS, 'GET', `/session/:sessionId/${vendorPrefix}/cast/get_sinks`)
162
134
  executor.defineCommand(
163
135
  Command.SET_CAST_SINK_TO_USE,
164
136
  'POST',
165
- `/session/:sessionId/${vendorPrefix}/cast/set_sink_to_use`
137
+ `/session/:sessionId/${vendorPrefix}/cast/set_sink_to_use`,
166
138
  )
167
139
  executor.defineCommand(
168
140
  Command.START_CAST_DESKTOP_MIRRORING,
169
141
  'POST',
170
- `/session/:sessionId/${vendorPrefix}/cast/start_desktop_mirroring`
142
+ `/session/:sessionId/${vendorPrefix}/cast/start_desktop_mirroring`,
171
143
  )
172
144
  executor.defineCommand(
173
145
  Command.START_CAST_TAB_MIRRORING,
174
146
  'POST',
175
- `/session/:sessionId/${vendorPrefix}/cast/start_tab_mirroring`
147
+ `/session/:sessionId/${vendorPrefix}/cast/start_tab_mirroring`,
176
148
  )
177
149
  executor.defineCommand(
178
150
  Command.GET_CAST_ISSUE_MESSAGE,
179
151
  'GET',
180
- `/session/:sessionId/${vendorPrefix}/cast/get_issue_message`
181
- )
182
- executor.defineCommand(
183
- Command.STOP_CASTING,
184
- 'POST',
185
- `/session/:sessionId/${vendorPrefix}/cast/stop_casting`
152
+ `/session/:sessionId/${vendorPrefix}/cast/get_issue_message`,
186
153
  )
154
+ executor.defineCommand(Command.STOP_CASTING, 'POST', `/session/:sessionId/${vendorPrefix}/cast/stop_casting`)
187
155
  }
188
156
 
189
157
  /**
@@ -622,9 +590,7 @@ class Extensions {
622
590
  if (Buffer.isBuffer(extension)) {
623
591
  return extension.toString('base64')
624
592
  }
625
- return io
626
- .read(/** @type {string} */ (extension))
627
- .then((buffer) => buffer.toString('base64'))
593
+ return io.read(/** @type {string} */ (extension)).then((buffer) => buffer.toString('base64'))
628
594
  })
629
595
  }
630
596
  }
@@ -646,12 +612,7 @@ class Driver extends webdriver.WebDriver {
646
612
  * @param vendorCapabilityKey Either 'goog:chromeOptions' or 'ms:edgeOptions'
647
613
  * @return {!Driver} A new driver instance.
648
614
  */
649
- static createSession(
650
- caps,
651
- opt_serviceExecutor,
652
- vendorPrefix = '',
653
- vendorCapabilityKey = ''
654
- ) {
615
+ static createSession(caps, opt_serviceExecutor, vendorPrefix = '', vendorCapabilityKey = '') {
655
616
  let executor
656
617
  let onQuit
657
618
  if (opt_serviceExecutor instanceof http.Executor) {
@@ -701,9 +662,7 @@ class Driver extends webdriver.WebDriver {
701
662
  * when app is launched.
702
663
  */
703
664
  launchApp(id) {
704
- return this.execute(
705
- new command.Command(Command.LAUNCH_APP).setParameter('id', id)
706
- )
665
+ return this.execute(new command.Command(Command.LAUNCH_APP).setParameter('id', id))
707
666
  }
708
667
 
709
668
  /**
@@ -742,16 +701,9 @@ class Driver extends webdriver.WebDriver {
742
701
  */
743
702
  setNetworkConditions(spec) {
744
703
  if (!spec || typeof spec !== 'object') {
745
- throw TypeError(
746
- 'setNetworkConditions called with non-network-conditions parameter'
747
- )
704
+ throw TypeError('setNetworkConditions called with non-network-conditions parameter')
748
705
  }
749
- return this.execute(
750
- new command.Command(Command.SET_NETWORK_CONDITIONS).setParameter(
751
- 'network_conditions',
752
- spec
753
- )
754
- )
706
+ return this.execute(new command.Command(Command.SET_NETWORK_CONDITIONS).setParameter('network_conditions', spec))
755
707
  }
756
708
 
757
709
  /**
@@ -765,9 +717,7 @@ class Driver extends webdriver.WebDriver {
765
717
  */
766
718
  sendDevToolsCommand(cmd, params = {}) {
767
719
  return this.execute(
768
- new command.Command(Command.SEND_DEVTOOLS_COMMAND)
769
- .setParameter('cmd', cmd)
770
- .setParameter('params', params)
720
+ new command.Command(Command.SEND_DEVTOOLS_COMMAND).setParameter('cmd', cmd).setParameter('params', params),
771
721
  )
772
722
  }
773
723
 
@@ -784,7 +734,7 @@ class Driver extends webdriver.WebDriver {
784
734
  return this.execute(
785
735
  new command.Command(Command.SEND_AND_GET_DEVTOOLS_COMMAND)
786
736
  .setParameter('cmd', cmd)
787
- .setParameter('params', params)
737
+ .setParameter('params', params),
788
738
  )
789
739
  }
790
740
 
@@ -800,9 +750,7 @@ class Driver extends webdriver.WebDriver {
800
750
  */
801
751
  setPermission(name, state) {
802
752
  return this.execute(
803
- new command.Command(Command.SET_PERMISSION)
804
- .setParameter('descriptor', { name })
805
- .setParameter('state', state)
753
+ new command.Command(Command.SET_PERMISSION).setParameter('descriptor', { name }).setParameter('state', state),
806
754
  )
807
755
  }
808
756
 
@@ -835,10 +783,7 @@ class Driver extends webdriver.WebDriver {
835
783
  * containing the friendly device names of available cast sink targets.
836
784
  */
837
785
  getCastSinks() {
838
- return this.schedule(
839
- new command.Command(Command.GET_CAST_SINKS),
840
- 'Driver.getCastSinks()'
841
- )
786
+ return this.execute(new command.Command(Command.GET_CAST_SINKS))
842
787
  }
843
788
 
844
789
  /**
@@ -849,13 +794,7 @@ class Driver extends webdriver.WebDriver {
849
794
  * when the target device has been selected to respond further webdriver commands.
850
795
  */
851
796
  setCastSinkToUse(deviceName) {
852
- return this.schedule(
853
- new command.Command(Command.SET_CAST_SINK_TO_USE).setParameter(
854
- 'sinkName',
855
- deviceName
856
- ),
857
- 'Driver.setCastSinkToUse(' + deviceName + ')'
858
- )
797
+ return this.execute(new command.Command(Command.SET_CAST_SINK_TO_USE).setParameter('sinkName', deviceName))
859
798
  }
860
799
 
861
800
  /**
@@ -866,13 +805,7 @@ class Driver extends webdriver.WebDriver {
866
805
  * when the mirror command has been issued to the device.
867
806
  */
868
807
  startDesktopMirroring(deviceName) {
869
- return this.schedule(
870
- new command.Command(Command.START_CAST_DESKTOP_MIRRORING).setParameter(
871
- 'sinkName',
872
- deviceName
873
- ),
874
- 'Driver.startDesktopMirroring(' + deviceName + ')'
875
- )
808
+ return this.execute(new command.Command(Command.START_CAST_DESKTOP_MIRRORING).setParameter('sinkName', deviceName))
876
809
  }
877
810
 
878
811
  /**
@@ -883,13 +816,7 @@ class Driver extends webdriver.WebDriver {
883
816
  * when the mirror command has been issued to the device.
884
817
  */
885
818
  startCastTabMirroring(deviceName) {
886
- return this.schedule(
887
- new command.Command(Command.START_CAST_TAB_MIRRORING).setParameter(
888
- 'sinkName',
889
- deviceName
890
- ),
891
- 'Driver.startCastTabMirroring(' + deviceName + ')'
892
- )
819
+ return this.execute(new command.Command(Command.START_CAST_TAB_MIRRORING).setParameter('sinkName', deviceName))
893
820
  }
894
821
 
895
822
  /**
@@ -898,10 +825,7 @@ class Driver extends webdriver.WebDriver {
898
825
  * when the mirror command has been issued to the device.
899
826
  */
900
827
  getCastIssueMessage() {
901
- return this.schedule(
902
- new command.Command(Command.GET_CAST_ISSUE_MESSAGE),
903
- 'Driver.getCastIssueMessage()'
904
- )
828
+ return this.execute(new command.Command(Command.GET_CAST_ISSUE_MESSAGE))
905
829
  }
906
830
 
907
831
  /**
@@ -912,13 +836,7 @@ class Driver extends webdriver.WebDriver {
912
836
  * when the stop command has been issued to the device.
913
837
  */
914
838
  stopCasting(deviceName) {
915
- return this.schedule(
916
- new command.Command(Command.STOP_CASTING).setParameter(
917
- 'sinkName',
918
- deviceName
919
- ),
920
- 'Driver.stopCasting(' + deviceName + ')'
921
- )
839
+ return this.execute(new command.Command(Command.STOP_CASTING).setParameter('sinkName', deviceName))
922
840
  }
923
841
  }
924
842
 
@@ -35,7 +35,7 @@ function getPath(capabilities) {
35
35
  throw Error(
36
36
  `Unable to obtain browser driver.
37
37
  For more information on how to install drivers see
38
- https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/. ${e}`
38
+ https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location/. ${e}`,
39
39
  )
40
40
  }
41
41
  }
@@ -35,7 +35,7 @@ let debugMessagePrinted = false
35
35
  * Determines the path of the correct Selenium Manager binary
36
36
  * @returns {string}
37
37
  */
38
- function getBinary () {
38
+ function getBinary() {
39
39
  const directory = {
40
40
  darwin: 'macos',
41
41
  win32: 'windows',
@@ -43,13 +43,11 @@ function getBinary () {
43
43
  linux: 'linux',
44
44
  }[platform]
45
45
 
46
- const file =
47
- directory === 'windows' ? 'selenium-manager.exe' : 'selenium-manager'
46
+ const file = directory === 'windows' ? 'selenium-manager.exe' : 'selenium-manager'
48
47
 
49
48
  let seleniumManagerBasePath = path.join(__dirname, '..', '/bin')
50
49
 
51
- const filePath = process.env.SE_MANAGER_PATH || path.join(
52
- seleniumManagerBasePath, directory, file)
50
+ const filePath = process.env.SE_MANAGER_PATH || path.join(seleniumManagerBasePath, directory, file)
53
51
 
54
52
  if (!fs.existsSync(filePath)) {
55
53
  throw new Error(`Unable to obtain Selenium Manager at ${filePath}`)
@@ -70,18 +68,15 @@ function getBinary () {
70
68
  * browser location
71
69
  */
72
70
 
73
- function driverLocation (options) {
74
- let args = ['--browser', options.getBrowserName(), '--language-binding',
75
- 'javascript', '--output', 'json']
71
+ function driverLocation(options) {
72
+ let args = ['--browser', options.getBrowserName(), '--language-binding', 'javascript', '--output', 'json']
76
73
 
77
74
  if (options.getBrowserVersion() && options.getBrowserVersion() !== '') {
78
75
  args.push('--browser-version', options.getBrowserVersion())
79
76
  }
80
77
 
81
78
  const vendorOptions =
82
- options.get('goog:chromeOptions') ||
83
- options.get('ms:edgeOptions') ||
84
- options.get('moz:firefoxOptions')
79
+ options.get('goog:chromeOptions') || options.get('ms:edgeOptions') || options.get('moz:firefoxOptions')
85
80
  if (vendorOptions && vendorOptions.binary && vendorOptions.binary !== '') {
86
81
  args.push('--browser-path', path.resolve(vendorOptions.binary))
87
82
  }
@@ -117,16 +112,12 @@ function driverLocation (options) {
117
112
  errorMessage = e.toString()
118
113
  }
119
114
  }
120
- throw new Error(
121
- `Error executing command for ${smBinary} with ${args}: ${errorMessage}`
122
- )
115
+ throw new Error(`Error executing command for ${smBinary} with ${args}: ${errorMessage}`)
123
116
  }
124
117
  try {
125
118
  output = JSON.parse(spawnResult.stdout.toString())
126
119
  } catch (e) {
127
- throw new Error(
128
- `Error executing command for ${smBinary} with ${args}: ${e.toString()}`
129
- )
120
+ throw new Error(`Error executing command for ${smBinary} with ${args}: ${e.toString()}`)
130
121
  }
131
122
 
132
123
  // Once driverPath is available, delete browserVersion from payload
@@ -141,7 +132,7 @@ function driverLocation (options) {
141
132
  }
142
133
  }
143
134
 
144
- function logOutput (output) {
135
+ function logOutput(output) {
145
136
  for (const key in output.logs) {
146
137
  if (output.logs[key].level === 'WARN') {
147
138
  log_.warning(`${output.logs[key].message}`)
@@ -67,9 +67,7 @@ class CDPConnection {
67
67
  resolve(payload)
68
68
  }
69
69
  } catch (err) {
70
- logging
71
- .getLogger(logging.Type.BROWSER)
72
- .severe(`Failed parse message: ${err.message}`)
70
+ logging.getLogger(logging.Type.BROWSER).severe(`Failed parse message: ${err.message}`)
73
71
  }
74
72
  }
75
73
 
package/edge.js CHANGED
@@ -147,9 +147,7 @@ class Driver extends chromium.Driver {
147
147
  */
148
148
  static createSession(opt_config, opt_serviceExecutor) {
149
149
  let caps = opt_config || new Options()
150
- return /** @type {!Driver} */ (
151
- super.createSession(caps, opt_serviceExecutor, 'ms', EDGE_CAPABILITY_KEY)
152
- )
150
+ return /** @type {!Driver} */ (super.createSession(caps, opt_serviceExecutor, 'ms', EDGE_CAPABILITY_KEY))
153
151
  }
154
152
 
155
153
  /**
@@ -29,10 +29,7 @@ const { Options } = require('../chrome')
29
29
  ;(async function () {
30
30
  let driver
31
31
  try {
32
- driver = await new Builder()
33
- .forBrowser('chrome')
34
- .setChromeOptions(new Options().androidChrome())
35
- .build()
32
+ driver = await new Builder().forBrowser('chrome').setChromeOptions(new Options().androidChrome()).build()
36
33
  await driver.get('http://www.google.com/ncr')
37
34
  await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
38
35
  await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
@@ -41,5 +38,5 @@ const { Options } = require('../chrome')
41
38
  }
42
39
  })().then(
43
40
  (_) => console.log('SUCCESS'),
44
- (err) => console.error('ERROR: ' + err)
41
+ (err) => console.error('ERROR: ' + err),
45
42
  )
@@ -30,9 +30,7 @@ const { Options } = require('../chrome')
30
30
  try {
31
31
  driver = await new Builder()
32
32
  .forBrowser('chrome')
33
- .setChromeOptions(
34
- new Options().setMobileEmulation({ deviceName: 'Nexus 5X' })
35
- )
33
+ .setChromeOptions(new Options().setMobileEmulation({ deviceName: 'Nexus 5X' }))
36
34
  .build()
37
35
  await driver.get('http://www.google.com/ncr')
38
36
  await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
@@ -42,5 +40,5 @@ const { Options } = require('../chrome')
42
40
  }
43
41
  })().then(
44
42
  (_) => console.log('SUCCESS'),
45
- (err) => console.error('ERROR: ' + err)
43
+ (err) => console.error('ERROR: ' + err),
46
44
  )
@@ -43,8 +43,6 @@ const driver = new Builder().forBrowser('firefox').build()
43
43
 
44
44
  driver
45
45
  .get('http://www.google.com/ncr')
46
- .then((_) =>
47
- driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
48
- )
46
+ .then((_) => driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
49
47
  .then((_) => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
50
48
  .then((_) => driver.quit())