Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

selenium-webdriver

Package Overview
Dependencies
Maintainers
0
Versions
100
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.21.0 to 4.22.0

lib/script.js

6

bidi/browsingContextInspector.js

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

const { BrowsingContextInfo, NavigationInfo } = require('./browsingContextTypes')
const { BrowsingContextInfo, NavigationInfo, UserPromptOpened, UserPromptClosed } = require('./browsingContextTypes')

@@ -131,4 +131,6 @@ /**

response = new NavigationInfo(params.context, params.navigation, params.timestamp, params.url)
} else if ('type' in params) {
response = new UserPromptOpened(params.context, params.type, params.message)
} else if ('accepted' in params) {
/* Needs to be updated when browsers implement other events */
response = new UserPromptClosed(params.context, params.accepted, params.userText)
} else {

@@ -135,0 +137,0 @@ response = new BrowsingContextInfo(params.context, params.url, params.children, params.parent)

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

module.exports = { BrowsingContextInfo, NavigationInfo }
class UserPromptOpened {
constructor(browsingContextId, type, message) {
this.browsingContextId = browsingContextId
this.type = type
this.message = message
}
}
class UserPromptClosed {
constructor(browsingContextId, accepted, userText = undefined) {
this.browsingContextId = browsingContextId
this.accepted = accepted
this.userText = userText
}
}
module.exports = { BrowsingContextInfo, NavigationInfo, UserPromptOpened, UserPromptClosed }

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

TYPE_JS_LOGS: 'javascript',
TYPE_JS_EXCEPTION: 'javascriptException',
TYPE_LOGS: 'logs',
TYPE_CONSOLE_FILTER: 'console_filter',
TYPE_JS_LOGS_FILTER: 'javascript_filter',
TYPE_JS_EXCEPTION_FILTER: 'javascriptException_filter',
TYPE_LOGS_FILTER: 'logs_filter',
}

@@ -30,2 +36,3 @@

ws
#callbackId = 0

@@ -35,3 +42,11 @@ constructor(driver, browsingContextIds) {

this._browsingContextIds = browsingContextIds
this.listener = {}
this.listener = new Map()
this.listener.set(LOG.TYPE_CONSOLE, new Map())
this.listener.set(LOG.TYPE_JS_LOGS, new Map())
this.listener.set(LOG.TYPE_JS_EXCEPTION, new Map())
this.listener.set(LOG.TYPE_LOGS, new Map())
this.listener.set(LOG.TYPE_CONSOLE_FILTER, new Map())
this.listener.set(LOG.TYPE_JS_LOGS_FILTER, new Map())
this.listener.set(LOG.TYPE_JS_EXCEPTION_FILTER, new Map())
this.listener.set(LOG.TYPE_LOGS_FILTER, new Map())
}

@@ -48,11 +63,46 @@

/**
* @param kind
*/
logListener(kind) {
if (!(kind in this.listener)) {
this.listener[kind] = []
addCallback(eventType, callback) {
const id = ++this.#callbackId
const eventCallbackMap = this.listener.get(eventType)
eventCallbackMap.set(id, callback)
return id
}
removeCallback(id) {
let hasId = false
for (const [, callbacks] of this.listener) {
if (callbacks.has(id)) {
callbacks.delete(id)
hasId = true
}
}
if (!hasId) {
throw Error(`Callback with id ${id} not found`)
}
}
invokeCallbacks(eventType, data) {
const callbacks = this.listener.get(eventType)
if (callbacks) {
for (const [, callback] of callbacks) {
callback(data)
}
}
}
invokeCallbacksWithFilter(eventType, data, filterLevel) {
const callbacks = this.listener.get(eventType)
if (callbacks) {
for (const [, value] of callbacks) {
const callback = value.callback
const filter = value.filter
if (filterLevel === filter.getLevel()) {
callback(data)
}
}
}
}
/**

@@ -62,3 +112,3 @@ * Listen to Console logs

* @param filterBy
* @returns {Promise<void>}
* @returns {Promise<number>}
*/

@@ -70,2 +120,10 @@ async onConsoleEntry(callback, filterBy = undefined) {

let id
if (filterBy !== undefined) {
id = this.addCallback(LOG.TYPE_CONSOLE_FILTER, { callback: callback, filter: filterBy })
} else {
id = this.addCallback(LOG.TYPE_CONSOLE, callback)
}
this.ws = await this.bidi.socket

@@ -90,3 +148,3 @@

if (params?.level === filterBy.getLevel()) {
callback(consoleEntry)
this.invokeCallbacksWithFilter(LOG.TYPE_CONSOLE_FILTER, consoleEntry, filterBy.getLevel())
}

@@ -96,5 +154,7 @@ return

callback(consoleEntry)
this.invokeCallbacks(LOG.TYPE_CONSOLE, consoleEntry)
}
})
return id
}

@@ -106,3 +166,3 @@

* @param filterBy
* @returns {Promise<void>}
* @returns {Promise<number>}
*/

@@ -114,2 +174,10 @@ async onJavascriptLog(callback, filterBy = undefined) {

let id
if (filterBy !== undefined) {
id = this.addCallback(LOG.TYPE_JS_LOGS_FILTER, { callback: callback, filter: filterBy })
} else {
id = this.addCallback(LOG.TYPE_JS_LOGS, callback)
}
this.ws = await this.bidi.socket

@@ -131,3 +199,3 @@

if (params?.level === filterBy.getLevel()) {
callback(jsEntry)
this.invokeCallbacksWithFilter(LOG.TYPE_JS_LOGS_FILTER, jsEntry, filterBy.getLevel())
}

@@ -137,5 +205,7 @@ return

callback(jsEntry)
this.invokeCallbacks(LOG.TYPE_JS_LOGS, jsEntry)
}
})
return id
}

