appium-xcuitest-driver 7.35.1 → 8.1.0
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/CHANGELOG.md +16 -0
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +2 -16
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/driver.d.ts +12 -0
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +43 -6
- package/build/lib/driver.js.map +1 -1
- package/lib/commands/recordscreen.js +2 -20
- package/lib/driver.js +51 -7
- package/npm-shrinkwrap.json +200 -127
- package/package.json +2 -2
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import {fs, tempDir, logger, util} from 'appium/support';
|
|
3
3
|
import {SubProcess} from 'teen_process';
|
|
4
|
-
import {encodeBase64OrUpload
|
|
5
|
-
import {DEVICE_CONNECTIONS_FACTORY} from '../device-connections-factory';
|
|
4
|
+
import {encodeBase64OrUpload} from '../utils';
|
|
6
5
|
import {WDA_BASE_URL} from 'appium-webdriveragent';
|
|
7
6
|
import {waitForCondition} from 'asyncbox';
|
|
8
7
|
import url from 'url';
|
|
@@ -14,9 +13,9 @@ import url from 'url';
|
|
|
14
13
|
*/
|
|
15
14
|
const MAX_RECORDING_TIME_SEC = 4200;
|
|
16
15
|
const DEFAULT_RECORDING_TIME_SEC = 60 * 3;
|
|
17
|
-
const DEFAULT_MJPEG_SERVER_PORT = 9100;
|
|
18
16
|
const DEFAULT_FPS = 10;
|
|
19
17
|
const DEFAULT_QUALITY = 'medium';
|
|
18
|
+
const DEFAULT_MJPEG_SERVER_PORT = 9100;
|
|
20
19
|
const DEFAULT_VCODEC = 'mjpeg';
|
|
21
20
|
const MP4_EXT = '.mp4';
|
|
22
21
|
const FFMPEG_BINARY = 'ffmpeg';
|
|
@@ -52,7 +51,6 @@ export class ScreenRecorder {
|
|
|
52
51
|
const {
|
|
53
52
|
remotePort,
|
|
54
53
|
remoteUrl,
|
|
55
|
-
usePortForwarding,
|
|
56
54
|
videoFps,
|
|
57
55
|
videoType,
|
|
58
56
|
videoScale,
|
|
@@ -60,19 +58,6 @@ export class ScreenRecorder {
|
|
|
60
58
|
pixelFormat,
|
|
61
59
|
} = this.opts;
|
|
62
60
|
|
|
63
|
-
try {
|
|
64
|
-
await DEVICE_CONNECTIONS_FACTORY.requestConnection(this.udid, remotePort, {
|
|
65
|
-
devicePort: remotePort,
|
|
66
|
-
usePortForwarding,
|
|
67
|
-
});
|
|
68
|
-
} catch {
|
|
69
|
-
this.log.warn(
|
|
70
|
-
`Cannot forward the local port ${remotePort} to ${remotePort} ` +
|
|
71
|
-
`on the device ${this.udid}. Set the custom value to 'mjpegServerPort' ` +
|
|
72
|
-
`capability if this is an undesired behavior.`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
61
|
const args = [
|
|
77
62
|
'-f',
|
|
78
63
|
'mjpeg',
|
|
@@ -167,8 +152,6 @@ export class ScreenRecorder {
|
|
|
167
152
|
}
|
|
168
153
|
}
|
|
169
154
|
|
|
170
|
-
DEVICE_CONNECTIONS_FACTORY.releaseConnection(this.udid, this.opts.remotePort);
|
|
171
|
-
|
|
172
155
|
return result;
|
|
173
156
|
}
|
|
174
157
|
|
|
@@ -232,7 +215,6 @@ export default {
|
|
|
232
215
|
const screenRecorder = new ScreenRecorder(this.device.udid, this.log, videoPath, {
|
|
233
216
|
remotePort: this.opts.mjpegServerPort || DEFAULT_MJPEG_SERVER_PORT,
|
|
234
217
|
remoteUrl: wdaBaseUrl,
|
|
235
|
-
usePortForwarding: this.isRealDevice() && isLocalHost(wdaBaseUrl),
|
|
236
218
|
videoType,
|
|
237
219
|
videoFilters,
|
|
238
220
|
videoScale,
|
package/lib/driver.js
CHANGED
|
@@ -103,6 +103,8 @@ const DEFAULT_SETTINGS = {
|
|
|
103
103
|
const SHARED_RESOURCES_GUARD = new AsyncLock();
|
|
104
104
|
const WEB_ELEMENTS_CACHE_SIZE = 500;
|
|
105
105
|
const SUPPORTED_ORIENATIONS = ['LANDSCAPE', 'PORTRAIT'];
|
|
106
|
+
const DEFAULT_MJPEG_SERVER_PORT = 9100;
|
|
107
|
+
|
|
106
108
|
/* eslint-disable no-useless-escape */
|
|
107
109
|
/** @type {import('@appium/types').RouteMatcher[]} */
|
|
108
110
|
const NO_PROXY_NATIVE_LIST = [
|
|
@@ -467,12 +469,8 @@ export class XCUITestDriver extends BaseDriver {
|
|
|
467
469
|
// ensure WDA gets our defaults instead of whatever its own might be
|
|
468
470
|
await this.updateSettings(wdaSettings);
|
|
469
471
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this.log.info(`Starting MJPEG stream reading URL: '${this.opts.mjpegScreenshotUrl}'`);
|
|
473
|
-
this.mjpegStream = new mjpeg.MJpegStream(this.opts.mjpegScreenshotUrl);
|
|
474
|
-
await this.mjpegStream.start();
|
|
475
|
-
}
|
|
472
|
+
await this.handleMjpegOptions();
|
|
473
|
+
|
|
476
474
|
return /** @type {[string, import('@appium/types').DriverCaps<XCUITestDriverConstraints>]} */ ([
|
|
477
475
|
sessionId,
|
|
478
476
|
caps,
|
|
@@ -484,6 +482,53 @@ export class XCUITestDriver extends BaseDriver {
|
|
|
484
482
|
}
|
|
485
483
|
}
|
|
486
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Handles MJPEG server-related capabilities
|
|
487
|
+
* @returns {Promise<void>}
|
|
488
|
+
*/
|
|
489
|
+
async handleMjpegOptions() {
|
|
490
|
+
await this.allocateMjpegServerPort();
|
|
491
|
+
// turn on mjpeg stream reading if requested
|
|
492
|
+
if (this.opts.mjpegScreenshotUrl) {
|
|
493
|
+
this.log.info(`Starting MJPEG stream reading URL: '${this.opts.mjpegScreenshotUrl}'`);
|
|
494
|
+
this.mjpegStream = new mjpeg.MJpegStream(this.opts.mjpegScreenshotUrl);
|
|
495
|
+
await this.mjpegStream.start();
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Allocates and configures port forwarding for the MJPEG server
|
|
501
|
+
* @returns {Promise<void>}
|
|
502
|
+
* @throws {Error} If port forwarding fails and mjpegServerPort capability value is provided explicitly
|
|
503
|
+
*/
|
|
504
|
+
async allocateMjpegServerPort() {
|
|
505
|
+
const mjpegServerPort = this.opts.mjpegServerPort || DEFAULT_MJPEG_SERVER_PORT;
|
|
506
|
+
this.log.debug(
|
|
507
|
+
`Forwarding MJPEG server port ${mjpegServerPort} to local port ${mjpegServerPort}`,
|
|
508
|
+
);
|
|
509
|
+
try {
|
|
510
|
+
await DEVICE_CONNECTIONS_FACTORY.requestConnection(this.opts.udid, mjpegServerPort, {
|
|
511
|
+
devicePort: mjpegServerPort,
|
|
512
|
+
usePortForwarding: this.isRealDevice(),
|
|
513
|
+
});
|
|
514
|
+
} catch (error) {
|
|
515
|
+
if (_.isUndefined(this.opts.mjpegServerPort)) {
|
|
516
|
+
this.log.warn(
|
|
517
|
+
`Cannot forward the device port ${DEFAULT_MJPEG_SERVER_PORT} to the local port ${DEFAULT_MJPEG_SERVER_PORT}. ` +
|
|
518
|
+
`Certain features, like MJPEG-based screen recording, will be unavailable during this session. ` +
|
|
519
|
+
`Try to customize the value of 'mjpegServerPort' capability as a possible solution`,
|
|
520
|
+
);
|
|
521
|
+
} else {
|
|
522
|
+
this.log.debug(error.stack);
|
|
523
|
+
throw new Error(
|
|
524
|
+
`Cannot ensure MJPEG broadcast functionality by forwarding the local port ${mjpegServerPort} ` +
|
|
525
|
+
`requested by the 'mjpegServerPort' capability to the device port ${mjpegServerPort}. ` +
|
|
526
|
+
`Original error: ${error}`,
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
487
532
|
/**
|
|
488
533
|
* Returns the default URL for Safari browser
|
|
489
534
|
* @returns {string} The default URL
|
|
@@ -1025,7 +1070,6 @@ export class XCUITestDriver extends BaseDriver {
|
|
|
1025
1070
|
await this.wda.quit();
|
|
1026
1071
|
}
|
|
1027
1072
|
}
|
|
1028
|
-
|
|
1029
1073
|
DEVICE_CONNECTIONS_FACTORY.releaseConnection(this.opts.udid);
|
|
1030
1074
|
}
|
|
1031
1075
|
|