Socket
Socket
Sign inDemoInstall

selenium-webdriver

Package Overview
Dependencies
Maintainers
8
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

selenium-webdriver - npm Package Compare versions

Comparing version 4.9.2 to 4.10.0

46

bidi/browsingContext.js

@@ -132,2 +132,38 @@ // Licensed to the Software Freedom Conservancy (SFC) under one

}
/**
* Prints PDF of the webpage
* @param options print options given by the user
* @returns PrintResult object
*/
async printPage(options = {}) {
let params = {
method: 'browsingContext.print',
// Setting default values for parameters
params: {
context: this._id,
background: false,
margin: {
bottom: 1.0,
left: 1.0,
right: 1.0,
top: 1.0,
},
orientation: 'portrait',
page: {
height: 27.94,
width: 21.59,
},
pageRanges: [],
scale: 1.0,
shrinkToFit: true,
},
}
// Updating parameter values based on the options passed
params.params = this._driver.validatePrintPageParams(options, params.params)
const response = await this.bidi.send(params)
return new PrintResult(response.result.data)
}
}

@@ -150,2 +186,12 @@

class PrintResult {
constructor(data) {
this._data = data
}
get data() {
return this._data
}
}
/**

@@ -152,0 +198,0 @@ * initiate browsing context instance and return

@@ -26,2 +26,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one

const { RemoteValue } = require('./protocolValue')
const { WebDriverError } = require('../lib/error')

@@ -183,2 +184,35 @@ class ScriptManager {

async addPreloadScript(
functionDeclaration,
argumentValueList = null,
sandbox = null
) {
const params = {
functionDeclaration: functionDeclaration,
arguments: argumentValueList,
sandbox: sandbox,
}
const command = {
method: 'script.addPreloadScript',
params,
}
let response = await this.bidi.send(command)
return response.result.script
}
async removePreloadScript(script) {
const params = { script: script }
const command = {
method: 'script.removePreloadScript',
params,
}
let response = await this.bidi.send(command)
if ('error' in response) {
throw new WebDriverError(response.error)
}
return response.result
}
getCallFunctionParams(

@@ -185,0 +219,0 @@ targetType,

@@ -0,1 +1,14 @@

## v4.10.0
#### :nail_care: Polish
* Adding CDP v114 and removing v111
#### :rocket: New Feature
* [Edge] Support webview2 (#11978)
* [BiDi] Add Script module commands to add/remove preloaded scripts (#11847)
* [BiDi] Add printPage command (#12124)
* Add support for proxies with Selenium Manager
## v4.9.2

@@ -2,0 +15,0 @@

6

common/driverFinder.js

@@ -35,7 +35,7 @@ // Licensed to the Software Freedom Conservancy (SFC) under one

} catch (e) {
throw Error(
`Unable to obtain browser driver.
throw Error(
`Unable to obtain browser driver.
For more information on how to install drivers see
https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/. ${e}`
)
)
}

@@ -42,0 +42,0 @@ }

@@ -50,8 +50,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one

let seleniumManagerBasePath
if (process.env.SELENIUM_MANAGER_BASE_PATH) {
seleniumManagerBasePath = process.env.SELENIUM_MANAGER_BASE_PATH
} else {
seleniumManagerBasePath = path.join(__dirname, '..', '/bin')
}
let seleniumManagerBasePath = path.join(__dirname, '..', '/bin')

@@ -80,14 +75,36 @@ const filePath = path.join(seleniumManagerBasePath, directory, file)

console.debug(
'Applicable driver not found; attempting to install with Selenium Manager (Beta)'
)
let args = ['--browser', options.getBrowserName(), '--output', 'json']
if (options.getBrowserVersion() && options.getBrowserVersion() !== "") {
args.push("--browser-version", options.getBrowserVersion())
if (options.getBrowserVersion() && options.getBrowserVersion() !== '') {
args.push('--browser-version', options.getBrowserVersion())
}
const vendorOptions = options.get('goog:chromeOptions') || options.get('ms:edgeOptions')
|| options.get('moz:firefoxOptions')
if (vendorOptions && vendorOptions.binary && vendorOptions.binary !== "") {
args.push("--browser-path", '"' + vendorOptions.binary + '"')
const vendorOptions =
options.get('goog:chromeOptions') ||
options.get('ms:edgeOptions') ||
options.get('moz:firefoxOptions')
if (vendorOptions && vendorOptions.binary && vendorOptions.binary !== '') {
args.push('--browser-path', '"' + vendorOptions.binary + '"')
}
const proxyOptions = options.getProxy();
// Check if proxyOptions exists and has properties
if (proxyOptions && Object.keys(proxyOptions).length > 0) {
const httpProxy = proxyOptions['httpProxy'];
const sslProxy = proxyOptions['sslProxy'];
if (httpProxy !== undefined) {
args.push('--proxy', httpProxy);
}
else if (sslProxy !== undefined) {
args.push('--proxy', sslProxy);
}
}
const smBinary = getBinary()

@@ -109,3 +126,5 @@ const spawnResult = spawnSync(smBinary, args)

}
throw new Error(`Error executing command for ${smBinary} with ${args}: ${errorMessage}`)
throw new Error(
`Error executing command for ${smBinary} with ${args}: ${errorMessage}`
)
}

@@ -115,6 +134,7 @@ try {

} catch (e) {
throw new Error(`Error executing command for ${smBinary} with ${args}: ${e.toString()}`)
throw new Error(
`Error executing command for ${smBinary} with ${args}: ${e.toString()}`
)
}
for (const key in output.logs) {

@@ -121,0 +141,0 @@ if (output.logs[key].level === 'WARN') {

@@ -130,2 +130,15 @@ // Licensed to the Software Freedom Conservancy (SFC) under one

}
/**
* Changes the browser name to 'webview2' to enable
* <a href="https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/webdriver">
* test automation of WebView2 apps with Microsoft Edge WebDriver
* </a>
*
* @param {boolean} enable flag to enable or disable the 'webview2' usage
*/
useWebView(enable) {
const browserName = enable ? 'webview2' : Browser.EDGE
return this.setBrowserName(browserName)
}
}

