appium-webdriveragent 11.1.4 → 11.1.6
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 +12 -0
- package/WebDriverAgent.xcodeproj/project.pbxproj +14 -5
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationApp.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_1.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_2.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/IntegrationTests_3.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentLib.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentLib_tvOS.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner-nodebug.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner.xcscheme +1 -1
- package/WebDriverAgent.xcodeproj/xcshareddata/xcschemes/WebDriverAgentRunner_tvOS.xcscheme +1 -1
- package/WebDriverAgentLib/Info.plist +2 -2
- package/build/lib/check-dependencies.d.ts.map +1 -1
- package/build/lib/check-dependencies.js +6 -3
- package/build/lib/check-dependencies.js.map +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/no-session-proxy.d.ts.map +1 -1
- package/build/lib/no-session-proxy.js +1 -1
- package/build/lib/no-session-proxy.js.map +1 -1
- package/build/lib/types.d.ts.map +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +8 -9
- package/build/lib/utils.js.map +1 -1
- package/build/lib/webdriveragent.d.ts.map +1 -1
- package/build/lib/webdriveragent.js +21 -20
- package/build/lib/webdriveragent.js.map +1 -1
- package/build/lib/xcodebuild.d.ts.map +1 -1
- package/build/lib/xcodebuild.js +16 -19
- package/build/lib/xcodebuild.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/check-dependencies.ts +20 -14
- package/lib/constants.ts +0 -1
- package/lib/logger.ts +1 -1
- package/lib/no-session-proxy.ts +5 -7
- package/lib/types.ts +6 -1
- package/lib/utils.ts +80 -52
- package/lib/webdriveragent.ts +189 -134
- package/lib/xcodebuild.ts +62 -54
- package/package.json +3 -2
package/lib/xcodebuild.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
1
|
+
import {retryInterval} from 'asyncbox';
|
|
2
|
+
import {SubProcess, exec} from 'teen_process';
|
|
3
|
+
import {logger, timing} from '@appium/support';
|
|
4
|
+
import type {AppiumLogger, StringRecord} from '@appium/types';
|
|
5
|
+
import {log as defaultLogger} from './logger';
|
|
6
6
|
import B from 'bluebird';
|
|
7
7
|
import {
|
|
8
|
-
setRealDeviceSecurity,
|
|
9
|
-
|
|
8
|
+
setRealDeviceSecurity,
|
|
9
|
+
setXctestrunFile,
|
|
10
|
+
killProcess,
|
|
11
|
+
getWDAUpgradeTimestamp,
|
|
12
|
+
isTvOS,
|
|
10
13
|
} from './utils';
|
|
11
14
|
import _ from 'lodash';
|
|
12
15
|
import path from 'node:path';
|
|
13
|
-
import {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
|
|
16
|
+
import {WDA_RUNNER_BUNDLE_ID} from './constants';
|
|
17
|
+
import type {AppleDevice, XcodeBuildArgs} from './types';
|
|
18
|
+
import type {NoSessionProxy} from './no-session-proxy';
|
|
17
19
|
|
|
18
20
|
const DEFAULT_SIGNING_ID = 'iPhone Developer';
|
|
19
21
|
const PREBUILD_DELAY = 0;
|
|
@@ -28,21 +30,17 @@ const IGNORED_ERRORS = [
|
|
|
28
30
|
'Failed to remove screenshot at path',
|
|
29
31
|
];
|
|
30
32
|
const IGNORED_ERRORS_PATTERN = new RegExp(
|
|
31
|
-
'(' +
|
|
32
|
-
IGNORED_ERRORS
|
|
33
|
-
.map((errStr) => _.escapeRegExp(errStr))
|
|
34
|
-
.join('|') +
|
|
35
|
-
')'
|
|
33
|
+
'(' + IGNORED_ERRORS.map((errStr) => _.escapeRegExp(errStr)).join('|') + ')',
|
|
36
34
|
);
|
|
37
35
|
|
|
38
36
|
const RUNNER_SCHEME_TV = 'WebDriverAgentRunner_tvOS';
|
|
39
37
|
const LIB_SCHEME_TV = 'WebDriverAgentLib_tvOS';
|
|
40
38
|
|
|
41
|
-
const REAL_DEVICES_CONFIG_DOCS_LINK =
|
|
39
|
+
const REAL_DEVICES_CONFIG_DOCS_LINK =
|
|
40
|
+
'https://appium.github.io/appium-xcuitest-driver/latest/preparation/real-device-config/';
|
|
42
41
|
|
|
43
42
|
const xcodeLog = logger.getLogger('Xcode');
|
|
44
43
|
|
|
45
|
-
|
|
46
44
|
export class XcodeBuild {
|
|
47
45
|
xcodebuild?: SubProcess;
|
|
48
46
|
readonly device: AppleDevice;
|
|
@@ -85,7 +83,7 @@ export class XcodeBuild {
|
|
|
85
83
|
* @param args - Configuration arguments for xcodebuild
|
|
86
84
|
* @param log - Optional logger instance
|
|
87
85
|
*/
|
|
88
|
-
constructor
|
|
86
|
+
constructor(device: AppleDevice, args: XcodeBuildArgs, log: AppiumLogger | null = null) {
|
|
89
87
|
this.device = device;
|
|
90
88
|
this.log = log ?? defaultLogger;
|
|
91
89
|
|
|
@@ -137,7 +135,7 @@ export class XcodeBuild {
|
|
|
137
135
|
* Sets up xctestrun file if needed.
|
|
138
136
|
* @param noSessionProxy - The proxy instance for WDA communication
|
|
139
137
|
*/
|
|
140
|
-
async init
|
|
138
|
+
async init(noSessionProxy: NoSessionProxy): Promise<void> {
|
|
141
139
|
this.noSessionProxy = noSessionProxy;
|
|
142
140
|
|
|
143
141
|
if (this.useXctestrunFile) {
|
|
@@ -145,15 +143,15 @@ export class XcodeBuild {
|
|
|
145
143
|
isRealDevice: !!this.realDevice,
|
|
146
144
|
udid: this.device.udid,
|
|
147
145
|
platformVersion: this.platformVersion || '',
|
|
148
|
-
platformName: this.platformName || ''
|
|
146
|
+
platformName: this.platformName || '',
|
|
149
147
|
};
|
|
150
148
|
this.xctestrunFilePath = await setXctestrunFile({
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
149
|
+
deviceInfo,
|
|
150
|
+
sdkVersion: this.iosSdkVersion || '',
|
|
151
|
+
bootstrapPath: this.bootstrapPath,
|
|
152
|
+
wdaRemotePort: this.wdaRemotePort || 8100,
|
|
153
|
+
wdaBindingIP: this.wdaBindingIP,
|
|
154
|
+
});
|
|
157
155
|
return;
|
|
158
156
|
}
|
|
159
157
|
}
|
|
@@ -163,7 +161,7 @@ export class XcodeBuild {
|
|
|
163
161
|
* Uses cached value if available, otherwise queries xcodebuild for BUILD_DIR.
|
|
164
162
|
* @returns The derived data path, or `undefined` if it cannot be determined
|
|
165
163
|
*/
|
|
166
|
-
async retrieveDerivedDataPath
|
|
164
|
+
async retrieveDerivedDataPath(): Promise<string | undefined> {
|
|
167
165
|
if (this.derivedDataPath) {
|
|
168
166
|
return this.derivedDataPath;
|
|
169
167
|
}
|
|
@@ -201,7 +199,7 @@ export class XcodeBuild {
|
|
|
201
199
|
* Pre-builds WebDriverAgent before launching tests.
|
|
202
200
|
* Performs a build-only operation and sets usePrebuiltWDA flag.
|
|
203
201
|
*/
|
|
204
|
-
async prebuild
|
|
202
|
+
async prebuild(): Promise<void> {
|
|
205
203
|
// first do a build phase
|
|
206
204
|
this.log.debug('Pre-building WDA before launching test');
|
|
207
205
|
this.usePrebuiltWDA = true;
|
|
@@ -217,17 +215,15 @@ export class XcodeBuild {
|
|
|
217
215
|
* Cleans the Xcode project to remove leftovers from previous installs.
|
|
218
216
|
* Cleans both the library and runner schemes for the appropriate platform.
|
|
219
217
|
*/
|
|
220
|
-
async cleanProject
|
|
218
|
+
async cleanProject(): Promise<void> {
|
|
221
219
|
const libScheme = isTvOS(this.platformName || '') ? LIB_SCHEME_TV : LIB_SCHEME_IOS;
|
|
222
220
|
const runnerScheme = isTvOS(this.platformName || '') ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
|
|
223
221
|
|
|
224
222
|
for (const scheme of [libScheme, runnerScheme]) {
|
|
225
|
-
this.log.debug(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
'-scheme', scheme,
|
|
230
|
-
]);
|
|
223
|
+
this.log.debug(
|
|
224
|
+
`Cleaning the project scheme '${scheme}' to make sure there are no leftovers from previous installs`,
|
|
225
|
+
);
|
|
226
|
+
await exec('xcodebuild', ['clean', '-project', this.agentPath, '-scheme', scheme]);
|
|
231
227
|
}
|
|
232
228
|
}
|
|
233
229
|
|
|
@@ -237,7 +233,7 @@ export class XcodeBuild {
|
|
|
237
233
|
* @returns The WDA status record if tests are run, `void` if build-only
|
|
238
234
|
* @throws Error if xcodebuild fails or cannot start
|
|
239
235
|
*/
|
|
240
|
-
async start
|
|
236
|
+
async start(buildOnly: boolean = false): Promise<StringRecord | void> {
|
|
241
237
|
this.xcodebuild = await this.createSubProcess(buildOnly);
|
|
242
238
|
|
|
243
239
|
// wrap the start procedure in a promise so that we can catch, and report,
|
|
@@ -247,19 +243,22 @@ export class XcodeBuild {
|
|
|
247
243
|
}
|
|
248
244
|
const xcodebuild = this.xcodebuild;
|
|
249
245
|
return await new B((resolve, reject) => {
|
|
250
|
-
|
|
246
|
+
xcodebuild.once('exit', (code, signal) => {
|
|
251
247
|
xcodeLog.error(`xcodebuild exited with code '${code}' and signal '${signal}'`);
|
|
252
248
|
xcodebuild.removeAllListeners();
|
|
253
249
|
this._didProcessExit = true;
|
|
254
250
|
if (this._didBuildFail || (!signal && code !== 0)) {
|
|
255
|
-
let errorMessage =
|
|
251
|
+
let errorMessage =
|
|
252
|
+
`xcodebuild failed with code ${code}.` +
|
|
256
253
|
` This usually indicates an issue with the local Xcode setup or WebDriverAgent` +
|
|
257
254
|
` project configuration or the driver-to-platform version mismatch.`;
|
|
258
255
|
if (!this.showXcodeLog) {
|
|
259
|
-
errorMessage +=
|
|
256
|
+
errorMessage +=
|
|
257
|
+
` Consider setting 'showXcodeLog' capability to true in` +
|
|
260
258
|
` order to check the Appium server log for build-related error messages.`;
|
|
261
259
|
} else if (this.realDevice) {
|
|
262
|
-
errorMessage +=
|
|
260
|
+
errorMessage +=
|
|
261
|
+
` Consider checking the WebDriverAgent configuration guide` +
|
|
263
262
|
` for real iOS devices at ${REAL_DEVICES_CONFIG_DOCS_LINK}.`;
|
|
264
263
|
}
|
|
265
264
|
return reject(new Error(errorMessage));
|
|
@@ -293,16 +292,18 @@ export class XcodeBuild {
|
|
|
293
292
|
/**
|
|
294
293
|
* Stops the xcodebuild process and cleans up resources.
|
|
295
294
|
*/
|
|
296
|
-
async quit
|
|
295
|
+
async quit(): Promise<void> {
|
|
297
296
|
await killProcess('xcodebuild', this.xcodebuild);
|
|
298
297
|
}
|
|
299
298
|
|
|
300
|
-
private getCommand
|
|
299
|
+
private getCommand(buildOnly: boolean = false): {cmd: string; args: string[]} {
|
|
301
300
|
const cmd = 'xcodebuild';
|
|
302
301
|
const args: string[] = [];
|
|
303
302
|
|
|
304
303
|
// figure out the targets for xcodebuild
|
|
305
|
-
const [buildCmd, testCmd] = this.useSimpleBuildTest
|
|
304
|
+
const [buildCmd, testCmd] = this.useSimpleBuildTest
|
|
305
|
+
? ['build', 'test']
|
|
306
|
+
: ['build-for-testing', 'test-without-building'];
|
|
306
307
|
if (buildOnly) {
|
|
307
308
|
args.push(buildCmd);
|
|
308
309
|
} else if (this.usePrebuiltWDA || this.useXctestrunFile) {
|
|
@@ -336,14 +337,17 @@ export class XcodeBuild {
|
|
|
336
337
|
args.push('-destination', `id=${this.device.udid}`);
|
|
337
338
|
|
|
338
339
|
let versionMatch: RegExpMatchArray | null = null;
|
|
339
|
-
if (
|
|
340
|
+
if (
|
|
341
|
+
this.platformVersion &&
|
|
342
|
+
(versionMatch = new RegExp(/^(\d+)\.(\d+)/).exec(this.platformVersion))
|
|
343
|
+
) {
|
|
340
344
|
args.push(
|
|
341
|
-
`${isTvOS(this.platformName || '') ? 'TV' : 'IPHONE'}OS_DEPLOYMENT_TARGET=${versionMatch[1]}.${versionMatch[2]}
|
|
345
|
+
`${isTvOS(this.platformName || '') ? 'TV' : 'IPHONE'}OS_DEPLOYMENT_TARGET=${versionMatch[1]}.${versionMatch[2]}`,
|
|
342
346
|
);
|
|
343
347
|
} else {
|
|
344
348
|
this.log.warn(
|
|
345
349
|
`Cannot parse major and minor version numbers from platformVersion "${this.platformVersion}". ` +
|
|
346
|
-
|
|
350
|
+
'Will build for the default platform instead',
|
|
347
351
|
);
|
|
348
352
|
}
|
|
349
353
|
|
|
@@ -375,7 +379,7 @@ export class XcodeBuild {
|
|
|
375
379
|
return {cmd, args};
|
|
376
380
|
}
|
|
377
381
|
|
|
378
|
-
private async createSubProcess
|
|
382
|
+
private async createSubProcess(buildOnly: boolean = false): Promise<SubProcess> {
|
|
379
383
|
if (!this.useXctestrunFile && this.realDevice) {
|
|
380
384
|
if (this.keychainPath && this.keychainPassword) {
|
|
381
385
|
await setRealDeviceSecurity(this.keychainPath, this.keychainPassword);
|
|
@@ -383,8 +387,10 @@ export class XcodeBuild {
|
|
|
383
387
|
}
|
|
384
388
|
|
|
385
389
|
const {cmd, args} = this.getCommand(buildOnly);
|
|
386
|
-
this.log.debug(
|
|
387
|
-
`
|
|
390
|
+
this.log.debug(
|
|
391
|
+
`Beginning ${buildOnly ? 'build' : 'test'} with command '${cmd} ${args.join(' ')}' ` +
|
|
392
|
+
`in directory '${this.bootstrapPath}'`,
|
|
393
|
+
);
|
|
388
394
|
const env: Record<string, any> = Object.assign({}, process.env, {
|
|
389
395
|
USE_PORT: this.wdaRemotePort,
|
|
390
396
|
WDA_PRODUCT_BUNDLE_IDENTIFIER: this.updatedWDABundleId || WDA_RUNNER_BUNDLE_ID,
|
|
@@ -437,7 +443,7 @@ export class XcodeBuild {
|
|
|
437
443
|
return xcodebuild;
|
|
438
444
|
}
|
|
439
445
|
|
|
440
|
-
private async waitForStart
|
|
446
|
+
private async waitForStart(timer: timing.Timer): Promise<StringRecord | null> {
|
|
441
447
|
// try to connect once every 0.5 seconds, until `launchTimeout` is up
|
|
442
448
|
const timeout = this.launchTimeout || 60000; // Default to 60 seconds if not set
|
|
443
449
|
this.log.debug(`Waiting up to ${timeout}ms for WebDriverAgent to start`);
|
|
@@ -457,7 +463,7 @@ export class XcodeBuild {
|
|
|
457
463
|
const proxyTimeout = noSessionProxy.timeout;
|
|
458
464
|
noSessionProxy.timeout = 1000;
|
|
459
465
|
try {
|
|
460
|
-
currentStatus = await noSessionProxy.command('/status', 'GET') as StringRecord;
|
|
466
|
+
currentStatus = (await noSessionProxy.command('/status', 'GET')) as StringRecord;
|
|
461
467
|
if (currentStatus && currentStatus.ios && (currentStatus.ios as any).ip) {
|
|
462
468
|
this.agentUrl = (currentStatus.ios as any).ip;
|
|
463
469
|
}
|
|
@@ -475,12 +481,14 @@ export class XcodeBuild {
|
|
|
475
481
|
return currentStatus;
|
|
476
482
|
}
|
|
477
483
|
|
|
478
|
-
this.log.debug(
|
|
484
|
+
this.log.debug(
|
|
485
|
+
`WebDriverAgent successfully started after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`,
|
|
486
|
+
);
|
|
479
487
|
} catch (err: any) {
|
|
480
488
|
this.log.debug(err.stack);
|
|
481
489
|
throw new Error(
|
|
482
490
|
`We were not able to retrieve the /status response from the WebDriverAgent server after ${timeout}ms timeout.` +
|
|
483
|
-
|
|
491
|
+
`Try to increase the value of 'appium:wdaLaunchTimeout' capability as a possible workaround.`,
|
|
484
492
|
);
|
|
485
493
|
}
|
|
486
494
|
return currentStatus;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-webdriveragent",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.6",
|
|
4
4
|
"description": "Package bundling WebDriverAgent",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
"dev": "npm run build -- --watch",
|
|
10
10
|
"clean": "npm run build -- --clean",
|
|
11
11
|
"lint": "eslint .",
|
|
12
|
-
"format": "prettier -w ./lib",
|
|
13
12
|
"lint:fix": "npm run lint -- --fix",
|
|
13
|
+
"format": "prettier -w ./lib ./test",
|
|
14
|
+
"format:check": "prettier --check ./lib ./test",
|
|
14
15
|
"prepare": "npm run build",
|
|
15
16
|
"version": "npm run sync-wda-version",
|
|
16
17
|
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.ts\"",
|