selenium-standalone
Advanced tools
Comparing version 8.3.0 to 9.0.0
@@ -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( |
@@ -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 @@ =========================== |
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
92973
41
1437
95
16
+ Added@puppeteer/browsers@^1.5.0
+ Addedaxios@^1.4.0
+ Added@puppeteer/browsers@1.9.1(transitive)
+ Added@tootallnate/quickjs-emscripten@0.23.0(transitive)
+ Added@types/yauzl@2.10.3(transitive)
+ Addedagent-base@7.1.1(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedast-types@0.13.4(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.7.7(transitive)
+ Addedbasic-ftp@5.0.5(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddata-uri-to-buffer@6.0.2(transitive)
+ Addeddebug@4.3.4(transitive)
+ Addeddegenerator@5.0.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescodegen@2.1.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedestraverse@5.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedextract-zip@2.0.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedfs-extra@11.2.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-uri@6.0.3(transitive)
+ Addedhttp-proxy-agent@7.0.2(transitive)
+ Addedhttps-proxy-agent@7.0.5(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addedlru-cache@7.18.3(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addedms@2.1.2(transitive)
+ Addednetmask@2.0.2(transitive)
+ Addedpac-proxy-agent@7.0.2(transitive)
+ Addedpac-resolver@7.0.1(transitive)
+ Addedproxy-agent@6.3.1(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsocks-proxy-agent@8.0.4(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedtar-fs@3.0.4(transitive)
+ Addedtar-stream@3.1.7(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedunbzip2-stream@1.4.3(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)