selenium-webdriver 4.9.2 → 4.10.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 +13 -0
- package/bidi/browsingContext.js +46 -0
- package/bidi/scriptManager.js +34 -0
- package/bin/linux/selenium-manager +0 -0
- package/bin/macos/selenium-manager +0 -0
- package/bin/windows/selenium-manager.exe +0 -0
- package/common/driverFinder.js +3 -3
- package/common/seleniumManager.js +35 -15
- package/edge.js +13 -0
- package/io/exec.js +2 -2
- package/lib/atoms/find-elements.js +3 -4
- package/package.json +4 -4
package/CHANGES.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## v4.10.0
|
|
2
|
+
|
|
3
|
+
#### :nail_care: Polish
|
|
4
|
+
|
|
5
|
+
* Adding CDP v114 and removing v111
|
|
6
|
+
|
|
7
|
+
#### :rocket: New Feature
|
|
8
|
+
|
|
9
|
+
* [Edge] Support webview2 (#11978)
|
|
10
|
+
* [BiDi] Add Script module commands to add/remove preloaded scripts (#11847)
|
|
11
|
+
* [BiDi] Add printPage command (#12124)
|
|
12
|
+
* Add support for proxies with Selenium Manager
|
|
13
|
+
|
|
1
14
|
## v4.9.2
|
|
2
15
|
|
|
3
16
|
#### :nail_care: Polish
|
package/bidi/browsingContext.js
CHANGED
|
@@ -129,6 +129,42 @@ class BrowsingContext {
|
|
|
129
129
|
}
|
|
130
130
|
await this.bidi.send(params)
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Prints PDF of the webpage
|
|
135
|
+
* @param options print options given by the user
|
|
136
|
+
* @returns PrintResult object
|
|
137
|
+
*/
|
|
138
|
+
async printPage(options = {}) {
|
|
139
|
+
let params = {
|
|
140
|
+
method: 'browsingContext.print',
|
|
141
|
+
// Setting default values for parameters
|
|
142
|
+
params: {
|
|
143
|
+
context: this._id,
|
|
144
|
+
background: false,
|
|
145
|
+
margin: {
|
|
146
|
+
bottom: 1.0,
|
|
147
|
+
left: 1.0,
|
|
148
|
+
right: 1.0,
|
|
149
|
+
top: 1.0,
|
|
150
|
+
},
|
|
151
|
+
orientation: 'portrait',
|
|
152
|
+
page: {
|
|
153
|
+
height: 27.94,
|
|
154
|
+
width: 21.59,
|
|
155
|
+
},
|
|
156
|
+
pageRanges: [],
|
|
157
|
+
scale: 1.0,
|
|
158
|
+
shrinkToFit: true,
|
|
159
|
+
},
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Updating parameter values based on the options passed
|
|
163
|
+
params.params = this._driver.validatePrintPageParams(options, params.params)
|
|
164
|
+
|
|
165
|
+
const response = await this.bidi.send(params)
|
|
166
|
+
return new PrintResult(response.result.data)
|
|
167
|
+
}
|
|
132
168
|
}
|
|
133
169
|
|
|
134
170
|
class NavigateResult {
|
|
@@ -146,6 +182,16 @@ class NavigateResult {
|
|
|
146
182
|
}
|
|
147
183
|
}
|
|
148
184
|
|
|
185
|
+
class PrintResult {
|
|
186
|
+
constructor(data) {
|
|
187
|
+
this._data = data
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
get data() {
|
|
191
|
+
return this._data
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
149
195
|
/**
|
|
150
196
|
* initiate browsing context instance and return
|
|
151
197
|
* @param driver
|
package/bidi/scriptManager.js
CHANGED
|
@@ -23,6 +23,7 @@ const {
|
|
|
23
23
|
} = require('./evaluateResult')
|
|
24
24
|
const { RealmInfo } = require('./realmInfo')
|
|
25
25
|
const { RemoteValue } = require('./protocolValue')
|
|
26
|
+
const { WebDriverError } = require('../lib/error')
|
|
26
27
|
|
|
27
28
|
class ScriptManager {
|
|
28
29
|
constructor(driver) {
|
|
@@ -179,6 +180,39 @@ class ScriptManager {
|
|
|
179
180
|
return this.createEvaluateResult(response)
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
async addPreloadScript(
|
|
184
|
+
functionDeclaration,
|
|
185
|
+
argumentValueList = null,
|
|
186
|
+
sandbox = null
|
|
187
|
+
) {
|
|
188
|
+
const params = {
|
|
189
|
+
functionDeclaration: functionDeclaration,
|
|
190
|
+
arguments: argumentValueList,
|
|
191
|
+
sandbox: sandbox,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const command = {
|
|
195
|
+
method: 'script.addPreloadScript',
|
|
196
|
+
params,
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let response = await this.bidi.send(command)
|
|
200
|
+
return response.result.script
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async removePreloadScript(script) {
|
|
204
|
+
const params = { script: script }
|
|
205
|
+
const command = {
|
|
206
|
+
method: 'script.removePreloadScript',
|
|
207
|
+
params,
|
|
208
|
+
}
|
|
209
|
+
let response = await this.bidi.send(command)
|
|
210
|
+
if ('error' in response) {
|
|
211
|
+
throw new WebDriverError(response.error)
|
|
212
|
+
}
|
|
213
|
+
return response.result
|
|
214
|
+
}
|
|
215
|
+
|
|
182
216
|
getCallFunctionParams(
|
|
183
217
|
targetType,
|
|
184
218
|
id,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/common/driverFinder.js
CHANGED
|
@@ -32,11 +32,11 @@ function getPath(service, capabilities) {
|
|
|
32
32
|
try {
|
|
33
33
|
return pathExists(service.getExecutable()) || driverLocation(capabilities)
|
|
34
34
|
} catch (e) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
throw Error(
|
|
36
|
+
`Unable to obtain browser driver.
|
|
37
37
|
For more information on how to install drivers see
|
|
38
38
|
https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/. ${e}`
|
|
39
|
-
|
|
39
|
+
)
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -47,12 +47,7 @@ function getBinary() {
|
|
|
47
47
|
const file =
|
|
48
48
|
directory === 'windows' ? 'selenium-manager.exe' : 'selenium-manager'
|
|
49
49
|
|
|
50
|
-
let seleniumManagerBasePath
|
|
51
|
-
if (process.env.SELENIUM_MANAGER_BASE_PATH) {
|
|
52
|
-
seleniumManagerBasePath = process.env.SELENIUM_MANAGER_BASE_PATH
|
|
53
|
-
} else {
|
|
54
|
-
seleniumManagerBasePath = path.join(__dirname, '..', '/bin')
|
|
55
|
-
}
|
|
50
|
+
let seleniumManagerBasePath = path.join(__dirname, '..', '/bin')
|
|
56
51
|
|
|
57
52
|
const filePath = path.join(seleniumManagerBasePath, directory, file)
|
|
58
53
|
|
|
@@ -76,16 +71,38 @@ function driverLocation(options) {
|
|
|
76
71
|
)
|
|
77
72
|
}
|
|
78
73
|
|
|
74
|
+
console.debug(
|
|
75
|
+
'Applicable driver not found; attempting to install with Selenium Manager (Beta)'
|
|
76
|
+
)
|
|
77
|
+
|
|
79
78
|
let args = ['--browser', options.getBrowserName(), '--output', 'json']
|
|
80
79
|
|
|
81
|
-
if (options.getBrowserVersion() && options.getBrowserVersion() !==
|
|
82
|
-
args.push(
|
|
80
|
+
if (options.getBrowserVersion() && options.getBrowserVersion() !== '') {
|
|
81
|
+
args.push('--browser-version', options.getBrowserVersion())
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const vendorOptions =
|
|
85
|
+
options.get('goog:chromeOptions') ||
|
|
86
|
+
options.get('ms:edgeOptions') ||
|
|
87
|
+
options.get('moz:firefoxOptions')
|
|
88
|
+
if (vendorOptions && vendorOptions.binary && vendorOptions.binary !== '') {
|
|
89
|
+
args.push('--browser-path', '"' + vendorOptions.binary + '"')
|
|
83
90
|
}
|
|
84
91
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
92
|
+
const proxyOptions = options.getProxy();
|
|
93
|
+
|
|
94
|
+
// Check if proxyOptions exists and has properties
|
|
95
|
+
if (proxyOptions && Object.keys(proxyOptions).length > 0) {
|
|
96
|
+
const httpProxy = proxyOptions['httpProxy'];
|
|
97
|
+
const sslProxy = proxyOptions['sslProxy'];
|
|
98
|
+
|
|
99
|
+
if (httpProxy !== undefined) {
|
|
100
|
+
args.push('--proxy', httpProxy);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
else if (sslProxy !== undefined) {
|
|
104
|
+
args.push('--proxy', sslProxy);
|
|
105
|
+
}
|
|
89
106
|
}
|
|
90
107
|
|
|
91
108
|
const smBinary = getBinary()
|
|
@@ -104,15 +121,18 @@ function driverLocation(options) {
|
|
|
104
121
|
errorMessage = e.toString()
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
|
-
throw new Error(
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Error executing command for ${smBinary} with ${args}: ${errorMessage}`
|
|
126
|
+
)
|
|
108
127
|
}
|
|
109
128
|
try {
|
|
110
129
|
output = JSON.parse(spawnResult.stdout.toString())
|
|
111
130
|
} catch (e) {
|
|
112
|
-
throw new Error(
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Error executing command for ${smBinary} with ${args}: ${e.toString()}`
|
|
133
|
+
)
|
|
113
134
|
}
|
|
114
135
|
|
|
115
|
-
|
|
116
136
|
for (const key in output.logs) {
|
|
117
137
|
if (output.logs[key].level === 'WARN') {
|
|
118
138
|
console.warn(`${output.logs[key].message}`)
|
package/edge.js
CHANGED
|
@@ -127,6 +127,19 @@ class Options extends chromium.Options {
|
|
|
127
127
|
setEdgeChromiumBinaryPath(path) {
|
|
128
128
|
return this.setBinaryPath(path)
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Changes the browser name to 'webview2' to enable
|
|
133
|
+
* <a href="https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver">
|
|
134
|
+
* test automation of WebView2 apps with Microsoft Edge WebDriver
|
|
135
|
+
* </a>
|
|
136
|
+
*
|
|
137
|
+
* @param {boolean} enable flag to enable or disable the 'webview2' usage
|
|
138
|
+
*/
|
|
139
|
+
useWebView(enable) {
|
|
140
|
+
const browserName = enable ? 'webview2' : Browser.EDGE
|
|
141
|
+
return this.setBrowserName(browserName)
|
|
142
|
+
}
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
/**
|
package/io/exec.js
CHANGED
|
@@ -114,10 +114,9 @@ function nd(a,b,c,d){a=a.nodeValue.replace(/[\u200b\u200e\u200f]/g,"");a=a.repla
|
|
|
114
114
|
function pd(a,b,c,d,e){if(3==a.nodeType&&c)nd(a,b,d,e);else if(S(a))if(S(a,"CONTENT")||S(a,"SLOT")){for(var f=a;f.parentNode;)f=f.parentNode;f instanceof ShadowRoot?(a=S(a,"CONTENT")?a.getDistributedNodes():a.assignedNodes(),l(a,function(g){pd(g,b,c,d,e)})):jd(a,b)}else if(S(a,"SHADOW")){for(f=a;f.parentNode;)f=f.parentNode;if(f instanceof ShadowRoot&&(a=f))for(a=a.olderShadowRoot;a;)l(a.childNodes,function(g){pd(g,b,c,d,e)}),a=a.olderShadowRoot}else jd(a,b)}
|
|
115
115
|
function jd(a,b){a.shadowRoot&&l(a.shadowRoot.childNodes,function(c){pd(c,b,!0,null,null)});ld(a,b,function(c,d,e,f,g){var h=null;1==c.nodeType?h=c:3==c.nodeType&&(h=c);null!=h&&(null!=h.assignedSlot||h.getDestinationInsertionPoints&&0<h.getDestinationInsertionPoints().length)||pd(c,d,e,f,g)})};var qd={C:function(a,b){return!(!a.querySelectorAll||!a.querySelector)&&!/^\d.*/.test(b)},o:function(a,b){var c=eb(b),d="string"===typeof a?c.a.getElementById(a):a;return d?Uc(d,"id")==a&&b!=d&&hb(b,d)?d:ua(mb(c,"*"),function(e){return Uc(e,"id")==a&&b!=e&&hb(b,e)}):null},j:function(a,b){if(!a)return[];if(qd.C(b,a))try{return b.querySelectorAll("#"+qd.T(a))}catch(c){return[]}b=mb(eb(b),"*",null,b);return pa(b,function(c){return Uc(c,"id")==a})},T:function(a){return a.replace(/([\s'"\\#.:;,!?+<>=~*^$|%&@`{}\-\/\[\]\(\)])/g,
|
|
116
116
|
"\\$1")}};var Y={},rd={};Y.N=function(a,b,c){try{var d=Nc.j("a",b)}catch(e){d=mb(eb(b),"A",null,b)}return ua(d,function(e){e=id(e);e=e.replace(/^[\s]+|[\s]+$/g,"");return c&&-1!=e.indexOf(a)||e==a})};Y.K=function(a,b,c){try{var d=Nc.j("a",b)}catch(e){d=mb(eb(b),"A",null,b)}return pa(d,function(e){e=id(e);e=e.replace(/^[\s]+|[\s]+$/g,"");return c&&-1!=e.indexOf(a)||e==a})};Y.o=function(a,b){return Y.N(a,b,!1)};Y.j=function(a,b){return Y.K(a,b,!1)};rd.o=function(a,b){return Y.N(a,b,!0)};
|
|
117
|
-
rd.j=function(a,b){return Y.K(a,b,!0)};var Z={F:function(a,b){return function(c){var d=Z.u(a);d=W(d);c=W(c);return b.call(null,d,c)}},R:function(a){return Z.F(a,function(b,c){return c.b+c.height<b.b})},S:function(a){return Z.F(a,function(b,c){return b.b+b.height<c.b})},V:function(a){return Z.F(a,function(b,c){return c.a+c.width<b.a})},aa:function(a){return Z.F(a,function(b,c){return b.a+b.width<c.a})},W:function(a,b){var c;b?c=b:"number"==typeof a.distance&&(c=a.distance);c||(c=
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Z.U=function(a,b){var c=[];l(a,function(e){e&&ta(b,function(f){var g=f.kind,h=Z.P[g];if(!h)throw new P(61,"Cannot find filter suitable for "+g);return h.apply(null,f.args)(e)},null)&&c.push(e)},null);a=b[b.length-1];var d=Z.O[a?a.kind:"unknown"];return d?(a=d.apply(null,a.args))?Z.ba(a,c):c:c};
|
|
117
|
+
rd.j=function(a,b){return Y.K(a,b,!0)};var Z={F:function(a,b){return function(c){var d=Z.u(a);d=W(d);c=W(c);return b.call(null,d,c)}},R:function(a){return Z.F(a,function(b,c){return c.b+c.height<b.b})},S:function(a){return Z.F(a,function(b,c){return b.b+b.height<c.b})},V:function(a){return Z.F(a,function(b,c){return c.a+c.width<b.a})},aa:function(a){return Z.F(a,function(b,c){return b.a+b.width<c.a})},W:function(a,b){var c;b?c=b:"number"==typeof a.distance&&(c=a.distance);c||(c=50);return function(d){var e=Z.u(a);if(e===d)return!1;e=W(e);
|
|
118
|
+
d=W(d);e=new U(e.a-c,e.b-c,e.width+2*c,e.height+2*c);return e.a<=d.a+d.width&&d.a<=e.a+e.width&&e.b<=d.b+d.height&&d.b<=e.b+e.height}},u:function(a){if(ha(a)&&1==a.nodeType)return a;if(ea(a))return Z.u(a.call(null));if(ha(a)){var b;a:{if(b=sd(a)){var c=td[b];if(c&&ea(c.o)){b=c.o(a[b],Bc.document);break a}}throw new P(61,"Unsupported locator strategy: "+b);}if(!b)throw new P(7,"No element has been found by "+JSON.stringify(a));return b}throw new P(61,"Selector is of wrong type: "+JSON.stringify(a));
|
|
119
|
+
}};Z.P={left:Z.V,right:Z.aa,above:Z.R,below:Z.S,near:Z.W};Z.O={left:Z.u,right:Z.u,above:Z.u,below:Z.u,near:Z.u};Z.U=function(a,b){var c=[];l(a,function(e){e&&ta(b,function(f){var g=f.kind,h=Z.P[g];if(!h)throw new P(61,"Cannot find filter suitable for "+g);return h.apply(null,f.args)(e)},null)&&c.push(e)},null);a=b[b.length-1];var d=Z.O[a?a.kind:"unknown"];return d?(a=d.apply(null,a.args))?Z.ba(a,c):c:c};
|
|
121
120
|
Z.ba=function(a,b){function c(f){f=W(f);return Math.sqrt(Math.pow(d-(f.a+Math.max(1,f.width)/2),2)+Math.pow(e-(f.b+Math.max(1,f.height)/2),2))}a=W(a);var d=a.a+Math.max(1,a.width)/2,e=a.b+Math.max(1,a.height)/2;xa(b,function(f,g){return c(f)-c(g)});return b};Z.o=function(a,b){a=Z.j(a,b);return 0==a.length?null:a[0]};
|
|
122
121
|
Z.j=function(a,b){if(!a.hasOwnProperty("root")||!a.hasOwnProperty("filters"))throw new P(61,"Locator not suitable for relative locators: "+JSON.stringify(a));var c=a.filters,d=da(c);if("array"!=d&&("object"!=d||"number"!=typeof c.length))throw new P(61,"Targets should be an array: "+JSON.stringify(a));var e;S(a.root)?e=[a.root]:e=ud(a.root,b);return 0==e.length?[]:Z.U(e,a.filters)};var vd={o:function(a,b){if(""===a)throw new P(32,'Unable to locate an element with the tagName ""');return b.getElementsByTagName(a)[0]||null},j:function(a,b){if(""===a)throw new P(32,'Unable to locate an element with the tagName ""');return b.getElementsByTagName(a)}};var td={className:Dc,"class name":Dc,css:Nc,"css selector":Nc,relative:Z,id:qd,linkText:Y,"link text":Y,name:{o:function(a,b){b=mb(eb(b),"*",null,b);return ua(b,function(c){return Uc(c,"name")==a})},j:function(a,b){b=mb(eb(b),"*",null,b);return pa(b,function(c){return Uc(c,"name")==a})}},partialLinkText:rd,"partial link text":rd,tagName:vd,"tag name":vd,xpath:T};function sd(a){for(var b in a)if(a.hasOwnProperty(b))return b;return null}
|
|
123
122
|
function ud(a,b){var c=sd(a);if(c){var d=td[c];if(d&&ea(d.j))return d.j(a[c],b||Bc.document)}throw new P(61,"Unsupported locator strategy: "+c);};ca("_",ud);; return this._.apply(null,arguments);}).apply({navigator:typeof window!='undefined'?window.navigator:null,document:typeof window!='undefined'?window.document:null}, arguments);};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "selenium-webdriver",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "The official WebDriver JavaScript bindings from the Selenium project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"ws": ">=8.13.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"eslint": "^8.
|
|
31
|
+
"eslint": "^8.41.0",
|
|
32
32
|
"eslint-config-prettier": "^8.8.0",
|
|
33
33
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
34
34
|
"eslint-plugin-node": "^11.1.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"express": "^4.18.2",
|
|
37
37
|
"mocha": "^10.2.0",
|
|
38
38
|
"multer": "^1.4.5-lts.1",
|
|
39
|
-
"prettier": "^2.8.
|
|
39
|
+
"prettier": "^2.8.8",
|
|
40
40
|
"serve-index": "^1.9.1",
|
|
41
|
-
"sinon": "^15.0
|
|
41
|
+
"sinon": "^15.1.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"lint": "eslint --ignore-pattern node_modules --ignore-pattern generator --ext js lib/http.js \"**/*.js\"",
|