@@ -146,13 +216,8 @@

* @param callback
* @returns {Promise<void>}
* @returns {Promise<number>}
*/
async onJavascriptException(callback) {
const id = this.addCallback(LOG.TYPE_JS_EXCEPTION, callback)
this.ws = await this.bidi.socket
let enabled = LOG.TYPE_JS_EXCEPTION in this.listener || this.logListener(LOG.TYPE_JS_EXCEPTION)
this.listener[LOG.TYPE_JS_EXCEPTION].push(callback)
if (enabled) {
return
}
this.ws.on('message', (event) => {

@@ -169,7 +234,7 @@ const { params } = JSON.parse(Buffer.from(event.toString()))

this.listener[LOG.TYPE_JS_EXCEPTION].forEach((listener) => {
listener(jsErrorEntry)
})
this.invokeCallbacks(LOG.TYPE_JS_EXCEPTION, jsErrorEntry)
}
})
return id
}

@@ -181,3 +246,3 @@

* @param filterBy
* @returns {Promise<void>}
* @returns {Promise<number>}
*/

@@ -189,2 +254,9 @@ async onLog(callback, filterBy = undefined) {

let id
if (filterBy !== undefined) {
id = this.addCallback(LOG.TYPE_LOGS_FILTER, { callback: callback, filter: filterBy })
} else {
id = this.addCallback(LOG.TYPE_LOGS, callback)
}
this.ws = await this.bidi.socket

@@ -210,3 +282,12 @@

callback(jsEntry)
if (filterBy !== undefined) {
if (params?.level === filterBy.getLevel()) {
{
this.invokeCallbacksWithFilter(LOG.TYPE_LOGS_FILTER, jsEntry, filterBy.getLevel())
}
return
}
}
this.invokeCallbacks(LOG.TYPE_LOGS, jsEntry)
return

@@ -229,3 +310,3 @@ }

if (params?.level === filterBy.getLevel()) {
callback(consoleEntry)
this.invokeCallbacksWithFilter(LOG.TYPE_LOGS_FILTER, consoleEntry, filterBy.getLevel())
}

@@ -235,3 +316,3 @@ return

callback(consoleEntry)
this.invokeCallbacks(LOG.TYPE_LOGS, consoleEntry)
return

@@ -251,10 +332,15 @@ }

if (params?.level === filterBy.getLevel()) {
callback(genericEntry)
{
this.invokeCallbacksWithFilter(LOG.TYPE_LOGS_FILTER, genericEntry, filterBy.getLevel())
}
return
}
return
}
callback(genericEntry)
this.invokeCallbacks(LOG.TYPE_LOGS, genericEntry)
return
}
})
return id
}

@@ -261,0 +347,0 @@

@@ -0,1 +1,9 @@

## 4.22.0
- [bidi] Add types for user prompt related events (#14097)
- Add preference to enable CDP in Firefox by default (#14091)
- [bidi] Add callback handlers for logging APIs (#14120)
- [bidi] Add high-level logging API (#14135)
- Add CDP for Chrome 126 and remove 123
## 4.21.0

@@ -2,0 +10,0 @@

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

* [webview]: https://developer.chrome.com/multidevice/webview/overview
*
* @module selenium-webdriver/chrome
*/

@@ -123,0 +125,0 @@

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

* let driver = chrome.Driver.createSession(options, service);
*
* @module selenium-webdriver/chromium
*/

@@ -71,0 +73,0 @@

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

* [WebDriver (Chromium)]: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium
*
* @module selenium-webdriver/edge
*/

@@ -78,0 +80,0 @@

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

* [PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
*
* @module selenium-webdriver/firefox
*/

@@ -248,2 +250,5 @@

this.setBrowserName(Browser.FIREFOX)
// Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it.
// https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
this.setPreference('remote.active-protocols', 3)
}

@@ -250,0 +255,0 @@

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

* [wiki](https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
*
* @module selenium-webdriver/ie
*/

@@ -28,0 +30,0 @@

{
"name": "selenium-webdriver",
"version": "4.21.0",
"version": "4.22.0",
"description": "The official WebDriver JavaScript bindings from the Selenium project",

@@ -33,2 +33,3 @@ "license": "Apache-2.0",

"@eslint/js": "^9.1.1",
"clean-jsdoc-theme": "^4.3.0",
"eslint": "^9.1.0",

@@ -42,2 +43,3 @@ "eslint-config-prettier": "^9.1.0",

"globals": "^15.0.0",
"jsdoc": "^4.0.3",
"mocha": "^10.4.0",

@@ -54,3 +56,4 @@ "mocha-junit-reporter": "^2.2.1",

"test": "npm run lint && mocha -t 600000 --recursive test",
"test-jasmine": "bazel test //javascript/node/selenium-webdriver:tests"
"test-jasmine": "bazel test //javascript/node/selenium-webdriver:tests",
"generate-docs": "jsdoc --configure jsdoc_conf.json --verbose"
},

@@ -57,0 +60,0 @@ "mocha": {

@@ -220,3 +220,3 @@ # selenium-webdriver

[PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
[api]: http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/
[api]: https://www.selenium.dev/selenium/docs/api/javascript/
[chrome]: https://googlechromelabs.github.io/chrome-for-testing/#stable

@@ -223,0 +223,0 @@ [gh]: https://github.com/SeleniumHQ/selenium/

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

* @fileoverview Defines a WebDriver client for Safari.
*
* @module selenium-webdriver/safari
*/

@@ -22,0 +24,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

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