chromedriver 137.0.1 → 137.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +260 -151
- package/install.js +16 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,13 +7,13 @@ An NPM wrapper for Selenium [ChromeDriver](https://sites.google.com/chromium.org
|
|
|
7
7
|
|
|
8
8
|
## Building and Installing
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```bash
|
|
11
11
|
npm install chromedriver
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Or grab the source and
|
|
15
15
|
|
|
16
|
-
```
|
|
16
|
+
```bash
|
|
17
17
|
node ./install.js
|
|
18
18
|
```
|
|
19
19
|
|
|
@@ -25,30 +25,87 @@ The package has been set up to fetch and run ChromeDriver for MacOS (darwin),
|
|
|
25
25
|
Linux based platforms (as identified by Node.js), and Windows. If you
|
|
26
26
|
spot any platform weirdness, let us know or send a patch.
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Configuration Methods
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
You can configure chromedriver using any of the following methods. The installer will check all of these, in order of
|
|
31
|
+
precedence:
|
|
32
|
+
|
|
33
|
+
- Environment variables in uppercase (e.g., `CHROMEDRIVER_VERSION`)
|
|
34
|
+
- `package.json#config` in lowercase
|
|
35
|
+
- `.npmrc` entries in lowercase (e.g., `chromedriver_version=LATEST`)
|
|
36
|
+
|
|
37
|
+
This applies to all options such as:
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
- `chromedriver_version`
|
|
40
|
+
- `chromedriver_cdnurl`
|
|
41
|
+
- `chromedriver_cdnbinariesurl`
|
|
42
|
+
- `chromedriver_legacy_cdnurl`
|
|
43
|
+
- `chromedriver_skip_download`
|
|
44
|
+
- `chromedriver_force_download`
|
|
45
|
+
- `chromedriver_filepath`
|
|
46
|
+
- `detect_chromedriver_version`
|
|
47
|
+
- `include_chromium`
|
|
48
|
+
|
|
49
|
+
But not to native npm config options, which can be set as per
|
|
50
|
+
[NPM's documentation](https://docs.npmjs.com/cli/using-npm/config).
|
|
51
|
+
|
|
52
|
+
For example, to set the version, you can use:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
CHROMEDRIVER_VERSION=LATEST npm install chromedriver
|
|
37
56
|
```
|
|
38
57
|
|
|
39
|
-
Or
|
|
58
|
+
Or in your package.json under `config`:
|
|
59
|
+
|
|
60
|
+
```jsonc
|
|
61
|
+
{
|
|
62
|
+
// ... other configuration
|
|
63
|
+
"config": {
|
|
64
|
+
"chromedriver_version": "LATEST"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
You can also add it to your `.npmrc` when using NPM up to version 11,
|
|
70
|
+
but the NPM team is
|
|
71
|
+
[discouraging it](https://github.com/npm/cli/issues/8153)
|
|
72
|
+
and it won't work on version 12+:
|
|
40
73
|
|
|
41
74
|
```ini
|
|
42
|
-
|
|
75
|
+
chromedriver_version=LATEST
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The same goes to using arguments, it will work up to version 11:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install chromedriver --chromedriver_version=LATEST
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
These last two way to configure the installation will be removed from this package a few months after the NPM
|
|
85
|
+
team removes support for them.
|
|
86
|
+
|
|
87
|
+
### Force download
|
|
88
|
+
|
|
89
|
+
By default this package, when installed, will search for an existing
|
|
90
|
+
Chromedriver binary in your configured temp directory. If found, and it is the
|
|
91
|
+
correct version, it will simply copy it to your node_modules directory. You can
|
|
92
|
+
force it to always download by configuring it in your package.json under `config`:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"config": {
|
|
97
|
+
"chromedriver_force_download": "true"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
43
100
|
```
|
|
44
101
|
|
|
45
102
|
Another option is to use PATH variable `CHROMEDRIVER_FORCE_DOWNLOAD`.
|
|
46
103
|
|
|
47
|
-
```
|
|
104
|
+
```bash
|
|
48
105
|
CHROMEDRIVER_FORCE_DOWNLOAD=true npm install chromedriver
|
|
49
106
|
```
|
|
50
107
|
|
|
51
|
-
|
|
108
|
+
### Custom binaries url
|
|
52
109
|
|
|
53
110
|
This allows you to use your own endpoints for metadata and binaries. It is useful in air gapped
|
|
54
111
|
scenarios or if you have download restrictions, such as firewalls.
|
|
@@ -60,71 +117,77 @@ but implemented in this package starting with version
|
|
|
60
117
|
[README.md](https://github.com/giggio/node-chromedriver/tree/114.0.1#custom-binaries-url)
|
|
61
118
|
at the latest tag where it was using the legacy urls (`114.0.1`).
|
|
62
119
|
|
|
63
|
-
### For versions >= 115
|
|
64
|
-
|
|
65
120
|
There are two urls that need to be configured, one for metadata and one for binaries.
|
|
66
121
|
The one for metadata is the "CDN url", and the one for binaries is the "CDN binaries url".
|
|
67
122
|
See [Chrome for Testing](https://googlechromelabs.github.io/chrome-for-testing/) to understand
|
|
68
123
|
how these urls work.
|
|
69
124
|
|
|
70
|
-
|
|
125
|
+
#### Config
|
|
71
126
|
|
|
72
|
-
For metadata use `chromedriver_cdnurl`. The default is `https://googlechromelabs.github.io`. You need to either supply
|
|
127
|
+
For metadata use `chromedriver_cdnurl`. The default is `https://googlechromelabs.github.io`. You need to either supply
|
|
128
|
+
the binary download endpoint, or the binaries url config, see below.
|
|
73
129
|
|
|
74
130
|
For binaries use `chromedriver_cdnbinariesurl`. The default is to search for the download url using
|
|
75
131
|
`$chromedriver_cdnurl/chrome-for-testing/[version].json`, which forms a URL like:
|
|
76
|
-
https://googlechromelabs.github.io/chrome-for-testing/122.0.6261.57.json
|
|
132
|
+
<https://googlechromelabs.github.io/chrome-for-testing/122.0.6261.57.json>.
|
|
77
133
|
|
|
78
134
|
The resulting url will be something like:
|
|
79
|
-
https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.57/linux64/chromedriver-linux64.zip
|
|
135
|
+
<https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.57/linux64/chromedriver-linux64.zip>.
|
|
80
136
|
|
|
81
137
|
Keep in mind that this last url is just an example and it might change (as it has happened in the past).
|
|
82
138
|
|
|
83
|
-
|
|
84
|
-
npm install chromedriver --chromedriver_cdnurl=https://npmmirror.com/metadata --chromedriver_cdnbinariesurl=https://npmmirror.com/binaries
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Or add these properties to your [`.npmrc`](https://docs.npmjs.com/cli/configuring-npm/npmrc) file:
|
|
88
|
-
|
|
89
|
-
```ini
|
|
90
|
-
chromedriver_cdnurl=https://npmmirror.com/metadata
|
|
91
|
-
chromedriver_cdnbinariesurl=https://npmmirror.com/binaries
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Another option is to use the environment variables `CHROMEDRIVER_CDNURL` and `CHROMEDRIVER_CDNBINARIESURL`.
|
|
139
|
+
One option is to use the environment variables `CHROMEDRIVER_CDNURL` and `CHROMEDRIVER_CDNBINARIESURL`.
|
|
95
140
|
|
|
96
|
-
```
|
|
141
|
+
```bash
|
|
97
142
|
CHROMEDRIVER_CDNURL=https://npmmirror.com/metadata CHROMEDRIVER_CDNBINARIESURL=https://npmmirror.com/binaries npm install chromedriver
|
|
98
143
|
```
|
|
99
144
|
|
|
100
|
-
|
|
145
|
+
Or add them to your `package.json`:
|
|
101
146
|
|
|
102
|
-
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"config": {
|
|
150
|
+
"chromedriver_cdnurl": "https://npmmirror.com/metadata",
|
|
151
|
+
"chromedriver_cdnbinariesurl": "https://npmmirror.com/binaries"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
103
155
|
|
|
104
|
-
|
|
105
|
-
Default is `https://chromedriver.storage.googleapis.com`.
|
|
156
|
+
Or use the legacy arguments:
|
|
106
157
|
|
|
107
|
-
```
|
|
108
|
-
npm install chromedriver --
|
|
158
|
+
```bash
|
|
159
|
+
npm install chromedriver --chromedriver_cdnurl=https://npmmirror.com/metadata --chromedriver_cdnbinariesurl=https://npmmirror.com/binaries
|
|
109
160
|
```
|
|
110
161
|
|
|
111
|
-
Or add
|
|
162
|
+
Or add these properties to your [`.npmrc`](https://docs.npmjs.com/cli/configuring-npm/npmrc) file:
|
|
112
163
|
|
|
113
164
|
```ini
|
|
114
|
-
|
|
165
|
+
chromedriver_cdnurl=https://npmmirror.com/metadata
|
|
166
|
+
chromedriver_cdnbinariesurl=https://npmmirror.com/binaries
|
|
115
167
|
```
|
|
116
168
|
|
|
117
|
-
|
|
169
|
+
### Custom binaries file
|
|
118
170
|
|
|
119
|
-
|
|
120
|
-
|
|
171
|
+
To get the chromedriver from the filesystem instead of a web request use the npm config property `chromedriver_filepath`
|
|
172
|
+
in your package.json under `config`:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"config": {
|
|
177
|
+
"chromedriver_filepath": "/path/to/chromedriver_mac64.zip"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
121
180
|
```
|
|
122
181
|
|
|
123
|
-
|
|
182
|
+
Or using the environment variable:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
CHROMEDRIVER_FILEPATH=/path/to/chromedriver_mac64.zip npm install chromedriver
|
|
186
|
+
```
|
|
124
187
|
|
|
125
|
-
|
|
188
|
+
Or the legacy methods:
|
|
126
189
|
|
|
127
|
-
```
|
|
190
|
+
```bash
|
|
128
191
|
npm install chromedriver --chromedriver_filepath=/path/to/chromedriver_mac64.zip
|
|
129
192
|
```
|
|
130
193
|
|
|
@@ -134,63 +197,192 @@ Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
|
134
197
|
chromedriver_filepath=/path/to/chromedriver_mac64.zip
|
|
135
198
|
```
|
|
136
199
|
|
|
137
|
-
Another option is to use the PATH variable `CHROMEDRIVER_FILEPATH`
|
|
138
|
-
|
|
139
|
-
```shell
|
|
140
|
-
CHROMEDRIVER_FILEPATH=/path/to/chromedriver_mac64.zip
|
|
141
|
-
```
|
|
142
|
-
|
|
143
200
|
This variable can be used to set either a `.zip` file or the binary itself, eg:
|
|
144
201
|
|
|
145
|
-
```
|
|
202
|
+
```bash
|
|
146
203
|
CHROMEDRIVER_FILEPATH=/bin/chromedriver
|
|
147
204
|
```
|
|
148
|
-
|
|
205
|
+
|
|
206
|
+
### Installing on RISC-V 64-bit Systems
|
|
207
|
+
|
|
149
208
|
Chromedriver does not provide an official binary for RISC-V 64-bit architectures. To install on a RISC-V system, you must supply your own Chromedriver binary using the `--chromedriver_filepath` option. For example:
|
|
150
209
|
|
|
151
210
|
```bash
|
|
152
211
|
npm install chromedriver --chromedriver_filepath=/path/to/chromedriver
|
|
153
212
|
```
|
|
154
|
-
|
|
213
|
+
|
|
214
|
+
### Custom download options
|
|
155
215
|
|
|
156
216
|
Install through a proxy.
|
|
157
217
|
|
|
158
|
-
```
|
|
218
|
+
```bash
|
|
159
219
|
npm config set proxy http://[user:pwd]@domain.tld:port
|
|
160
220
|
npm config set https-proxy http://[user:pwd]@domain.tld:port
|
|
161
221
|
```
|
|
162
222
|
|
|
163
223
|
Use different User-Agent.
|
|
164
224
|
|
|
165
|
-
```
|
|
225
|
+
```bash
|
|
166
226
|
npm config set user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0"
|
|
167
227
|
```
|
|
168
228
|
|
|
169
|
-
|
|
229
|
+
### Skipping chromedriver download
|
|
170
230
|
|
|
171
231
|
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.
|
|
172
232
|
|
|
173
|
-
To achieve this you can use the
|
|
233
|
+
To achieve this you can use the config property `chromedriver_skip_download`, either via environment variable:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
CHROMEDRIVER_SKIP_DOWNLOAD=true npm install chromedriver
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Or in your package.json under `config`:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"config": {
|
|
244
|
+
"chromedriver_skip_download": "true"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Or using the legacy method, via argument:
|
|
174
250
|
|
|
175
|
-
```
|
|
251
|
+
```bash
|
|
176
252
|
npm install chromedriver --chromedriver_skip_download=true
|
|
177
253
|
```
|
|
178
254
|
|
|
179
|
-
Or
|
|
255
|
+
Or adding a property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
180
256
|
|
|
181
257
|
```ini
|
|
182
258
|
chromedriver_skip_download=true
|
|
183
259
|
```
|
|
184
260
|
|
|
185
|
-
|
|
261
|
+
### Versioning
|
|
262
|
+
|
|
263
|
+
The NPM package version tracks the version of chromedriver that will be installed,
|
|
264
|
+
with an additional build number that is used for revisions to the installer.
|
|
265
|
+
You can use the package version number to install a specific version, or use the
|
|
266
|
+
setting to a specific version. If there is a new Chromedriver version available which is not yet available as a version
|
|
267
|
+
of `node-chromedriver`, the npm command `npm run update-chromedriver` in this repository can be used to make the
|
|
268
|
+
required updates to this module, please submit the change as a PR. To always install the latest version of Chromedriver,
|
|
269
|
+
use `LATEST` as the version number. In your package.json under `config`:
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"config": {
|
|
274
|
+
"chromedriver_version": "LATEST"
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Using the environment variable:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
CHROMEDRIVER_VERSION=LATEST npm install chromedriver
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Or using the legacy method:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
npm install chromedriver --chromedriver_version=LATEST
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Or adding the property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
292
|
+
|
|
293
|
+
```ini
|
|
294
|
+
chromedriver_version=LATEST
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Another option is to use env variable `CHROMEDRIVER_VERSION`.
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
CHROMEDRIVER_VERSION=LATEST npm install chromedriver
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
You can force the latest release for a specific major version by specifying `LATEST_{VERSION_NUMBER}`:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
CHROMEDRIVER_VERSION=LATEST_80 npm install chromedriver
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
You can also force a different version of chromedriver by replacing `LATEST` with a version number:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
CHROMEDRIVER_VERSION=75.0.3770.140 npm install chromedriver
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Detect ChromeDriver Version
|
|
316
|
+
|
|
317
|
+
The NPM package version may not be always compatible to your Chrome version.
|
|
318
|
+
To get the chromedriver that corresponds to the version of Chrome installed,
|
|
319
|
+
you can use the npm config property `detect_chromedriver_version`. In your package.json under `config`:
|
|
320
|
+
|
|
321
|
+
```json
|
|
322
|
+
{
|
|
323
|
+
"config": {
|
|
324
|
+
"detect_chromedriver_version": "true"
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Or using the environment variable:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
DETECT_CHROMEDRIVER_VERSION=true npm install chromedriver
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Or the legacy method with the argument:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
npm install chromedriver --detect_chromedriver_version=true
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
342
|
+
|
|
343
|
+
```ini
|
|
344
|
+
detect_chromedriver_version=true
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Note:** When the property `detect_chromedriver_version` is provided,
|
|
348
|
+
`chromedriver_version` and `chromedriver_filepath` properties are ignored.
|
|
186
349
|
|
|
187
|
-
|
|
188
|
-
|
|
350
|
+
### Include Chromium
|
|
351
|
+
|
|
352
|
+
If you don't have Chrome installed, you can check for Chromium version instead by setting the argument
|
|
353
|
+
`include_chromium` to `true`. In your package.json under `config`:
|
|
354
|
+
|
|
355
|
+
```json
|
|
356
|
+
{
|
|
357
|
+
"config": {
|
|
358
|
+
"include_chromium": "true"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
189
361
|
```
|
|
190
362
|
|
|
363
|
+
Or using the environment variable:
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
INCLUDE_CHROMIUM=true npm install chromedriver
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Or using the legacy argument:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
npm install chromedriver --include_chromium=true
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
376
|
+
|
|
377
|
+
```ini
|
|
378
|
+
include_chromium=true
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Note:** The property `INCLUDE_CHROMIUM` is ignored if the property `DETECT_CHROMEDRIVER_VERSION` is not used.
|
|
382
|
+
|
|
191
383
|
## Running
|
|
192
384
|
|
|
193
|
-
```
|
|
385
|
+
```bash
|
|
194
386
|
bin/chromedriver [arguments]
|
|
195
387
|
```
|
|
196
388
|
|
|
@@ -245,7 +437,6 @@ args = [
|
|
|
245
437
|
chromedriver.start(args);
|
|
246
438
|
// run your tests
|
|
247
439
|
chromedriver.stop();
|
|
248
|
-
|
|
249
440
|
```
|
|
250
441
|
|
|
251
442
|
With the latest version, you can optionally receive a Promise from the `chromedriver.start` function:
|
|
@@ -262,89 +453,6 @@ chromedriver
|
|
|
262
453
|
Note: if your tests are ran asynchronously, chromedriver.stop() will have to be
|
|
263
454
|
executed as a callback at the end of your tests
|
|
264
455
|
|
|
265
|
-
## Versioning
|
|
266
|
-
|
|
267
|
-
The NPM package version tracks the version of chromedriver that will be installed,
|
|
268
|
-
with an additional build number that is used for revisions to the installer.
|
|
269
|
-
You can use the package version number to install a specific version, or use the
|
|
270
|
-
setting to a specific version. If there is a new Chromedriver version available which is not yet available as a version of `node-chromedriver`, the npm command `npm run update-chromedriver` in this repository can be used to make the required updates to this module, please submit the change as a PR. To always install the latest version of Chromedriver,
|
|
271
|
-
use `LATEST` as the version number:
|
|
272
|
-
|
|
273
|
-
```shell
|
|
274
|
-
npm install chromedriver --chromedriver_version=LATEST
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
278
|
-
|
|
279
|
-
```ini
|
|
280
|
-
chromedriver_version=LATEST
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
Another option is to use env variable `CHROMEDRIVER_VERSION`.
|
|
284
|
-
|
|
285
|
-
```shell
|
|
286
|
-
CHROMEDRIVER_VERSION=LATEST npm install chromedriver
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
You can force the latest release for a specific major version by specifying `LATEST_{VERSION_NUMBER}`:
|
|
290
|
-
|
|
291
|
-
```shell
|
|
292
|
-
CHROMEDRIVER_VERSION=LATEST_80 npm install chromedriver
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
You can also force a different version of chromedriver by replacing `LATEST` with a version number:
|
|
296
|
-
|
|
297
|
-
```shell
|
|
298
|
-
CHROMEDRIVER_VERSION=75.0.3770.140 npm install chromedriver
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
## Detect ChromeDriver Version
|
|
302
|
-
|
|
303
|
-
The NPM package version may not be always compatible to your Chrome version.
|
|
304
|
-
To get the chromedriver that corresponds to the version of Chrome installed,
|
|
305
|
-
you can use the npm config property `detect_chromedriver_version`.
|
|
306
|
-
|
|
307
|
-
```shell
|
|
308
|
-
npm install chromedriver --detect_chromedriver_version
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
312
|
-
|
|
313
|
-
```ini
|
|
314
|
-
detect_chromedriver_version=true
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Another option is to use environment variable `DETECT_CHROMEDRIVER_VERSION`.
|
|
318
|
-
|
|
319
|
-
```shell
|
|
320
|
-
DETECT_CHROMEDRIVER_VERSION=true npm install chromedriver
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
**Note:** When the property `detect_chromedriver_version` is provided,
|
|
324
|
-
`chromedriver_version` and `chromedriver_filepath` properties are ignored.
|
|
325
|
-
|
|
326
|
-
## Include Chromium
|
|
327
|
-
|
|
328
|
-
If you don't have Chrome installed, you can check for Chromium version instead by setting the argument `include_chromium` to `true`.
|
|
329
|
-
|
|
330
|
-
```shell
|
|
331
|
-
npm install chromedriver --include_chromium
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file.
|
|
335
|
-
|
|
336
|
-
```ini
|
|
337
|
-
include_chromium=true
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
Another option is to use environment variable `INCLUDE_CHROMIUM`.
|
|
341
|
-
|
|
342
|
-
```shell
|
|
343
|
-
INCLUDE_CHROMIUM=true npm install chromedriver
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
**Note:** The property `INCLUDE_CHROMIUM` is ignored if the property `DETECT_CHROMEDRIVER_VERSION` is not used.
|
|
347
|
-
|
|
348
456
|
## A Note on chromedriver
|
|
349
457
|
|
|
350
458
|
Chromedriver is not a library for NodeJS.
|
|
@@ -357,7 +465,8 @@ It is not a Node.js wrapper.
|
|
|
357
465
|
We will do our best to support every supported Node.js versions.
|
|
358
466
|
See [nodejs/Release](https://github.com/nodejs/Release) for
|
|
359
467
|
the current supported versions. You can also view our
|
|
360
|
-
[build scripts](https://github.com/giggio/node-chromedriver/blob/main/.github/workflows/build.yml#L41) and check the
|
|
468
|
+
[build scripts](https://github.com/giggio/node-chromedriver/blob/main/.github/workflows/build.yml#L41) and check the
|
|
469
|
+
versions there.
|
|
361
470
|
|
|
362
471
|
## Contributing
|
|
363
472
|
|
|
@@ -376,7 +485,7 @@ If you are on Windows, set `git config core.autocrlf input` so you don't get git
|
|
|
376
485
|
[Giovanni Bassi](https://github.com/giggio), with collaboration from
|
|
377
486
|
[lots of good people](https://github.com/giggio/node-chromedriver/graphs/contributors).
|
|
378
487
|
|
|
379
|
-
Thanks for
|
|
488
|
+
Thanks for the [PhantomJS](https://github.com/Medium/phantomjs) install project for heavy inspiration!
|
|
380
489
|
|
|
381
490
|
## License
|
|
382
491
|
|
package/install.js
CHANGED
|
@@ -17,20 +17,26 @@ const finishedAsync = promisify(finished);
|
|
|
17
17
|
const process = require('node:process');
|
|
18
18
|
const console = require('node:console');
|
|
19
19
|
|
|
20
|
+
function getNpmEnvVar(name) {
|
|
21
|
+
return process.env[name.toUpperCase()] ??
|
|
22
|
+
process.env[`npm_package_config_${name}`] ??
|
|
23
|
+
process.env[`npm_config_${name}`];
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
class Installer {
|
|
21
27
|
async install() {
|
|
22
|
-
const skipDownload = (
|
|
28
|
+
const skipDownload = (getNpmEnvVar('chromedriver_skip_download') === 'true');
|
|
23
29
|
if (skipDownload) {
|
|
24
30
|
console.log('Found CHROMEDRIVER_SKIP_DOWNLOAD variable, skipping installation.');
|
|
25
31
|
process.exit(0);
|
|
26
32
|
}
|
|
27
|
-
const cdnUrl = (
|
|
28
|
-
const legacyCdnUrl = (
|
|
29
|
-
let chromedriverVersion =
|
|
30
|
-
const detectChromedriverVersion = (
|
|
33
|
+
const cdnUrl = (getNpmEnvVar('chromedriver_cdnurl') || 'https://googlechromelabs.github.io').replace(/\/+$/, '');
|
|
34
|
+
const legacyCdnUrl = (getNpmEnvVar('chromedriver_legacy_cdnurl') || 'https://chromedriver.storage.googleapis.com').replace(/\/+$/, '');
|
|
35
|
+
let chromedriverVersion = getNpmEnvVar('chromedriver_version') || helper.version;
|
|
36
|
+
const detectChromedriverVersion = (getNpmEnvVar('detect_chromedriver_version') === 'true');
|
|
31
37
|
try {
|
|
32
38
|
if (detectChromedriverVersion) {
|
|
33
|
-
const includeChromium = (
|
|
39
|
+
const includeChromium = (getNpmEnvVar('include_chromium') === 'true');
|
|
34
40
|
// Refer http://chromedriver.chromium.org/downloads/version-selection
|
|
35
41
|
const chromeVersion = await getChromeVersion(includeChromium);
|
|
36
42
|
console.log("Your Chrome version is " + chromeVersion);
|
|
@@ -60,7 +66,7 @@ class Installer {
|
|
|
60
66
|
const chromedriverIsAvailable = await this.verifyIfChromedriverIsAvailableAndHasCorrectVersion(chromedriverVersion, chromedriverBinaryFilePath);
|
|
61
67
|
if (!chromedriverIsAvailable) {
|
|
62
68
|
console.log('Current existing ChromeDriver binary is unavailable, proceeding with download and extraction.');
|
|
63
|
-
const configuredfilePath =
|
|
69
|
+
const configuredfilePath = getNpmEnvVar('chromedriver_filepath');
|
|
64
70
|
if (configuredfilePath) {
|
|
65
71
|
console.log('Using file: ', configuredfilePath);
|
|
66
72
|
downloadedFile = configuredfilePath;
|
|
@@ -92,7 +98,7 @@ class Installer {
|
|
|
92
98
|
return 'linux64';
|
|
93
99
|
} else if (process.arch === 'riscv64') {
|
|
94
100
|
// Check if --chromedriver_filepath is provided via env vars
|
|
95
|
-
const configuredfilePath =
|
|
101
|
+
const configuredfilePath = getNpmEnvVar('chromedriver_filepath');
|
|
96
102
|
if (!configuredfilePath) {
|
|
97
103
|
console.error(
|
|
98
104
|
'Error: RISC-V detected: No official Chromedriver binary is available for RISC-V 64-bit. ' +
|
|
@@ -134,7 +140,7 @@ class Installer {
|
|
|
134
140
|
* @param {string} platform
|
|
135
141
|
*/
|
|
136
142
|
async downloadFile(cdnUrl, downloadedFile, chromedriverVersion, platform) {
|
|
137
|
-
const cdnBinariesUrl = (
|
|
143
|
+
const cdnBinariesUrl = (getNpmEnvVar('chromedriver_cdnbinariesurl'))?.replace(/\/+$/, '');
|
|
138
144
|
const url = cdnBinariesUrl
|
|
139
145
|
? `${cdnBinariesUrl}/${chromedriverVersion}/${platform}/${path.basename(downloadedFile)}`
|
|
140
146
|
: await this.getDownloadUrl(cdnUrl, chromedriverVersion, platform);
|
|
@@ -176,7 +182,7 @@ class Installer {
|
|
|
176
182
|
verifyIfChromedriverIsAvailableAndHasCorrectVersion(chromedriverVersion, chromedriverBinaryFilePath) {
|
|
177
183
|
if (!fs.existsSync(chromedriverBinaryFilePath))
|
|
178
184
|
return Promise.resolve(false);
|
|
179
|
-
const forceDownload =
|
|
185
|
+
const forceDownload = getNpmEnvVar('chromedriver_force_download') === 'true';
|
|
180
186
|
if (forceDownload)
|
|
181
187
|
return Promise.resolve(false);
|
|
182
188
|
console.log('ChromeDriver binary exists. Validating...');
|