@@ -132,0 +145,0 @@

@@ -144,4 +144,4 @@ // Licensed to the Software Freedom Conservancy (SFC) under one

proc.once('error', err => {
reject(err);
proc.once('error', (err) => {
reject(err)
})

@@ -148,0 +148,0 @@ })

@@ -117,8 +117,7 @@ // GENERATED CODE - DO NOT EDIT

"\\$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)};
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=100);return function(d){var e=Z.u(a);if(e===d)return!1;e=
W(e);d=W(d);var f=Math.abs(e.a+e.width-d.a),g=Math.abs(e.b+e.height-d.b);g=Math.abs(e.b-(d.b+d.height))<=c||g<=c;return(Math.abs(e.a-(d.a+d.width))<=c||f<=c)&&g?!0:Math.sqrt(Math.pow(Math.abs(e.a+e.width/2-(d.a+d.width/2)),2)+Math.pow(Math.abs(e.b+e.height/2-(d.b+d.height/2)),2))<=c}},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));}};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};
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);
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));
}};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};
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]};
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}
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);};
{
"name": "selenium-webdriver",
"version": "4.9.2",
"version": "4.10.0",
"description": "The official WebDriver JavaScript bindings from the Selenium project",

@@ -31,3 +31,3 @@ "license": "Apache-2.0",

"devDependencies": {
"eslint": "^8.37.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",

@@ -40,5 +40,5 @@ "eslint-plugin-no-only-tests": "^3.1.0",

"multer": "^1.4.5-lts.1",
"prettier": "^2.8.7",
"prettier": "^2.8.8",
"serve-index": "^1.9.1",
"sinon": "^15.0.3"
"sinon": "^15.1.0"
},

@@ -45,0 +45,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc