selenium-webdriver
Advanced tools
Comparing version 4.14.0 to 4.15.0
@@ -18,2 +18,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
const { InvalidArgumentError, NoSuchFrameError } = require('../lib/error') | ||
const { BrowsingContextInfo } = require('./browsingContextTypes') | ||
@@ -169,2 +170,145 @@ class BrowsingContext { | ||
} | ||
async captureScreenshot() { | ||
let params = { | ||
method: 'browsingContext.captureScreenshot', | ||
params: { | ||
context: this._id, | ||
}, | ||
} | ||
const response = await this.bidi.send(params) | ||
this.checkErrorInScreenshot(response) | ||
return response['result']['data'] | ||
} | ||
async captureBoxScreenshot(x, y, width, height) { | ||
let params = { | ||
method: 'browsingContext.captureScreenshot', | ||
params: { | ||
context: this._id, | ||
clip: { | ||
type: 'viewport', | ||
x: x, | ||
y: y, | ||
width: width, | ||
height: height, | ||
}, | ||
}, | ||
} | ||
const response = await this.bidi.send(params) | ||
this.checkErrorInScreenshot(response) | ||
return response['result']['data'] | ||
} | ||
async captureElementScreenshot( | ||
sharedId, | ||
handle = undefined, | ||
scrollIntoView = undefined | ||
) { | ||
let params = { | ||
method: 'browsingContext.captureScreenshot', | ||
params: { | ||
context: this._id, | ||
clip: { | ||
type: 'element', | ||
element: { | ||
sharedId: sharedId, | ||
handle: handle, | ||
}, | ||
scrollIntoView: scrollIntoView, | ||
}, | ||
}, | ||
} | ||
const response = await this.bidi.send(params) | ||
this.checkErrorInScreenshot(response) | ||
return response['result']['data'] | ||
} | ||
checkErrorInScreenshot(response) { | ||
if ('error' in response) { | ||
const { error, msg } = response | ||
switch (error) { | ||
case 'invalid argument': | ||
throw new InvalidArgumentError(msg) | ||
case 'no such frame': | ||
throw new NoSuchFrameError(msg) | ||
} | ||
} | ||
} | ||
async activate() { | ||
const params = { | ||
method: 'browsingContext.activate', | ||
params: { | ||
context: this._id, | ||
}, | ||
} | ||
let result = await this.bidi.send(params) | ||
if ('error' in result) { | ||
throw Error(result['error']) | ||
} | ||
} | ||
async handleUserPrompt(accept = undefined, userText = undefined) { | ||
const params = { | ||
method: 'browsingContext.handleUserPrompt', | ||
params: { | ||
context: this._id, | ||
accept: accept, | ||
userText: userText, | ||
}, | ||
} | ||
let result = await this.bidi.send(params) | ||
if ('error' in result) { | ||
throw Error(result['error']) | ||
} | ||
} | ||
async reload(ignoreCache = undefined, readinessState = undefined) { | ||
if ( | ||
readinessState !== undefined && | ||
!['none', 'interactive', 'complete'].includes(readinessState) | ||
) { | ||
throw Error( | ||
`Valid readiness states are 'none', 'interactive' & 'complete'. Received: ${readinessState}` | ||
) | ||
} | ||
const params = { | ||
method: 'browsingContext.reload', | ||
params: { | ||
context: this._id, | ||
ignoreCache: ignoreCache, | ||
wait: readinessState, | ||
}, | ||
} | ||
const navigateResult = (await this.bidi.send(params))['result'] | ||
return new NavigateResult( | ||
navigateResult['url'], | ||
navigateResult['navigation'] | ||
) | ||
} | ||
async setViewport(width, height, devicePixelRatio = undefined) { | ||
const params = { | ||
method: 'browsingContext.setViewport', | ||
params: { | ||
context: this._id, | ||
viewport: { width: width, height: height }, | ||
devicePixelRatio: devicePixelRatio, | ||
}, | ||
} | ||
let result = await this.bidi.send(params) | ||
if ('error' in result) { | ||
throw Error(result['error']) | ||
} | ||
} | ||
} | ||
@@ -171,0 +315,0 @@ |
@@ -40,2 +40,30 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
async onNavigationStarted(callback) { | ||
await this.subscribeAndHandleEvent( | ||
'browsingContext.navigationStarted', | ||
callback | ||
) | ||
} | ||
async onFragmentNavigated(callback) { | ||
await this.subscribeAndHandleEvent( | ||
'browsingContext.fragmentNavigated', | ||
callback | ||
) | ||
} | ||
async onUserPromptClosed(callback) { | ||
await this.subscribeAndHandleEvent( | ||
'browsingContext.userPromptClosed', | ||
callback | ||
) | ||
} | ||
async onUserPromptOpened(callback) { | ||
await this.subscribeAndHandleEvent( | ||
'browsingContext.userPromptOpened', | ||
callback | ||
) | ||
} | ||
async onDomContentLoaded(callback) { | ||
@@ -42,0 +70,0 @@ await this.subscribeAndHandleEvent( |
@@ -0,1 +1,17 @@ | ||
## 4.15.0 | ||
#### :bug: Bug fix | ||
* Replace calls to console.log with managed loggers (#12909) | ||
#### :nail_care: Polish | ||
* Add CDP v119 and remove v116 | ||
#### :rocket: New Feature | ||
* Add BiDi captureScreenshot command (#12510) | ||
* Add BiDi browsing context activate command, handle user prompt command and reload command | ||
* Add BiDi browsing context commands and events (#13078) | ||
## 4.14.0 | ||
@@ -2,0 +18,0 @@ |
@@ -29,3 +29,5 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
const { Capability } = require('../lib/capabilities') | ||
const logging = require('../lib/logging') | ||
const log_ = logging.getLogger(logging.Type.DRIVER) | ||
let debugMessagePrinted = false | ||
@@ -57,3 +59,3 @@ | ||
if (!debugMessagePrinted) { | ||
console.debug(`Selenium Manager binary found at ${filePath}`) | ||
log_.debug(`Selenium Manager binary found at ${filePath}`) | ||
debugMessagePrinted = true // Set the flag to true after printing the debug message | ||
@@ -145,6 +147,6 @@ } | ||
if (output.logs[key].level === 'WARN') { | ||
console.warn(`${output.logs[key].message}`) | ||
log_.warning(`${output.logs[key].message}`) | ||
} | ||
if (['DEBUG', 'INFO'].includes(output.logs[key].level)) { | ||
console.debug(`${output.logs[key].message}`) | ||
log_.debug(`${output.logs[key].message}`) | ||
} | ||
@@ -151,0 +153,0 @@ } |
@@ -18,2 +18,4 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
const logging = require('../lib/logging') | ||
const RESPONSE_TIMEOUT = 1000 * 30 | ||
@@ -69,3 +71,5 @@ class CDPConnection { | ||
} catch (err) { | ||
console.error(`Failed parse message: ${err.message}`) | ||
logging | ||
.getLogger(logging.Type.BROWSER) | ||
.error(`Failed parse message: ${err.message}`) | ||
} | ||
@@ -72,0 +76,0 @@ } |
@@ -30,3 +30,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
logging.installConsoleHandler() | ||
logging.getLogger('webdriver.http').setLevel(logging.Level.ALL) | ||
logging.getLogger(`${logging.Type.DRIVER}.http`).setLevel(logging.Level.ALL) | ||
;(async function () { | ||
@@ -33,0 +33,0 @@ let driver |
@@ -197,3 +197,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
/** @private @const */ | ||
this.log_ = logging.getLogger('webdriver.Builder') | ||
this.log_ = logging.getLogger(`${logging.Type.DRIVER}.Builder`) | ||
@@ -200,0 +200,0 @@ /** @private {string} */ |
@@ -37,2 +37,4 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
const log_ = logging.getLogger(`${logging.Type.DRIVER}.http`) | ||
const getAttribute = requireAtom( | ||
@@ -62,6 +64,6 @@ 'get-attribute.js', | ||
const file = bazelTarget.slice(2).replace(':', '/') | ||
console.log(`../../../bazel-bin/${file}`) | ||
log_.log(`../../../bazel-bin/${file}`) | ||
return require(path.resolve(`../../../bazel-bin/${file}`)) | ||
} catch (ex2) { | ||
console.log(ex2) | ||
log_.error(ex2) | ||
throw Error( | ||
@@ -158,4 +160,2 @@ `Failed to import atoms module ${module}. If running in dev mode, you` + | ||
const LOG = logging.getLogger('webdriver.http') | ||
function post(path) { | ||
@@ -434,3 +434,3 @@ return resource('POST', path) | ||
function buildRequest(customCommands, command) { | ||
LOG.finest(() => `Translating command: ${command.getName()}`) | ||
log_.finest(() => `Translating command: ${command.getName()}`) | ||
let spec = customCommands && customCommands.get(command.getName()) | ||
@@ -443,3 +443,3 @@ if (spec) { | ||
if (typeof spec === 'function') { | ||
LOG.finest(() => `Transforming command for W3C: ${command.getName()}`) | ||
log_.finest(() => `Transforming command for W3C: ${command.getName()}`) | ||
let newCommand = spec(command) | ||
@@ -459,3 +459,3 @@ return buildRequest(customCommands, newCommand) | ||
function toHttpRequest(resource) { | ||
LOG.finest(() => `Building HTTP request: ${JSON.stringify(resource)}`) | ||
log_.finest(() => `Building HTTP request: ${JSON.stringify(resource)}`) | ||
let parameters = command.getParameters() | ||
@@ -496,3 +496,3 @@ let path = buildPath(resource.path, parameters) | ||
/** @private {!logging.Logger} */ | ||
this.log_ = logging.getLogger('webdriver.http.Executor') | ||
this.log_ = logging.getLogger(`${logging.Type.DRIVER}.http.Executor`) | ||
} | ||
@@ -499,0 +499,0 @@ |
{ | ||
"name": "selenium-webdriver", | ||
"version": "4.14.0", | ||
"version": "4.15.0", | ||
"description": "The official WebDriver JavaScript bindings from the Selenium project", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -123,3 +123,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
/** @private @const */ | ||
this.log_ = logging.getLogger('webdriver.DriverService') | ||
this.log_ = logging.getLogger(`${logging.Type.DRIVER}.DriverService`) | ||
/** @private {string} */ | ||
@@ -126,0 +126,0 @@ this.executable_ = executable |
@@ -22,2 +22,3 @@ // Licensed to the Software Freedom Conservancy (SFC) under one | ||
const cp = require('child_process') | ||
const logging = require('../lib/logging') | ||
@@ -58,5 +59,7 @@ /** | ||
if (isSelenium3x(seleniumStandalonePath)) { | ||
console.warn( | ||
'Deprecation: Support for Standalone Server 3.x will be removed soon. Please update to version 4.x' | ||
) | ||
logging | ||
.getLogger(logging.Type.SERVER) | ||
.warning( | ||
'Deprecation: Support for Standalone Server 3.x will be removed soon. Please update to version 4.x', | ||
) | ||
return args | ||
@@ -63,0 +66,0 @@ } |
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
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
19107265
18233
7