selenium-standalone
Advanced tools
Comparing version 9.1.2 to 9.2.0
@@ -29,3 +29,3 @@ <!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
// https://selenium-release.storage.googleapis.com/index.html | ||
version: process.env.SELENIUM_VERSION || '4.4.0', | ||
version: process.env.SELENIUM_VERSION || '4.9.0', | ||
baseURL: 'https://selenium-release.storage.googleapis.com', | ||
@@ -90,2 +90,4 @@ drivers: { | ||
`opts.onlyDriver` can be any valid 'chrome' | 'firefox' | 'chromiumedge' it allow to install any driver without selenium server | ||
returns `Promise<void>` | ||
@@ -118,2 +120,4 @@ | ||
`opts.onlyDriver` can be any valid 'chrome' | 'firefox' | 'chromiumedge' it allow to start any driver directly without selenium server | ||
returns `Promise<ChildProcess>` | ||
@@ -129,6 +133,4 @@ | ||
or use truthy `opts.processKiller` in config | ||
## Set `selenium-standalone` Version as NodeJS environment parameter | ||
You can set any version by `process.env.SELENIUM_VERSION=3.141.59` before starting selenium-standalone. Default values are here: [lib/default-config.js](../lib/default-config.js) |
@@ -55,2 +55,6 @@ <!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
# install or start only certain driver | ||
selenium-standalone install --onlyDriver=chrome | ||
selenium-standalone start --onlyDriver=chrome | ||
``` | ||
@@ -57,0 +61,0 @@ |
@@ -51,3 +51,3 @@ const path = require('path'); | ||
`${opts.drivers.ie.version}-${detectBrowserPlatformCustom(opts.drivers.ie.arch)}`, | ||
'IEDriverServer.exe' | ||
'IEDriverServer' | ||
), | ||
@@ -100,2 +100,6 @@ }; | ||
downloadPath = acc[name].installPath + '.zip'; | ||
if (process.platform === 'win32') { | ||
acc[name].installPath = `${acc[name].installPath}.exe`; | ||
} | ||
} | ||
@@ -102,0 +106,0 @@ acc[name].downloadPath = downloadPath; |
@@ -10,2 +10,3 @@ module.exports = () => { | ||
arch: process.arch, | ||
onlyDriverArgs: [], | ||
baseURL: 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing', | ||
@@ -22,2 +23,3 @@ }, | ||
arch: process.arch, | ||
onlyDriverArgs: [], | ||
baseURL: 'https://github.com/mozilla/geckodriver/releases/download', | ||
@@ -32,2 +34,3 @@ }, | ||
arch: process.arch, | ||
onlyDriverArgs: [], | ||
baseURL: 'https://msedgedriver.azureedge.net', | ||
@@ -34,0 +37,0 @@ }, |
@@ -131,3 +131,5 @@ const tarStream = require('tar-stream'); | ||
path.dirname(zipFilePath), | ||
isBrowserDriver(entry.fileName) ? path.basename(zipFilePath, '.zip') : path.basename(entry.fileName) | ||
isBrowserDriver(entry.fileName) | ||
? path.basename(zipFilePath, '.zip') + `${process.platform === 'win32' ? '.exe' : ''}` | ||
: path.basename(entry.fileName) | ||
); | ||
@@ -134,0 +136,0 @@ const extractWriteStream = fs |
@@ -57,7 +57,9 @@ /* eslint-disable no-shadow */ | ||
if (opts.singleDriverInstall) { | ||
const singleDriver = opts.drivers[opts.singleDriverInstall]; | ||
if (opts.singleDriverInstall || opts.onlyDriver) { | ||
const driver = opts.singleDriverInstall || opts.onlyDriver; | ||
const singleDriver = opts.drivers[driver]; | ||
if (singleDriver) { | ||
opts.drivers = {}; | ||
opts.drivers[opts.singleDriverInstall] = singleDriver; | ||
opts.drivers[driver] = singleDriver; | ||
} | ||
@@ -89,2 +91,5 @@ } | ||
if (opts.onlyDriver) { | ||
delete fsPaths.selenium; | ||
} | ||
const urls = await computeDownloadUrls({ | ||
@@ -104,2 +109,3 @@ seleniumVersion: opts.version, | ||
fsPaths: fsPaths, | ||
opts: opts, | ||
}), | ||
@@ -144,9 +150,11 @@ asyncLogEnd.bind(null, logger), | ||
async function download(opts) { | ||
const installers = [ | ||
{ | ||
const installers = []; | ||
if (!opts.opts.onlyDriver) { | ||
installers.push({ | ||
installer: installSelenium, | ||
from: opts.urls.selenium, | ||
to: opts.fsPaths.selenium.downloadPath, | ||
}, | ||
]; | ||
}); | ||
} | ||
@@ -192,3 +200,2 @@ if (opts.fsPaths.chrome) { | ||
} | ||
return Promise.all(installers.map((i) => onlyInstallMissingFiles(i))); | ||
@@ -195,0 +202,0 @@ } |
@@ -21,2 +21,4 @@ const fkill = require('fkill'); | ||
processesName.push('safaridriver'); | ||
} else { | ||
processesName.push(driverName); | ||
} | ||
@@ -28,13 +30,15 @@ } | ||
async function processKiller(drivers, portValue) { | ||
if (portValue) { | ||
if (!Number.isNaN(Number(`${portValue}`.startsWith(':') ? `${portValue}`.substring(1) : `${portValue}`))) { | ||
const portCast = `${portValue}`.startsWith(':') ? portValue : `:${portValue}`; | ||
async function processKiller(ports, processesName) { | ||
if (ports && ports.length) { | ||
for (const port of ports) { | ||
if (port) { | ||
const portCast = `${port}`.startsWith(':') ? port : `:${port}`; | ||
await killProcessByFkill([portCast]); | ||
await killProcessByCmd([`${portValue}`.startsWith(':') ? `${portValue}`.substring(1) : portValue], 'port'); | ||
await killProcessByFkill([portCast]); | ||
await killProcessByCmd([`${port}`.startsWith(':') ? `${port}`.substring(1) : port], 'port'); | ||
} | ||
} | ||
} | ||
if (drivers && typeof drivers === 'object' && Object.keys(drivers).length) { | ||
await killProcess(getConfigProcessesName(drivers), 'name'); | ||
if (processesName && processesName.length) { | ||
await killProcess(getConfigProcessesName(processesName), 'name'); | ||
} | ||
@@ -86,4 +90,2 @@ } | ||
module.exports = { | ||
processKiller, | ||
}; | ||
module.exports = processKiller; |
@@ -18,3 +18,4 @@ module.exports = start; | ||
const noop = require('./noop'); | ||
const { processKiller } = require('./processKiller.js'); | ||
const processKiller = require('./processKiller.js'); | ||
const { startDriver } = require('./driver-starter.js'); | ||
@@ -59,7 +60,9 @@ async function start(_opts) { | ||
if (opts.singleDriverStart) { | ||
const singleDriver = opts.drivers[opts.singleDriverStart]; | ||
if (opts.singleDriverStart || opts.onlyDriver) { | ||
const driver = opts.singleDriverStart || opts.onlyDriver; | ||
const singleDriver = opts.drivers[driver]; | ||
if (singleDriver) { | ||
opts.drivers = {}; | ||
opts.drivers[opts.singleDriverStart] = singleDriver; | ||
opts.drivers[opts.singleDriverStart || opts.onlyDriver] = singleDriver; | ||
} | ||
@@ -74,2 +77,6 @@ } | ||
if (opts.onlyDriver) { | ||
delete fsPaths.selenium; | ||
} | ||
// programmatic use, did not give javaPath | ||
@@ -149,17 +156,38 @@ if (!opts.javaPath) { | ||
args.push(...opts.javaArgs, '-jar', fsPaths.selenium.installPath, ...opts.seleniumArgs); | ||
let seleniumStatusUrl; | ||
if (!opts.onlyDriver) { | ||
args.push(...opts.javaArgs, '-jar', fsPaths.selenium.installPath, ...opts.seleniumArgs); | ||
seleniumStatusUrl = statusUrl.getSeleniumStatusUrl(args, opts); | ||
} | ||
await checkPathsExistence(Object.keys(fsPaths).map((name) => fsPaths[name].installPath)); | ||
const seleniumStatusUrl = statusUrl.getSeleniumStatusUrl(args, opts); | ||
if ( | ||
(await isPortReachable((seleniumStatusUrl && seleniumStatusUrl.port) || 4444, { timeout: 100 })) || | ||
opts.onlyDriver | ||
) { | ||
const seleniumPort = (seleniumStatusUrl && seleniumStatusUrl.port) || 4444; | ||
if (await isPortReachable(seleniumStatusUrl.port, { timeout: 100 })) { | ||
if (!('processKiller' in opts) || ('processKiller' in opts && opts.processKiller)) { | ||
await processKiller(opts.drivers, seleniumStatusUrl.port); | ||
if (opts.onlyDriver) { | ||
const drivers = Object.keys(opts.drivers); | ||
const ports = []; | ||
if (await isPortReachable(seleniumStatusUrl.port, { timeout: 100 })) { | ||
throw new Error(`Port ${seleniumStatusUrl.port} is already in use.`); | ||
for (const driver of drivers) { | ||
if (driver === 'firefox' && (await isPortReachable(4444, { timeout: 1000, host: '127.0.0.1' }))) { | ||
ports.push(4444); | ||
} | ||
if ((driver === 'chrome' || driver === 'chromiumedge') && (await isPortReachable(9515, { timeout: 100 }))) { | ||
ports.push(9515); | ||
} | ||
} | ||
await processKiller([...ports, seleniumPort], Object.keys(opts.drivers)); | ||
} else { | ||
await processKiller([seleniumPort], Object.keys(opts.drivers)); | ||
} | ||
if (await isPortReachable(seleniumPort, { timeout: 100 })) { | ||
throw new Error(`Port ${seleniumPort} is already in use.`); | ||
} | ||
} else { | ||
throw new Error(`Port ${seleniumStatusUrl.port} is already in use.`); | ||
throw new Error(`Port ${seleniumPort} is already in use.`); | ||
} | ||
@@ -173,14 +201,25 @@ } | ||
debug('Spawning Selenium Server process', opts.javaPath, args); | ||
const selenium = spawn(opts.javaPath, args, opts.spawnOptions); | ||
await checkStarted(selenium, seleniumStatusUrl.toString()); | ||
if (selenium.stdout) { | ||
selenium.stdout.on('data', noop); | ||
} | ||
if (opts.onlyDriver && opts.drivers[opts.onlyDriver]) { | ||
const chromeDriverProcess = await startDriver( | ||
fsPaths[opts.onlyDriver].installPath, | ||
opts.drivers[opts.onlyDriver].onlyDriverArgs | ||
); | ||
if (selenium.stderr) { | ||
selenium.stderr.on('data', noop); | ||
return chromeDriverProcess; | ||
// eslint-disable-next-line no-else-return | ||
} else { | ||
const selenium = spawn(opts.javaPath, args, opts.spawnOptions); | ||
await checkStarted(selenium, seleniumStatusUrl.toString()); | ||
if (selenium.stdout) { | ||
selenium.stdout.on('data', noop); | ||
} | ||
if (selenium.stderr) { | ||
selenium.stderr.on('data', noop); | ||
} | ||
return selenium; | ||
} | ||
return selenium; | ||
} | ||
@@ -187,0 +226,0 @@ |
{ | ||
"name": "selenium-standalone", | ||
"version": "9.1.2", | ||
"version": "9.2.0", | ||
"description": "installs a `selenium-standalone` command line to install and start a standalone selenium server", | ||
@@ -61,5 +61,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"chai": "4.3.8", | ||
"chai": "4.3.10", | ||
"doctoc": "2.2.1", | ||
"eslint": "8.49.0", | ||
"eslint": "8.50.0", | ||
"eslint-config-prettier": "9.0.0", | ||
@@ -66,0 +66,0 @@ "eslint-plugin-prettier": "4.2.1", |
@@ -22,4 +22,6 @@ ⚠️ __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). | ||
Starting from `v9.0.6` support changes regarding new storage for `latest` versions of chromedriver. | ||
Starting from `v9.0.6` supported changes regarding new storage for `latest` versions of chromedriver. | ||
Starting from `v9.2.0` added new feature 'onlyDriver' | ||
## Install & Run | ||
@@ -26,0 +28,0 @@ |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
103708
44
1718
98
8
2