chromedriver
Advanced tools
Comparing version 2.43.0 to 2.43.1
@@ -13,2 +13,8 @@ 'use strict'; | ||
var skipDownload = process.env.npm_config_chromedriver_skip_download || process.env.CHROMEDRIVER_SKIP_DOWNLOAD; | ||
if (skipDownload) { | ||
console.log('Found CHROMEDRIVER_SKIP_DOWNLOAD variable, skipping installation.') | ||
return; | ||
} | ||
var libPath = path.join(__dirname, 'lib', 'chromedriver'); | ||
@@ -68,2 +74,7 @@ var cdnUrl = process.env.npm_config_chromedriver_cdnurl || process.env.CHROMEDRIVER_CDNURL || 'https://chromedriver.storage.googleapis.com'; | ||
promise.then(function () { | ||
if (path.extname(downloadedFile) !== '.zip') { | ||
fs.copyFileSync(downloadedFile, path.join(tmpPath, 'chromedriver')); | ||
console.log('Skipping zip extraction - binary file found.'); | ||
return true; | ||
} | ||
return extractDownload(downloadedFile, tmpPath); | ||
@@ -70,0 +81,0 @@ }) |
@@ -0,11 +1,42 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var tcpPortUsed = require('tcp-port-used'); | ||
function getPortFromArgs(args) { | ||
var port = 9515; | ||
if (!args){ | ||
return port; | ||
} | ||
var portRegexp = /--port=(\d*)/; | ||
var portArg = args.find(function (arg) { | ||
return portRegexp.test(arg); | ||
}); | ||
if (portArg){ | ||
port = parseInt(portRegexp.exec(portArg)[1]); | ||
} | ||
return port; | ||
}; | ||
process.env.PATH = path.join(__dirname, 'chromedriver') + path.delimiter + process.env.PATH; | ||
exports.path = process.platform === 'win32' ? path.join(__dirname, 'chromedriver', 'chromedriver.exe') : path.join(__dirname, 'chromedriver', 'chromedriver'); | ||
exports.version = '2.43'; | ||
exports.start = function(args) { | ||
var cp = require('child_process').spawn(exports.path, args); | ||
exports.start = function(args, returnPromise) { | ||
var command = exports.path; | ||
if (!fs.existsSync(command)) { | ||
console.log('Could not find chromedriver in default path: ', command); | ||
console.log('Falling back to use global chromedriver bin'); | ||
command = process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver'; | ||
} | ||
var cp = require('child_process').spawn(command, args); | ||
cp.stdout.pipe(process.stdout); | ||
cp.stderr.pipe(process.stderr); | ||
exports.defaultInstance = cp; | ||
return cp; | ||
if (!returnPromise) { | ||
return cp; | ||
} | ||
var port = getPortFromArgs(args); | ||
var pollInterval = 100; | ||
var timeout = 10000; | ||
return tcpPortUsed.waitUntilUsed(port, pollInterval, timeout) | ||
.then(function () { | ||
return cp; | ||
}); | ||
}; | ||
@@ -12,0 +43,0 @@ exports.stop = function () { |
{ | ||
"name": "chromedriver", | ||
"version": "2.43.0", | ||
"version": "2.43.1", | ||
"keywords": [ | ||
@@ -32,4 +32,5 @@ "chromedriver", | ||
"mkdirp": "^0.5.1", | ||
"request": "^2.87.0" | ||
"request": "^2.87.0", | ||
"tcp-port-used": "^1.0.0" | ||
} | ||
} |
@@ -70,2 +70,8 @@ ChromeDriver | ||
This variable can be used to set either a `.zip` file or the binary itself, eg: | ||
```shell | ||
CHROMEDRIVER_FILEPATH=/bin/chromedriver | ||
``` | ||
## Custom download options | ||
@@ -85,2 +91,24 @@ | ||
## Skipping chromedriver download | ||
You may wish to skip the downloading of the chromedriver binary file, for example if you know for certain that it is already there or if you want to use a system binary and just use this module as an interface to interact with it. | ||
To achieve this you can use the npm config property `chromedriver_skip_download`. | ||
```shell | ||
npm install chromedriver --chromedriver_skip_download=true | ||
``` | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
chromedriver_skip_download=true | ||
``` | ||
Another option is to use the PATH variable `CHROMEDRIVER_SKIP_DOWNLOAD` | ||
```shell | ||
CHROMEDRIVER_SKIP_DOWNLOAD=true | ||
``` | ||
Running | ||
@@ -148,2 +176,14 @@ ------- | ||
``` | ||
With the latest version, you can optionally receive a Promise from the `chromedriver.start` function: | ||
```javascript | ||
var returnPromise = true; | ||
chromedriver | ||
.start(args, returnPromise) | ||
.then(() => { | ||
console.log('chromedriver is ready'); | ||
}); | ||
``` | ||
Note: if your tests are ran asynchronously, chromedriver.stop() will have to be | ||
@@ -150,0 +190,0 @@ executed as a callback at the end of your tests |
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 2 instances 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
29148
281
254
6
26
+ Addedtcp-port-used@^1.0.0
+ Addeddebug@4.3.1(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addedip-regex@4.3.0(transitive)
+ Addedis-url@1.2.4(transitive)
+ Addedis2@2.0.9(transitive)
+ Addedms@2.1.2(transitive)
+ Addedtcp-port-used@1.0.2(transitive)