appium-chromedriver 5.0.2 → 5.0.5
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 +3 -1
- package/build/index.js +1 -1
- package/build/lib/chromedriver.js +68 -61
- package/build/lib/install.js +1 -1
- package/build/lib/protocol-helpers.js +1 -1
- package/build/lib/storage-client.js +1 -1
- package/build/lib/utils.js +11 -2
- package/config/mapping.json +1 -0
- package/lib/chromedriver.js +68 -64
- package/lib/utils.js +15 -1
- package/package.json +6 -4
package/lib/chromedriver.js
CHANGED
|
@@ -9,7 +9,7 @@ import { SubProcess, exec } from 'teen_process';
|
|
|
9
9
|
import B from 'bluebird';
|
|
10
10
|
import {
|
|
11
11
|
getChromeVersion, getChromedriverDir, CHROMEDRIVER_CHROME_MAPPING,
|
|
12
|
-
getChromedriverBinaryPath, CD_CDN,
|
|
12
|
+
getChromedriverBinaryPath, CD_CDN, generateLogPrefix
|
|
13
13
|
} from './utils';
|
|
14
14
|
import semver from 'semver';
|
|
15
15
|
import _ from 'lodash';
|
|
@@ -18,9 +18,6 @@ import compareVersions from 'compare-versions';
|
|
|
18
18
|
import ChromedriverStorageClient from './storage-client';
|
|
19
19
|
import { toW3cCapNames, getCapValue } from './protocol-helpers';
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const log = logger.getLogger('Chromedriver');
|
|
23
|
-
|
|
24
21
|
const NEW_CD_VERSION_FORMAT_MAJOR_VERSION = 73;
|
|
25
22
|
const DEFAULT_HOST = '127.0.0.1';
|
|
26
23
|
const MIN_CD_VERSION_WITH_W3C_SUPPORT = 75;
|
|
@@ -56,6 +53,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
56
53
|
details,
|
|
57
54
|
isAutodownloadEnabled = false,
|
|
58
55
|
} = args;
|
|
56
|
+
this._log = logger.getLogger(generateLogPrefix(this));
|
|
59
57
|
|
|
60
58
|
this.proxyHost = host;
|
|
61
59
|
this.proxyPort = port;
|
|
@@ -71,7 +69,8 @@ class Chromedriver extends events.EventEmitter {
|
|
|
71
69
|
this.state = Chromedriver.STATE_STOPPED;
|
|
72
70
|
this.jwproxy = new JWProxy({
|
|
73
71
|
server: this.proxyHost,
|
|
74
|
-
port: this.proxyPort
|
|
72
|
+
port: this.proxyPort,
|
|
73
|
+
log: this._log,
|
|
75
74
|
});
|
|
76
75
|
this.verbose = verbose;
|
|
77
76
|
this.logPath = logPath;
|
|
@@ -84,23 +83,27 @@ class Chromedriver extends events.EventEmitter {
|
|
|
84
83
|
this.desiredProtocol = PROTOCOLS.MJSONWP;
|
|
85
84
|
}
|
|
86
85
|
|
|
86
|
+
get log () {
|
|
87
|
+
return this._log;
|
|
88
|
+
}
|
|
89
|
+
|
|
87
90
|
async getDriversMapping () {
|
|
88
91
|
let mapping = _.cloneDeep(CHROMEDRIVER_CHROME_MAPPING);
|
|
89
92
|
if (this.mappingPath) {
|
|
90
|
-
log.debug(`Attempting to use Chromedriver->Chrome mapping from '${this.mappingPath}'`);
|
|
93
|
+
this.log.debug(`Attempting to use Chromedriver->Chrome mapping from '${this.mappingPath}'`);
|
|
91
94
|
if (!await fs.exists(this.mappingPath)) {
|
|
92
|
-
log.warn(`No file found at '${this.mappingPath}'`);
|
|
93
|
-
log.info('Defaulting to the static Chromedriver->Chrome mapping');
|
|
95
|
+
this.log.warn(`No file found at '${this.mappingPath}'`);
|
|
96
|
+
this.log.info('Defaulting to the static Chromedriver->Chrome mapping');
|
|
94
97
|
} else {
|
|
95
98
|
try {
|
|
96
99
|
mapping = JSON.parse(await fs.readFile(this.mappingPath, 'utf8'));
|
|
97
100
|
} catch (err) {
|
|
98
|
-
log.warn(`Error parsing mapping from '${this.mappingPath}': ${err.message}`);
|
|
99
|
-
log.info('Defaulting to the static Chromedriver->Chrome mapping');
|
|
101
|
+
this.log.warn(`Error parsing mapping from '${this.mappingPath}': ${err.message}`);
|
|
102
|
+
this.log.info('Defaulting to the static Chromedriver->Chrome mapping');
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
} else {
|
|
103
|
-
log.debug('Using the static Chromedriver->Chrome mapping');
|
|
106
|
+
this.log.debug('Using the static Chromedriver->Chrome mapping');
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
// make sure that the values for minimum chrome version are semver compliant
|
|
@@ -109,7 +112,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
109
112
|
if (coercedVersion) {
|
|
110
113
|
mapping[cdVersion] = coercedVersion.version;
|
|
111
114
|
} else {
|
|
112
|
-
log.info(`'${chromeVersion}' is not a valid version number. Skipping it`);
|
|
115
|
+
this.log.info(`'${chromeVersion}' is not a valid version number. Skipping it`);
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
return mapping;
|
|
@@ -117,10 +120,15 @@ class Chromedriver extends events.EventEmitter {
|
|
|
117
120
|
|
|
118
121
|
async getChromedrivers (mapping) {
|
|
119
122
|
// go through the versions available
|
|
120
|
-
const executables = await fs.glob(
|
|
121
|
-
|
|
123
|
+
const executables = await fs.glob('*', {
|
|
124
|
+
cwd: this.executableDir,
|
|
125
|
+
strict: false,
|
|
126
|
+
nodir: true,
|
|
127
|
+
absolute: true,
|
|
128
|
+
});
|
|
129
|
+
this.log.debug(`Found ${util.pluralize('executable', executables.length, true)} ` +
|
|
122
130
|
`in '${this.executableDir}'`);
|
|
123
|
-
const cds = (await asyncmap(executables, async
|
|
131
|
+
const cds = (await asyncmap(executables, async (executable) => {
|
|
124
132
|
const logError = ({message, stdout = null, stderr = null}) => {
|
|
125
133
|
let errMsg = `Cannot retrieve version number from '${path.basename(executable)}' Chromedriver binary. ` +
|
|
126
134
|
`Make sure it returns a valid version string in response to '--version' command line argument. ${message}`;
|
|
@@ -130,7 +138,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
130
138
|
if (stderr) {
|
|
131
139
|
errMsg += `\nStderr: ${stderr}`;
|
|
132
140
|
}
|
|
133
|
-
log.warn(errMsg);
|
|
141
|
+
this.log.warn(errMsg);
|
|
134
142
|
return null;
|
|
135
143
|
};
|
|
136
144
|
|
|
@@ -177,12 +185,12 @@ class Chromedriver extends events.EventEmitter {
|
|
|
177
185
|
.filter((cd) => !!cd)
|
|
178
186
|
.sort((a, b) => compareVersions(b.version, a.version));
|
|
179
187
|
if (_.isEmpty(cds)) {
|
|
180
|
-
log.info(`No Chromedrivers were found in '${this.executableDir}'`);
|
|
188
|
+
this.log.info(`No Chromedrivers were found in '${this.executableDir}'`);
|
|
181
189
|
return cds;
|
|
182
190
|
}
|
|
183
|
-
log.debug(`The following Chromedriver executables were found:`);
|
|
191
|
+
this.log.debug(`The following Chromedriver executables were found:`);
|
|
184
192
|
for (const cd of cds) {
|
|
185
|
-
log.debug(` '${cd.executable}' (version '${cd.version}', minimum Chrome version '${cd.minChromeVersion ? cd.minChromeVersion : 'Unknown'}')`);
|
|
193
|
+
this.log.debug(` '${cd.executable}' (version '${cd.version}', minimum Chrome version '${cd.minChromeVersion ? cd.minChromeVersion : 'Unknown'}')`);
|
|
186
194
|
}
|
|
187
195
|
return cds;
|
|
188
196
|
}
|
|
@@ -192,7 +200,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
192
200
|
// The `info` item must contain the output of /json/version CDP command
|
|
193
201
|
// where `Browser` field looks like `Chrome/72.0.3601.0``
|
|
194
202
|
if (this.details?.info) {
|
|
195
|
-
log.debug(`Browser version in the supplied details: ${this.details?.info?.Browser}`);
|
|
203
|
+
this.log.debug(`Browser version in the supplied details: ${this.details?.info?.Browser}`);
|
|
196
204
|
}
|
|
197
205
|
const versionMatch = VERSION_PATTERN.exec(this.details?.info?.Browser);
|
|
198
206
|
if (versionMatch) {
|
|
@@ -256,7 +264,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
256
264
|
await fs.writeFile(this.mappingPath, JSON.stringify(newMapping, null, 2), 'utf8');
|
|
257
265
|
shouldUpdateStaticMapping = false;
|
|
258
266
|
} catch (e) {
|
|
259
|
-
log.warn(`Cannot store the updated chromedrivers mapping into '${this.mappingPath}'. ` +
|
|
267
|
+
this.log.warn(`Cannot store the updated chromedrivers mapping into '${this.mappingPath}'. ` +
|
|
260
268
|
`This may reduce the performance of further executions. Original error: ${e.message}`);
|
|
261
269
|
}
|
|
262
270
|
}
|
|
@@ -272,14 +280,14 @@ class Chromedriver extends events.EventEmitter {
|
|
|
272
280
|
|
|
273
281
|
const mapping = await this.getDriversMapping();
|
|
274
282
|
if (!_.isEmpty(mapping)) {
|
|
275
|
-
log.debug(`The most recent known Chrome version: ${_.values(mapping)[0]}`);
|
|
283
|
+
this.log.debug(`The most recent known Chrome version: ${_.values(mapping)[0]}`);
|
|
276
284
|
}
|
|
277
285
|
|
|
278
286
|
let didStorageSync = false;
|
|
279
287
|
const syncChromedrivers = async (chromeVersion) => {
|
|
280
288
|
didStorageSync = true;
|
|
281
289
|
const retrievedMapping = await this.storageClient.retrieveMapping();
|
|
282
|
-
log.debug('Got chromedrivers mapping from the storage: ' +
|
|
290
|
+
this.log.debug('Got chromedrivers mapping from the storage: ' +
|
|
283
291
|
JSON.stringify(retrievedMapping, null, 2));
|
|
284
292
|
const driverKeys = await this.storageClient.syncDrivers({
|
|
285
293
|
minBrowserVersion: chromeVersion.major,
|
|
@@ -313,7 +321,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
313
321
|
missingVersions[version] = minChromeVersion;
|
|
314
322
|
}
|
|
315
323
|
if (!_.isEmpty(missingVersions)) {
|
|
316
|
-
log.info(`Found ${util.pluralize('Chromedriver', _.size(missingVersions), true)}, ` +
|
|
324
|
+
this.log.info(`Found ${util.pluralize('Chromedriver', _.size(missingVersions), true)}, ` +
|
|
317
325
|
`which ${_.size(missingVersions) === 1 ? 'is' : 'are'} missing in the list of known versions: ` +
|
|
318
326
|
JSON.stringify(missingVersions));
|
|
319
327
|
await this.updateDriversMapping(Object.assign(mapping, missingVersions));
|
|
@@ -321,12 +329,12 @@ class Chromedriver extends events.EventEmitter {
|
|
|
321
329
|
|
|
322
330
|
if (this.disableBuildCheck) {
|
|
323
331
|
if (_.isEmpty(cds)) {
|
|
324
|
-
log.errorAndThrow(`There must be at least one Chromedriver executable available for use if ` +
|
|
332
|
+
this.log.errorAndThrow(`There must be at least one Chromedriver executable available for use if ` +
|
|
325
333
|
`'chromedriverDisableBuildCheck' capability is set to 'true'`);
|
|
326
334
|
}
|
|
327
335
|
const {version, executable} = cds[0];
|
|
328
|
-
log.warn(`Chrome build check disabled. Using most recent Chromedriver version (${version}, at '${executable}')`);
|
|
329
|
-
log.warn(`If this is wrong, set 'chromedriverDisableBuildCheck' capability to 'false'`);
|
|
336
|
+
this.log.warn(`Chrome build check disabled. Using most recent Chromedriver version (${version}, at '${executable}')`);
|
|
337
|
+
this.log.warn(`If this is wrong, set 'chromedriverDisableBuildCheck' capability to 'false'`);
|
|
330
338
|
return executable;
|
|
331
339
|
}
|
|
332
340
|
|
|
@@ -334,14 +342,14 @@ class Chromedriver extends events.EventEmitter {
|
|
|
334
342
|
if (!chromeVersion) {
|
|
335
343
|
// unable to get the chrome version
|
|
336
344
|
if (_.isEmpty(cds)) {
|
|
337
|
-
log.errorAndThrow(`There must be at least one Chromedriver executable available for use if ` +
|
|
345
|
+
this.log.errorAndThrow(`There must be at least one Chromedriver executable available for use if ` +
|
|
338
346
|
`the current Chrome version cannot be determined`);
|
|
339
347
|
}
|
|
340
348
|
const {version, executable} = cds[0];
|
|
341
|
-
log.warn(`Unable to discover Chrome version. Using Chromedriver ${version} at '${executable}'`);
|
|
349
|
+
this.log.warn(`Unable to discover Chrome version. Using Chromedriver ${version} at '${executable}'`);
|
|
342
350
|
return executable;
|
|
343
351
|
}
|
|
344
|
-
log.debug(`Found Chrome bundle '${this.bundleId}' version '${chromeVersion}'`);
|
|
352
|
+
this.log.debug(`Found Chrome bundle '${this.bundleId}' version '${chromeVersion}'`);
|
|
345
353
|
|
|
346
354
|
const matchingDrivers = cds.filter(({minChromeVersion}) => {
|
|
347
355
|
const minChromeVersionS = minChromeVersion && semver.coerce(minChromeVersion);
|
|
@@ -360,9 +368,9 @@ class Chromedriver extends events.EventEmitter {
|
|
|
360
368
|
continue;
|
|
361
369
|
}
|
|
362
370
|
} catch (e) {
|
|
363
|
-
log.warn(`Cannot synchronize local chromedrivers with the remote storage at ${CD_CDN}: ` +
|
|
371
|
+
this.log.warn(`Cannot synchronize local chromedrivers with the remote storage at ${CD_CDN}: ` +
|
|
364
372
|
e.message);
|
|
365
|
-
log.debug(e.stack);
|
|
373
|
+
this.log.debug(e.stack);
|
|
366
374
|
}
|
|
367
375
|
}
|
|
368
376
|
const autodownloadSuggestion =
|
|
@@ -373,9 +381,9 @@ class Chromedriver extends events.EventEmitter {
|
|
|
373
381
|
}
|
|
374
382
|
|
|
375
383
|
const binPath = matchingDrivers[0].executable;
|
|
376
|
-
log.debug(`Found ${util.pluralize('executable', matchingDrivers.length, true)} ` +
|
|
384
|
+
this.log.debug(`Found ${util.pluralize('executable', matchingDrivers.length, true)} ` +
|
|
377
385
|
`capable of automating Chrome '${chromeVersion}'.\nChoosing the most recent, '${binPath}'.`);
|
|
378
|
-
log.debug('If a specific version is required, specify it with the `chromedriverExecutable`' +
|
|
386
|
+
this.log.debug('If a specific version is required, specify it with the `chromedriverExecutable`' +
|
|
379
387
|
'desired capability.');
|
|
380
388
|
return binPath;
|
|
381
389
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -399,19 +407,19 @@ class Chromedriver extends events.EventEmitter {
|
|
|
399
407
|
`${this.chromedriver}, but it doesn't exist!`);
|
|
400
408
|
}
|
|
401
409
|
this.executableVerified = true;
|
|
402
|
-
log.info(`Set chromedriver binary as: ${this.chromedriver}`);
|
|
410
|
+
this.log.info(`Set chromedriver binary as: ${this.chromedriver}`);
|
|
403
411
|
}
|
|
404
412
|
|
|
405
413
|
syncProtocol (cdVersion = null) {
|
|
406
414
|
const coercedVersion = semver.coerce(cdVersion);
|
|
407
415
|
if (!coercedVersion || coercedVersion.major < MIN_CD_VERSION_WITH_W3C_SUPPORT) {
|
|
408
|
-
log.debug(`Chromedriver v. ${cdVersion} does not fully support ${PROTOCOLS.W3C} protocol. ` +
|
|
416
|
+
this.log.debug(`Chromedriver v. ${cdVersion} does not fully support ${PROTOCOLS.W3C} protocol. ` +
|
|
409
417
|
`Defaulting to ${PROTOCOLS.MJSONWP}`);
|
|
410
418
|
return;
|
|
411
419
|
}
|
|
412
420
|
const chromeOptions = getCapValue(this.capabilities, 'chromeOptions', {});
|
|
413
421
|
if (chromeOptions.w3c === false) {
|
|
414
|
-
log.info(`Chromedriver v. ${cdVersion} supports ${PROTOCOLS.W3C} protocol, ` +
|
|
422
|
+
this.log.info(`Chromedriver v. ${cdVersion} supports ${PROTOCOLS.W3C} protocol, ` +
|
|
415
423
|
`but ${PROTOCOLS.MJSONWP} one has been explicitly requested`);
|
|
416
424
|
return;
|
|
417
425
|
}
|
|
@@ -478,7 +486,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
478
486
|
let match = /"Browser": "(.*)"/.exec(out);
|
|
479
487
|
if (match) {
|
|
480
488
|
webviewVersion = match[1];
|
|
481
|
-
log.debug(`Webview version: '${webviewVersion}'`);
|
|
489
|
+
this.log.debug(`Webview version: '${webviewVersion}'`);
|
|
482
490
|
}
|
|
483
491
|
|
|
484
492
|
// also print chromedriver version to logs
|
|
@@ -486,7 +494,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
486
494
|
// Starting ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 9515
|
|
487
495
|
match = /Starting ChromeDriver ([.\d]+)/.exec(out);
|
|
488
496
|
if (match) {
|
|
489
|
-
log.debug(`Chromedriver version: '${match[1]}'`);
|
|
497
|
+
this.log.debug(`Chromedriver version: '${match[1]}'`);
|
|
490
498
|
this.syncProtocol(match[1]);
|
|
491
499
|
}
|
|
492
500
|
|
|
@@ -494,11 +502,11 @@ class Chromedriver extends events.EventEmitter {
|
|
|
494
502
|
if (this.verbose) {
|
|
495
503
|
for (let line of (stdout || '').trim().split('\n')) {
|
|
496
504
|
if (!line.trim().length) continue; // eslint-disable-line curly
|
|
497
|
-
log.debug(`[STDOUT] ${line}`);
|
|
505
|
+
this.log.debug(`[STDOUT] ${line}`);
|
|
498
506
|
}
|
|
499
507
|
for (let line of (stderr || '').trim().split('\n')) {
|
|
500
508
|
if (!line.trim().length) continue; // eslint-disable-line curly
|
|
501
|
-
log.error(`[STDERR] ${line}`);
|
|
509
|
+
this.log.error(`[STDERR] ${line}`);
|
|
502
510
|
}
|
|
503
511
|
}
|
|
504
512
|
});
|
|
@@ -509,20 +517,18 @@ class Chromedriver extends events.EventEmitter {
|
|
|
509
517
|
if (this.state !== Chromedriver.STATE_STOPPED &&
|
|
510
518
|
this.state !== Chromedriver.STATE_STOPPING &&
|
|
511
519
|
this.state !== Chromedriver.STATE_RESTARTING) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
log.error(msg);
|
|
520
|
+
const msg = `Chromedriver exited unexpectedly with code ${code}, signal ${signal}`;
|
|
521
|
+
this.log.error(msg);
|
|
515
522
|
this.changeState(Chromedriver.STATE_STOPPED);
|
|
516
523
|
}
|
|
517
524
|
});
|
|
518
|
-
log.info(`Spawning chromedriver with: ${this.chromedriver} `
|
|
519
|
-
`${args.join(' ')}`);
|
|
525
|
+
this.log.info(`Spawning chromedriver with: ${this.chromedriver} ${args.join(' ')}`);
|
|
520
526
|
// start subproc and wait for startDetector
|
|
521
527
|
await this.proc.start(startDetector);
|
|
522
528
|
await this.waitForOnline();
|
|
523
529
|
await this.startSession();
|
|
524
530
|
} catch (e) {
|
|
525
|
-
log.debug(e);
|
|
531
|
+
this.log.debug(e);
|
|
526
532
|
this.emit(Chromedriver.EVENT_ERROR, e);
|
|
527
533
|
// just because we had an error doesn't mean the chromedriver process
|
|
528
534
|
// finished; we should clean up if necessary
|
|
@@ -545,20 +551,16 @@ class Chromedriver extends events.EventEmitter {
|
|
|
545
551
|
}
|
|
546
552
|
|
|
547
553
|
message += e.message;
|
|
548
|
-
log.errorAndThrow(message);
|
|
554
|
+
this.log.errorAndThrow(message);
|
|
549
555
|
}
|
|
550
556
|
}
|
|
551
557
|
|
|
552
558
|
sessionId () {
|
|
553
|
-
|
|
554
|
-
return null;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return this.jwproxy.sessionId;
|
|
559
|
+
return this.state === Chromedriver.STATE_ONLINE ? this.jwproxy.sessionId : null;
|
|
558
560
|
}
|
|
559
561
|
|
|
560
562
|
async restart () {
|
|
561
|
-
log.info('Restarting chromedriver');
|
|
563
|
+
this.log.info('Restarting chromedriver');
|
|
562
564
|
if (this.state !== Chromedriver.STATE_ONLINE) {
|
|
563
565
|
throw new Error("Can't restart when we're not online");
|
|
564
566
|
}
|
|
@@ -591,9 +593,10 @@ class Chromedriver extends events.EventEmitter {
|
|
|
591
593
|
const sessionCaps = this.desiredProtocol === PROTOCOLS.W3C
|
|
592
594
|
? {capabilities: {alwaysMatch: this.capabilities}}
|
|
593
595
|
: {desiredCapabilities: this.capabilities};
|
|
594
|
-
log.info(`Starting ${this.desiredProtocol} Chromedriver session with capabilities: ` +
|
|
596
|
+
this.log.info(`Starting ${this.desiredProtocol} Chromedriver session with capabilities: ` +
|
|
595
597
|
JSON.stringify(sessionCaps, null, 2));
|
|
596
598
|
await this.jwproxy.command('/session', 'POST', sessionCaps);
|
|
599
|
+
this.log.prefix = generateLogPrefix(this, this.jwproxy.sessionId);
|
|
597
600
|
this.changeState(Chromedriver.STATE_ONLINE);
|
|
598
601
|
}
|
|
599
602
|
|
|
@@ -605,12 +608,13 @@ class Chromedriver extends events.EventEmitter {
|
|
|
605
608
|
try {
|
|
606
609
|
return await f();
|
|
607
610
|
} catch (e) {
|
|
608
|
-
log.warn(e.message);
|
|
609
|
-
log.debug(e.stack);
|
|
611
|
+
this.log.warn(e.message);
|
|
612
|
+
this.log.debug(e.stack);
|
|
610
613
|
}
|
|
611
614
|
};
|
|
612
615
|
await runSafeStep(() => this.jwproxy.command('', 'DELETE'));
|
|
613
616
|
await runSafeStep(() => this.proc.stop('SIGTERM', 20000));
|
|
617
|
+
this.log.prefix = generateLogPrefix(this);
|
|
614
618
|
if (emitStates) {
|
|
615
619
|
this.changeState(Chromedriver.STATE_STOPPED);
|
|
616
620
|
}
|
|
@@ -618,7 +622,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
618
622
|
|
|
619
623
|
changeState (state) {
|
|
620
624
|
this.state = state;
|
|
621
|
-
log.debug(`Changed state to '${state}'`);
|
|
625
|
+
this.log.debug(`Changed state to '${state}'`);
|
|
622
626
|
this.emit(Chromedriver.EVENT_CHANGED, {state});
|
|
623
627
|
}
|
|
624
628
|
|
|
@@ -634,12 +638,12 @@ class Chromedriver extends events.EventEmitter {
|
|
|
634
638
|
let cmd = system.isWindows()
|
|
635
639
|
? `wmic process where "commandline like '%chromedriver.exe%--port=${this.proxyPort}%'" delete`
|
|
636
640
|
: `pkill -15 -f "${this.chromedriver}.*--port=${this.proxyPort}"`;
|
|
637
|
-
log.debug(`Killing any old chromedrivers, running: ${cmd}`);
|
|
641
|
+
this.log.debug(`Killing any old chromedrivers, running: ${cmd}`);
|
|
638
642
|
try {
|
|
639
643
|
await (B.promisify(cp.exec))(cmd);
|
|
640
|
-
log.debug('Successfully cleaned up old chromedrivers');
|
|
644
|
+
this.log.debug('Successfully cleaned up old chromedrivers');
|
|
641
645
|
} catch (err) {
|
|
642
|
-
log.warn('No old chromedrivers seem to exist');
|
|
646
|
+
this.log.warn('No old chromedrivers seem to exist');
|
|
643
647
|
}
|
|
644
648
|
|
|
645
649
|
if (this.adb) {
|
|
@@ -647,9 +651,9 @@ class Chromedriver extends events.EventEmitter {
|
|
|
647
651
|
const udid = udidIndex > -1 ? this.adb.executable.defaultArgs[udidIndex + 1] : null;
|
|
648
652
|
|
|
649
653
|
if (udid) {
|
|
650
|
-
log.debug(`Cleaning this device's adb forwarded port socket connections: ${udid}`);
|
|
654
|
+
this.log.debug(`Cleaning this device's adb forwarded port socket connections: ${udid}`);
|
|
651
655
|
} else {
|
|
652
|
-
log.debug(`Cleaning any old adb forwarded port socket connections`);
|
|
656
|
+
this.log.debug(`Cleaning any old adb forwarded port socket connections`);
|
|
653
657
|
}
|
|
654
658
|
|
|
655
659
|
try {
|
|
@@ -665,7 +669,7 @@ class Chromedriver extends events.EventEmitter {
|
|
|
665
669
|
}
|
|
666
670
|
}
|
|
667
671
|
} catch (err) {
|
|
668
|
-
log.warn(`Unable to clean forwarded ports. Error: '${err.message}'. Continuing.`);
|
|
672
|
+
this.log.warn(`Unable to clean forwarded ports. Error: '${err.message}'. Continuing.`);
|
|
669
673
|
}
|
|
670
674
|
}
|
|
671
675
|
}
|
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { system, fs } from '@appium/support';
|
|
3
|
+
import { BaseDriver } from '@appium/base-driver';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import compareVersions from 'compare-versions';
|
|
5
6
|
import axios from 'axios';
|
|
@@ -92,9 +93,22 @@ const getOsInfo = _.memoize(async function getOsInfo () {
|
|
|
92
93
|
};
|
|
93
94
|
});
|
|
94
95
|
|
|
96
|
+
const getBaseDriverInstance = _.memoize(() => new BaseDriver({}, false));
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Generates log prefix string
|
|
100
|
+
*
|
|
101
|
+
* @param {object} obj log owner instance
|
|
102
|
+
* @param {string?} sessionId Optional session identifier
|
|
103
|
+
* @returns {string}
|
|
104
|
+
*/
|
|
105
|
+
function generateLogPrefix (obj, sessionId = null) {
|
|
106
|
+
return getBaseDriverInstance().helpers.generateDriverLogPrefix(obj, sessionId);
|
|
107
|
+
}
|
|
108
|
+
|
|
95
109
|
|
|
96
110
|
export {
|
|
97
111
|
getChromeVersion, getChromedriverDir, getChromedriverBinaryPath, getOsName,
|
|
98
112
|
CD_BASE_DIR, CD_CDN, CD_VER, CHROMEDRIVER_CHROME_MAPPING, getMostRecentChromedriver,
|
|
99
|
-
retrieveData, getOsInfo, OS, X64, X86, M1_ARCH_SUFFIX,
|
|
113
|
+
retrieveData, getOsInfo, OS, X64, X86, M1_ARCH_SUFFIX, generateLogPrefix,
|
|
100
114
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"chrome",
|
|
7
7
|
"android"
|
|
8
8
|
],
|
|
9
|
-
"version": "5.0.
|
|
9
|
+
"version": "5.0.5",
|
|
10
10
|
"author": "appium",
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"repository": {
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"config/mapping.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@appium/base-driver": "^8.
|
|
38
|
+
"@appium/base-driver": "^8.4.0",
|
|
39
39
|
"@appium/support": "^2.55.3",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"@xmldom/xmldom": "^0.x",
|
|
42
42
|
"asyncbox": "^2.0.2",
|
|
43
43
|
"axios": "^0.x",
|
|
44
44
|
"bluebird": "^3.5.1",
|
|
45
|
-
"compare-versions": "^
|
|
45
|
+
"compare-versions": "^4.1.3",
|
|
46
46
|
"fancy-log": "^2.0.0",
|
|
47
47
|
"lodash": "^4.17.4",
|
|
48
48
|
"semver": "^7.0.0",
|
|
@@ -76,11 +76,13 @@
|
|
|
76
76
|
"@appium/test-support": "^1.0.0",
|
|
77
77
|
"@babel/core": "^7.16.0",
|
|
78
78
|
"@babel/eslint-parser": "^7.16.3",
|
|
79
|
+
"@semantic-release/git": "^10.0.1",
|
|
79
80
|
"chai": "^4.1.2",
|
|
80
81
|
"chai-as-promised": "^7.1.1",
|
|
81
82
|
"gulp": "^4.0.0",
|
|
82
|
-
"mocha": "^
|
|
83
|
+
"mocha": "^10.0.0",
|
|
83
84
|
"pre-commit": "^1.1.3",
|
|
85
|
+
"semantic-release": "^19.0.2",
|
|
84
86
|
"sinon": "^13.0.0"
|
|
85
87
|
}
|
|
86
88
|
}
|