selenium-webdriver 4.0.0-rc-2 → 4.0.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,10 @@
1
+ ## v4.0.0
2
+
3
+ * Fixes cdp for Chrome and Firefox (#9909)
4
+ * Add cdp 95 to python and JS
5
+ * Removing unused target for cdpConnection
6
+
7
+
1
8
  ## v4.0.0-rc-2
2
9
 
3
10
  * Fix builder test
package/firefox.js CHANGED
@@ -411,6 +411,13 @@ class Options extends Capabilities {
411
411
  }
412
412
  return this
413
413
  }
414
+
415
+ /**
416
+ * Enables moz:debuggerAddress for firefox cdp
417
+ */
418
+ enableDebugger() {
419
+ return this.set('moz:debuggerAddress', true)
420
+ }
414
421
  }
415
422
 
416
423
  /**
package/lib/webdriver.js CHANGED
@@ -29,7 +29,6 @@ const input = require('./input')
29
29
  const logging = require('./logging')
30
30
  const promise = require('./promise')
31
31
  const Symbols = require('./symbols')
32
- const cdpTargets = ['page', 'browser']
33
32
  const cdp = require('../devtools/CDPConnection')
34
33
  const WebSocket = require('ws')
35
34
  const http = require('../http/index')
@@ -37,6 +36,7 @@ const fs = require('fs')
37
36
  const { Capabilities } = require('./capabilities')
38
37
  const path = require('path')
39
38
  const { NoSuchElementError } = require('./error')
39
+ const cdpTargets = ['page', 'browser']
40
40
 
41
41
  // Capability names that are defined in the W3C spec.
42
42
  const W3C_CAPABILITY_NAMES = new Set([
@@ -1199,8 +1199,7 @@ class WebDriver {
1199
1199
  caps['map_'].get('moz:debuggerAddress') ||
1200
1200
  new Map()
1201
1201
  const debuggerUrl = seCdp || vendorInfo['debuggerAddress'] || vendorInfo
1202
- this._wsUrl = await this.getWsUrl(debuggerUrl, target)
1203
-
1202
+ this._wsUrl = await this.getWsUrl(debuggerUrl, target, caps)
1204
1203
  return new Promise((resolve, reject) => {
1205
1204
  try {
1206
1205
  this._wsConnection = new WebSocket(this._wsUrl)
@@ -1223,32 +1222,38 @@ class WebDriver {
1223
1222
  /**
1224
1223
  * Retrieves 'webSocketDebuggerUrl' by sending a http request using debugger address
1225
1224
  * @param {string} debuggerAddress
1226
- * @param {string} target
1225
+ * @param target
1226
+ * @param caps
1227
1227
  * @return {string} Returns parsed webSocketDebuggerUrl obtained from the http request
1228
1228
  */
1229
- async getWsUrl(debuggerAddress, target) {
1229
+ async getWsUrl(debuggerAddress, target, caps) {
1230
1230
  if (target && cdpTargets.indexOf(target.toLowerCase()) === -1) {
1231
1231
  throw new error.InvalidArgumentError('invalid target value')
1232
1232
  }
1233
1233
 
1234
1234
  if (debuggerAddress.match(/\/se\/cdp/)) {
1235
- if (debuggerAddress.match("ws:\/\/", "http:\/\/")) {
1236
- return debuggerAddress.replace("ws:\/\/", "http:\/\/")
1237
- }
1238
- else if (debuggerAddress.match("wss:\/\/", "https:\/\/")) {
1239
- return debuggerAddress.replace("wss:\/\/", "https:\/\/")
1240
- }
1241
- else {
1242
- return debuggerAddress
1243
- }
1235
+ return debuggerAddress;
1236
+ }
1237
+
1238
+ let path
1239
+ if (target === 'page' && caps['map_'].get('browserName')!=='firefox' ){
1240
+ path = '/json'
1241
+ } else if(target === 'page' && caps['map_'].get('browserName')==='firefox'){
1242
+ path = '/json/list'
1243
+ }
1244
+ else {
1245
+ path = '/json/version'
1244
1246
  }
1245
1247
 
1246
- const path = '/json/version'
1247
1248
  let request = new http.Request('GET', path)
1248
1249
  let client = new http.HttpClient('http://' + debuggerAddress)
1249
1250
  let response = await client.send(request)
1250
1251
 
1251
- return JSON.parse(response.body)['webSocketDebuggerUrl']
1252
+ if (target.toLowerCase() === 'page') {
1253
+ return JSON.parse(response.body)[0]['webSocketDebuggerUrl']
1254
+ } else {
1255
+ return JSON.parse(response.body)['webSocketDebuggerUrl']
1256
+ }
1252
1257
  }
1253
1258
 
1254
1259
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selenium-webdriver",
3
- "version": "4.0.0-rc-2",
3
+ "version": "4.0.0",
4
4
  "description": "The official WebDriver JavaScript bindings from the Selenium project",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [