Socket
Socket
Sign inDemoInstall

selenium-standalone

Package Overview
Dependencies
Maintainers
10
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

selenium-standalone - npm Package Compare versions

Comparing version 8.3.0 to 9.0.0

lib/validation.js

170

lib/compute-download-urls.js

@@ -1,2 +0,2 @@

module.exports = computeDownloadUrls;
module.exports = { computeDownloadUrls, resolveDownloadPath, getLastChromedriverVersionFromMajor, getLatestChromium };

@@ -6,2 +6,5 @@ const got = require('got');

const { isSelenium4 } = require('./isSelenium4');
const { detectBrowserPlatform, resolveBuildId } = require('@puppeteer/browsers');
const { validateMajorVersionPrefix, getVersionWithZeroedPatchPart } = require('./validation');
const axios = require('axios');

@@ -41,3 +44,5 @@ const urls = {

*/
async function computeDownloadUrls(opts) {
async function computeDownloadUrls(options) {
const opts = Object.assign({}, options);
const downloadUrls = {

@@ -56,12 +61,79 @@ selenium:

if (opts.drivers.chrome) {
await resolveLatestVersion(opts, 'chrome', opts.drivers.chrome.baseURL + '/LATEST_RELEASE');
downloadUrls.chrome =
opts.drivers.chrome.fullURL ||
util.format(
urls.chrome,
opts.drivers.chrome.baseURL,
if (opts.drivers.chrome.version === 'latest' && !opts.drivers.chrome.fullURL) {
opts.drivers.chrome.version = await resolveBuildId(
'chromedriver',
detectBrowserPlatform(),
opts.drivers.chrome.channel ? opts.drivers.chrome.channel : 'stable'
);
downloadUrls.chrome = resolveDownloadUrl(
detectBrowserPlatform(),
opts.drivers.chrome.version,
getChromeDriverArchitecture(opts.drivers.chrome.arch, opts.drivers.chrome.version)
opts.drivers.chrome.baseURL
);
} else if (
validateMajorVersionPrefix(opts.drivers.chrome.version) &&
Number(validateMajorVersionPrefix(opts.drivers.chrome.version)) > 114 &&
!opts.drivers.chrome.fullURL
) {
const lastVersionFromMajor = opts.drivers.chrome.major
? opts.drivers.chrome.major
: await getLastChromedriverVersionFromMajor(opts.drivers.chrome.version);
if (lastVersionFromMajor) {
const url = lastVersionFromMajor.downloads.chrome
.map((m) => {
if (m.platform === detectBrowserPlatform()) {
return m.url;
}
})
.filter((f) => f !== undefined);
if (url.length) {
downloadUrls.chrome = url[0];
opts.drivers.chrome.version = lastVersionFromMajor.version;
} else {
console.log(`Url for the latest for major:${url} fallback to latest`);
opts.drivers.chrome.version = await resolveBuildId(
'chromedriver',
detectBrowserPlatform(),
opts.drivers.chrome.channel ? opts.drivers.chrome.channel : 'stable'
);
downloadUrls.chrome = resolveDownloadUrl(
detectBrowserPlatform(),
opts.drivers.chrome.version,
opts.drivers.chrome.baseURL
);
}
} else {
console.log(`The latest for major ${opts.drivers.chrome.version}:${lastVersionFromMajor} fallback to latest`);
opts.drivers.chrome.version = await resolveBuildId(
'chromedriver',
detectBrowserPlatform(),
opts.drivers.chrome.channel ? opts.drivers.chrome.channel : 'stable'
);
downloadUrls.chrome = resolveDownloadUrl(
detectBrowserPlatform(),
opts.drivers.chrome.version,
opts.drivers.chrome.baseURL
);
}
} else if (opts.drivers.chrome.fullURL) {
downloadUrls.chrome = opts.drivers.chrome.fullURL;
} else {
opts.drivers.chrome.baseURL = opts.drivers.chrome.baseURL
? opts.drivers.chrome.baseURL
: 'https://chromedriver.storage.googleapis.com';
await resolveLatestVersion(opts, 'chrome', opts.drivers.chrome.baseURL + '/LATEST_RELEASE');
downloadUrls.chrome =
opts.drivers.chrome.fullURL ||
util.format(
urls.chrome,
opts.drivers.chrome.baseURL,
opts.drivers.chrome.version,
getChromeDriverArchitecture(opts.drivers.chrome.arch, opts.drivers.chrome.version)
);
}
}

@@ -110,3 +182,2 @@ if (opts.drivers.ie) {

}
return downloadUrls;

@@ -226,3 +297,3 @@ }

async function resolveLatestVersion(opts, browserDriver, url) {
if (opts.drivers[browserDriver].version === 'latest') {
if (opts.drivers[browserDriver].version === 'latest' && browserDriver !== 'chrome') {
try {

@@ -242,4 +313,2 @@ if (browserDriver === 'firefox') {

}
} else if (await getLatestChromium(opts, browserDriver, url)) {
return true;
}

@@ -251,2 +320,6 @@ } catch (_) {

opts.drivers[browserDriver].version = opts.drivers[browserDriver].fallbackVersion;
} else if (browserDriver === 'chrome' && /^(\d{3})\.\d+\.\d+/.test(opts.drivers.chrome.version)) {
if (await getLatestChromium(opts, browserDriver, url)) {
return true;
}
}

@@ -256,11 +329,13 @@ }

async function getLatestChromium(opts, browserDriver, url) {
const response = await got(url, { timeout: 10000 });
// edgewebdriver latest version file contains invalid characters
const version = response.body.replace(/\r|\n/g, '').replace(/[^\d|.]/g, '');
if (!version) {
try {
const response = await got(url, { timeout: 10000 });
// edgewebdriver latest version file contains invalid characters
const version = response.body.replace(/\r|\n/g, '').replace(/[^\d|.]/g, '');
// eslint-disable-next-line no-param-reassign
opts.drivers[browserDriver].version = version;
return true;
} catch {
return false;
}
// eslint-disable-next-line no-param-reassign
opts.drivers[browserDriver].version = version;
return true;
}

@@ -277,10 +352,49 @@

function getVersionWithZeroedPatchPart(fullVersion) {
if (!/^\d+\.\d+\.\d+$/i.test(fullVersion)) {
// If version longer than just 3 numbers, like '4.0.0-beta-1', do nothing
return fullVersion;
function resolveDownloadUrl(
platform,
buildId,
baseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing'
) {
return `${baseUrl}/${resolveDownloadPath(platform, buildId).join('/')}`;
}
function folder(platform) {
switch (platform) {
case 'linux':
return 'linux64';
case 'mac_arm':
return 'mac-arm64';
case 'mac':
return 'mac-x64';
case 'win32':
return 'win32';
case 'win64':
return 'win64';
}
// else make version patch part zero: '4.1.1' => '4.1.0'
const [major, minor] = fullVersion.split('.');
return `${major}.${minor}.0`;
}
function resolveDownloadPath(platform, buildId) {
return [buildId, folder(platform), `chromedriver-${folder(platform)}.zip`];
}
async function getLastChromedriverVersionFromMajor(version) {
const response = await axios({
method: 'get',
url: 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json',
responseType: 'json',
headers: {
'Content-Type': 'application/json',
},
});
const versionsWithMajor = response.data.versions.filter(
(f) =>
validateMajorVersionPrefix(f.version) === validateMajorVersionPrefix(version) && 'chromedriver' in f.downloads
);
versionsWithMajor
.sort((version1, version2) => {
return version1.version.localeCompare(version2.version, undefined, { numeric: true, sensitivity: 'base' });
})
.reverse();
return versionsWithMajor.length ? versionsWithMajor[0] : null;
}
module.exports = computeFsPaths;
const path = require('path');
const { getLastChromedriverVersionFromMajor, getLatestChromium } = require('./compute-download-urls');
const { validateMajorVersionPrefix } = require('./validation');
const basePath = path.join(__dirname, '..', '.selenium');
function computeFsPaths(options) {
async function computeFsPaths(options) {
let fsPaths = {};

@@ -12,2 +14,15 @@ const opts = Object.assign({}, options);

if (opts.drivers.chrome) {
if (
opts.drivers.chrome.version !== 'latest' &&
Number(validateMajorVersionPrefix(opts.drivers.chrome.version)) > 114
) {
const version = await getLastChromedriverVersionFromMajor(opts.drivers.chrome.version);
opts.drivers.chrome.major = version;
opts.drivers.chrome.version = version ? version.version : 'latest';
} else if (
opts.drivers.chrome.version !== 'latest' &&
Number(validateMajorVersionPrefix(opts.drivers.chrome.version)) <= 114
) {
await getLatestChromium(opts, 'chrome', 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE');
}
fsPaths.chrome = {

@@ -14,0 +29,0 @@ installPath: path.join(

4

lib/default-config.js

@@ -8,5 +8,5 @@ module.exports = () => {

version: 'latest',
fallbackVersion: '94.0.4606.61',
channel: 'stable',
arch: process.arch,
baseURL: 'https://chromedriver.storage.googleapis.com',
baseURL: 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing',
},

@@ -13,0 +13,0 @@ ie: {

@@ -118,3 +118,3 @@ const tarStream = require('tar-stream');

zipFile.on('entry', (entry) => {
if (/.*\/.*/.test(entry.fileName)) {
if (fs.existsSync(entry.fileName) && fs.lstatSync(entry.fileName).isDirectory()) {
return; // ignore folders, i.e. release notes folder in edge driver zip

@@ -128,3 +128,3 @@ }

path.dirname(zipFilePath),
isBrowserDriver(entry.fileName) ? path.basename(zipFilePath, '.zip') : entry.fileName
isBrowserDriver(entry.fileName) ? path.basename(zipFilePath, '.zip') : path.basename(entry.fileName)
);

@@ -131,0 +131,0 @@ const extractWriteStream = fs

@@ -11,3 +11,3 @@ /* eslint-disable no-shadow */

const computeDownloadUrls = require('./compute-download-urls');
const { computeDownloadUrls } = require('./compute-download-urls');
const computeFsPaths = require('./compute-fs-paths');

@@ -71,3 +71,3 @@ const defaultConfig = require('./default-config')();

const requestOpts = Object.assign({ timeout: 90000 }, opts.requestOpts);
const requestOpts = Object.assign({ timeout: 320000 }, opts.requestOpts);
if (opts.proxy) {

@@ -84,3 +84,3 @@ requestOpts.proxy = opts.proxy;

const fsPaths = computeFsPaths({
const fsPaths = await computeFsPaths({
seleniumVersion: opts.version,

@@ -87,0 +87,0 @@ drivers: opts.drivers,

@@ -65,3 +65,3 @@ module.exports = start;

const fsPaths = computeFsPaths({
const fsPaths = await computeFsPaths({
seleniumVersion: opts.version,

@@ -68,0 +68,0 @@ drivers: opts.drivers,

{
"name": "selenium-standalone",
"version": "8.3.0",
"version": "9.0.0",
"description": "installs a `selenium-standalone` command line to install and start a standalone selenium server",
"main": "index.js",
"engines": {
"node": ">=12.0.0",
"npm": ">=6.0.0"
"node": ">=16.3.0",
"npm": ">=8.0.0"
},
"scripts": {
"start": "DEBUG=selenium-standalone:* ./bin/selenium-standalone install && DEBUG=selenium-standalone:* ./bin/selenium-standalone start",
"test": "export SELENIUM_VERSION=4.4.0&& ./bin/selenium-standalone install && mocha && export SELENIUM_VERSION=3.141.59&& ./bin/selenium-standalone install && mocha 'test/programmatic.js'",
"test": "export SELENIUM_VERSION=4.4.0 && ./bin/selenium-standalone install && mocha --timeout=15000 && export SELENIUM_VERSION=3.141.59 && ./bin/selenium-standalone install && mocha 'test/programmatic.js' --timeout=15000",
"docker:build": "run-s docker:build:*",

@@ -43,2 +43,4 @@ "docker:build:latest": "docker build -t webdriverio/${npm_package_name}:latest --cache-from webdriverio/${npm_package_name}:latest .",

"dependencies": {
"@puppeteer/browsers": "^1.5.0",
"axios": "^1.4.0",
"commander": "^10.0.0",

@@ -62,4 +64,4 @@ "cross-spawn": "^7.0.3",

"doctoc": "2.2.1",
"eslint": "8.33.0",
"eslint-config-prettier": "8.6.0",
"eslint": "8.42.0",
"eslint-config-prettier": "8.7.0",
"eslint-plugin-prettier": "4.2.1",

@@ -71,5 +73,5 @@ "husky": "8.0.3",

"npm-run-all": "^4.1.5",
"prettier": "2.8.3",
"prettier": "2.8.8",
"release-it": "^15.0.0"
}
}

@@ -0,1 +1,3 @@

⚠️ __ATTENTION:__ we are looking for people taking on maintenance for this package. Read more in [`webdriverio/selenium-standalone#813`](https://github.com/webdriverio/selenium-standalone/issues/813).
Node.js Selenium Standalone [![Test](https://github.com/webdriverio/selenium-standalone/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/webdriverio/selenium-standalone/actions/workflows/test.yml)

@@ -2,0 +4,0 @@ ===========================

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