appium-webdriveragent 10.5.3 → 11.0.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 +23 -0
- package/Scripts/{build-webdriveragent.js → build-webdriveragent.mjs} +13 -7
- package/Scripts/{fetch-prebuilt-wda.js → fetch-prebuilt-wda.mjs} +17 -9
- package/Scripts/update-wda-version.mjs +42 -0
- package/WebDriverAgentLib/Info.plist +2 -2
- package/WebDriverAgentLib/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +6503 -6229
- package/WebDriverAgentLib/Vendor/CocoaAsyncSocket/GCDAsyncUdpSocket.m +4107 -3883
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -2
- package/build/index.js.map +1 -1
- package/build/lib/check-dependencies.d.ts +2 -7
- package/build/lib/check-dependencies.d.ts.map +1 -1
- package/build/lib/check-dependencies.js +0 -11
- package/build/lib/check-dependencies.js.map +1 -1
- package/build/lib/constants.d.ts +12 -12
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +14 -26
- package/build/lib/constants.js.map +1 -1
- package/build/lib/logger.d.ts +1 -2
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +2 -2
- package/build/lib/logger.js.map +1 -1
- package/build/lib/no-session-proxy.d.ts +5 -5
- package/build/lib/no-session-proxy.d.ts.map +1 -1
- package/build/lib/no-session-proxy.js +0 -1
- package/build/lib/no-session-proxy.js.map +1 -1
- package/build/lib/utils.d.ts +53 -96
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +124 -110
- package/build/lib/utils.js.map +1 -1
- package/build/lib/webdriveragent.d.ts +123 -170
- package/build/lib/webdriveragent.d.ts.map +1 -1
- package/build/lib/webdriveragent.js +319 -349
- package/build/lib/webdriveragent.js.map +1 -1
- package/build/lib/xcodebuild.d.ts +66 -77
- package/build/lib/xcodebuild.d.ts.map +1 -1
- package/build/lib/xcodebuild.js +123 -92
- package/build/lib/xcodebuild.js.map +1 -1
- package/build/test/functional/desired.d.ts +3 -0
- package/build/test/functional/desired.d.ts.map +1 -0
- package/build/test/functional/desired.js +9 -0
- package/build/test/functional/desired.js.map +1 -0
- package/build/test/functional/helpers/simulator.d.ts +5 -0
- package/build/test/functional/helpers/simulator.d.ts.map +1 -0
- package/build/test/functional/helpers/simulator.js +39 -0
- package/build/test/functional/helpers/simulator.js.map +1 -0
- package/build/test/functional/webdriveragent-e2e-specs.d.ts +2 -0
- package/build/test/functional/webdriveragent-e2e-specs.d.ts.map +1 -0
- package/build/test/functional/webdriveragent-e2e-specs.js +133 -0
- package/build/test/functional/webdriveragent-e2e-specs.js.map +1 -0
- package/build/test/unit/utils-specs.d.ts +2 -0
- package/build/test/unit/utils-specs.d.ts.map +1 -0
- package/build/test/unit/utils-specs.js +161 -0
- package/build/test/unit/utils-specs.js.map +1 -0
- package/build/test/unit/webdriveragent-specs.d.ts +2 -0
- package/build/test/unit/webdriveragent-specs.d.ts.map +1 -0
- package/build/test/unit/webdriveragent-specs.js +424 -0
- package/build/test/unit/webdriveragent-specs.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/index.ts +1 -1
- package/lib/{check-dependencies.js → check-dependencies.ts} +4 -13
- package/lib/constants.ts +18 -0
- package/lib/logger.ts +3 -0
- package/lib/{no-session-proxy.js → no-session-proxy.ts} +4 -5
- package/lib/{utils.js → utils.ts} +101 -111
- package/lib/{webdriveragent.js → webdriveragent.ts} +353 -390
- package/lib/{xcodebuild.js → xcodebuild.ts} +145 -114
- package/package.json +7 -9
- package/lib/constants.js +0 -24
- package/lib/logger.js +0 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { retryInterval } from 'asyncbox';
|
|
2
2
|
import { SubProcess, exec } from 'teen_process';
|
|
3
3
|
import { logger, timing } from '@appium/support';
|
|
4
|
-
import
|
|
4
|
+
import type { AppiumLogger, StringRecord } from '@appium/types';
|
|
5
|
+
import { log as defaultLogger } from './logger';
|
|
5
6
|
import B from 'bluebird';
|
|
6
7
|
import {
|
|
7
8
|
setRealDeviceSecurity, setXctestrunFile,
|
|
@@ -11,6 +12,8 @@ import {
|
|
|
11
12
|
import _ from 'lodash';
|
|
12
13
|
import path from 'path';
|
|
13
14
|
import { WDA_RUNNER_BUNDLE_ID } from './constants';
|
|
15
|
+
import type { AppleDevice, XcodeBuildArgs } from './types';
|
|
16
|
+
import type { NoSessionProxy } from './no-session-proxy';
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
const DEFAULT_SIGNING_ID = 'iPhone Developer';
|
|
@@ -42,18 +45,48 @@ const xcodeLog = logger.getLogger('Xcode');
|
|
|
42
45
|
|
|
43
46
|
|
|
44
47
|
export class XcodeBuild {
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
xcodebuild?: SubProcess;
|
|
49
|
+
readonly device: AppleDevice;
|
|
50
|
+
private readonly log: AppiumLogger;
|
|
51
|
+
readonly realDevice: boolean;
|
|
52
|
+
readonly agentPath: string;
|
|
53
|
+
readonly bootstrapPath: string;
|
|
54
|
+
readonly platformVersion?: string;
|
|
55
|
+
readonly platformName?: string;
|
|
56
|
+
readonly iosSdkVersion?: string;
|
|
57
|
+
private readonly showXcodeLog?: boolean;
|
|
58
|
+
private readonly xcodeConfigFile?: string;
|
|
59
|
+
private readonly xcodeOrgId?: string;
|
|
60
|
+
readonly xcodeSigningId: string;
|
|
61
|
+
private readonly keychainPath?: string;
|
|
62
|
+
private readonly keychainPassword?: string;
|
|
63
|
+
usePrebuiltWDA?: boolean;
|
|
64
|
+
private readonly useSimpleBuildTest?: boolean;
|
|
65
|
+
private readonly useXctestrunFile?: boolean;
|
|
66
|
+
private readonly launchTimeout?: number;
|
|
67
|
+
private readonly wdaRemotePort?: number;
|
|
68
|
+
private readonly wdaBindingIP?: string;
|
|
69
|
+
private readonly updatedWDABundleId?: string;
|
|
70
|
+
derivedDataPath?: string;
|
|
71
|
+
private readonly mjpegServerPort?: number;
|
|
72
|
+
private readonly prebuildDelay: number;
|
|
73
|
+
private readonly allowProvisioningDeviceRegistration?: boolean;
|
|
74
|
+
private readonly resultBundlePath?: string;
|
|
75
|
+
private readonly resultBundleVersion?: string;
|
|
76
|
+
private _didBuildFail: boolean;
|
|
77
|
+
private _didProcessExit: boolean;
|
|
78
|
+
private _derivedDataPathPromise?: Promise<string | undefined>;
|
|
79
|
+
private noSessionProxy?: NoSessionProxy;
|
|
80
|
+
private xctestrunFilePath?: string;
|
|
81
|
+
agentUrl?: string;
|
|
47
82
|
|
|
48
83
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
84
|
+
* Creates a new XcodeBuild instance.
|
|
85
|
+
* @param device - The Apple device to build for
|
|
86
|
+
* @param args - Configuration arguments for xcodebuild
|
|
87
|
+
* @param log - Optional logger instance
|
|
53
88
|
*/
|
|
54
|
-
constructor (
|
|
55
|
-
this.xcodeVersion = xcodeVersion;
|
|
56
|
-
|
|
89
|
+
constructor (device: AppleDevice, args: XcodeBuildArgs, log: AppiumLogger | null = null) {
|
|
57
90
|
this.device = device;
|
|
58
91
|
this.log = log ?? defaultLogger;
|
|
59
92
|
|
|
@@ -74,7 +107,6 @@ export class XcodeBuild {
|
|
|
74
107
|
this.keychainPath = args.keychainPath;
|
|
75
108
|
this.keychainPassword = args.keychainPassword;
|
|
76
109
|
|
|
77
|
-
this.prebuildWDA = args.prebuildWDA;
|
|
78
110
|
this.usePrebuiltWDA = args.usePrebuiltWDA;
|
|
79
111
|
this.useSimpleBuildTest = args.useSimpleBuildTest;
|
|
80
112
|
|
|
@@ -102,15 +134,14 @@ export class XcodeBuild {
|
|
|
102
134
|
}
|
|
103
135
|
|
|
104
136
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @
|
|
137
|
+
* Initializes the XcodeBuild instance with a no-session proxy.
|
|
138
|
+
* Sets up xctestrun file if needed, or updates project bundle ID for real devices.
|
|
139
|
+
* @param noSessionProxy - The proxy instance for WDA communication
|
|
108
140
|
*/
|
|
109
|
-
async init (noSessionProxy) {
|
|
141
|
+
async init (noSessionProxy: NoSessionProxy): Promise<void> {
|
|
110
142
|
this.noSessionProxy = noSessionProxy;
|
|
111
143
|
|
|
112
144
|
if (this.useXctestrunFile) {
|
|
113
|
-
/** @type {import('./types').DeviceInfo} */
|
|
114
145
|
const deviceInfo = {
|
|
115
146
|
isRealDevice: !!this.realDevice,
|
|
116
147
|
udid: this.device.udid,
|
|
@@ -142,9 +173,11 @@ export class XcodeBuild {
|
|
|
142
173
|
}
|
|
143
174
|
|
|
144
175
|
/**
|
|
145
|
-
*
|
|
176
|
+
* Retrieves the Xcode derived data path for the build.
|
|
177
|
+
* Uses cached value if available, otherwise queries xcodebuild for BUILD_DIR.
|
|
178
|
+
* @returns The derived data path, or `undefined` if it cannot be determined
|
|
146
179
|
*/
|
|
147
|
-
async retrieveDerivedDataPath () {
|
|
180
|
+
async retrieveDerivedDataPath (): Promise<string | undefined> {
|
|
148
181
|
if (this.derivedDataPath) {
|
|
149
182
|
return this.derivedDataPath;
|
|
150
183
|
}
|
|
@@ -155,10 +188,10 @@ export class XcodeBuild {
|
|
|
155
188
|
}
|
|
156
189
|
|
|
157
190
|
this._derivedDataPathPromise = (async () => {
|
|
158
|
-
let stdout;
|
|
191
|
+
let stdout: string;
|
|
159
192
|
try {
|
|
160
193
|
({stdout} = await exec('xcodebuild', ['-project', this.agentPath, '-showBuildSettings']));
|
|
161
|
-
} catch (err) {
|
|
194
|
+
} catch (err: any) {
|
|
162
195
|
this.log.warn(`Cannot retrieve WDA build settings. Original error: ${err.message}`);
|
|
163
196
|
return;
|
|
164
197
|
}
|
|
@@ -179,9 +212,10 @@ export class XcodeBuild {
|
|
|
179
212
|
}
|
|
180
213
|
|
|
181
214
|
/**
|
|
182
|
-
*
|
|
215
|
+
* Resets the project file to its original state.
|
|
216
|
+
* Restores the bundle ID to the original value for real devices if it was modified.
|
|
183
217
|
*/
|
|
184
|
-
async reset () {
|
|
218
|
+
async reset (): Promise<void> {
|
|
185
219
|
// if necessary, reset the bundleId to original value
|
|
186
220
|
if (this.realDevice && this.updatedWDABundleId) {
|
|
187
221
|
await resetProjectFile(this.agentPath);
|
|
@@ -189,9 +223,10 @@ export class XcodeBuild {
|
|
|
189
223
|
}
|
|
190
224
|
|
|
191
225
|
/**
|
|
192
|
-
*
|
|
226
|
+
* Pre-builds WebDriverAgent before launching tests.
|
|
227
|
+
* Performs a build-only operation and sets usePrebuiltWDA flag.
|
|
193
228
|
*/
|
|
194
|
-
async prebuild () {
|
|
229
|
+
async prebuild (): Promise<void> {
|
|
195
230
|
// first do a build phase
|
|
196
231
|
this.log.debug('Pre-building WDA before launching test');
|
|
197
232
|
this.usePrebuiltWDA = true;
|
|
@@ -204,9 +239,10 @@ export class XcodeBuild {
|
|
|
204
239
|
}
|
|
205
240
|
|
|
206
241
|
/**
|
|
207
|
-
*
|
|
242
|
+
* Cleans the Xcode project to remove leftovers from previous installs.
|
|
243
|
+
* Cleans both the library and runner schemes for the appropriate platform.
|
|
208
244
|
*/
|
|
209
|
-
async cleanProject () {
|
|
245
|
+
async cleanProject (): Promise<void> {
|
|
210
246
|
const libScheme = isTvOS(this.platformName || '') ? LIB_SCHEME_TV : LIB_SCHEME_IOS;
|
|
211
247
|
const runnerScheme = isTvOS(this.platformName || '') ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
|
|
212
248
|
|
|
@@ -221,14 +257,74 @@ export class XcodeBuild {
|
|
|
221
257
|
}
|
|
222
258
|
|
|
223
259
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @param
|
|
226
|
-
* @returns
|
|
260
|
+
* Starts the xcodebuild process to build and/or test WebDriverAgent.
|
|
261
|
+
* @param buildOnly - If `true`, only builds without running tests. Defaults to `false`.
|
|
262
|
+
* @returns The WDA status record if tests are run, `void` if build-only
|
|
263
|
+
* @throws Error if xcodebuild fails or cannot start
|
|
264
|
+
*/
|
|
265
|
+
async start (buildOnly: boolean = false): Promise<StringRecord | void> {
|
|
266
|
+
this.xcodebuild = await this.createSubProcess(buildOnly);
|
|
267
|
+
|
|
268
|
+
// wrap the start procedure in a promise so that we can catch, and report,
|
|
269
|
+
// any startup errors that are thrown as events
|
|
270
|
+
if (!this.xcodebuild) {
|
|
271
|
+
throw new Error('xcodebuild subprocess was not created');
|
|
272
|
+
}
|
|
273
|
+
const xcodebuild = this.xcodebuild;
|
|
274
|
+
return await new B((resolve, reject) => {
|
|
275
|
+
xcodebuild.once('exit', (code, signal) => {
|
|
276
|
+
xcodeLog.error(`xcodebuild exited with code '${code}' and signal '${signal}'`);
|
|
277
|
+
xcodebuild.removeAllListeners();
|
|
278
|
+
this._didProcessExit = true;
|
|
279
|
+
if (this._didBuildFail || (!signal && code !== 0)) {
|
|
280
|
+
let errorMessage = `xcodebuild failed with code ${code}.` +
|
|
281
|
+
` This usually indicates an issue with the local Xcode setup or WebDriverAgent` +
|
|
282
|
+
` project configuration or the driver-to-platform version mismatch.`;
|
|
283
|
+
if (!this.showXcodeLog) {
|
|
284
|
+
errorMessage += ` Consider setting 'showXcodeLog' capability to true in` +
|
|
285
|
+
` order to check the Appium server log for build-related error messages.`;
|
|
286
|
+
} else if (this.realDevice) {
|
|
287
|
+
errorMessage += ` Consider checking the WebDriverAgent configuration guide` +
|
|
288
|
+
` for real iOS devices at ${REAL_DEVICES_CONFIG_DOCS_LINK}.`;
|
|
289
|
+
}
|
|
290
|
+
return reject(new Error(errorMessage));
|
|
291
|
+
}
|
|
292
|
+
// in the case of just building, the process will exit and that is our finish
|
|
293
|
+
if (buildOnly) {
|
|
294
|
+
return resolve();
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
return (async () => {
|
|
299
|
+
try {
|
|
300
|
+
const timer = new timing.Timer().start();
|
|
301
|
+
if (!xcodebuild) {
|
|
302
|
+
throw new Error('xcodebuild subprocess was not created');
|
|
303
|
+
}
|
|
304
|
+
await xcodebuild.start(true);
|
|
305
|
+
if (!buildOnly) {
|
|
306
|
+
const result = await this.waitForStart(timer);
|
|
307
|
+
resolve(result ?? undefined);
|
|
308
|
+
}
|
|
309
|
+
} catch (err: any) {
|
|
310
|
+
const msg = `Unable to start WebDriverAgent: ${err}`;
|
|
311
|
+
this.log.error(msg);
|
|
312
|
+
reject(new Error(msg));
|
|
313
|
+
}
|
|
314
|
+
})();
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Stops the xcodebuild process and cleans up resources.
|
|
227
320
|
*/
|
|
228
|
-
|
|
321
|
+
async quit (): Promise<void> {
|
|
322
|
+
await killProcess('xcodebuild', this.xcodebuild);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private getCommand (buildOnly: boolean = false): {cmd: string; args: string[]} {
|
|
229
326
|
const cmd = 'xcodebuild';
|
|
230
|
-
|
|
231
|
-
const args = [];
|
|
327
|
+
const args: string[] = [];
|
|
232
328
|
|
|
233
329
|
// figure out the targets for xcodebuild
|
|
234
330
|
const [buildCmd, testCmd] = this.useSimpleBuildTest ? ['build', 'test'] : ['build-for-testing', 'test-without-building'];
|
|
@@ -301,11 +397,7 @@ export class XcodeBuild {
|
|
|
301
397
|
return {cmd, args};
|
|
302
398
|
}
|
|
303
399
|
|
|
304
|
-
|
|
305
|
-
* @param {boolean} [buildOnly=false]
|
|
306
|
-
* @returns {Promise<SubProcess>}
|
|
307
|
-
*/
|
|
308
|
-
async createSubProcess (buildOnly = false) {
|
|
400
|
+
private async createSubProcess (buildOnly: boolean = false): Promise<SubProcess> {
|
|
309
401
|
if (!this.useXctestrunFile && this.realDevice) {
|
|
310
402
|
if (this.keychainPath && this.keychainPassword) {
|
|
311
403
|
await setRealDeviceSecurity(this.keychainPath, this.keychainPassword);
|
|
@@ -315,8 +407,7 @@ export class XcodeBuild {
|
|
|
315
407
|
const {cmd, args} = this.getCommand(buildOnly);
|
|
316
408
|
this.log.debug(`Beginning ${buildOnly ? 'build' : 'test'} with command '${cmd} ${args.join(' ')}' ` +
|
|
317
409
|
`in directory '${this.bootstrapPath}'`);
|
|
318
|
-
|
|
319
|
-
const env = Object.assign({}, process.env, {
|
|
410
|
+
const env: Record<string, any> = Object.assign({}, process.env, {
|
|
320
411
|
USE_PORT: this.wdaRemotePort,
|
|
321
412
|
WDA_PRODUCT_BUNDLE_IDENTIFIER: this.updatedWDABundleId || WDA_RUNNER_BUNDLE_ID,
|
|
322
413
|
});
|
|
@@ -345,7 +436,7 @@ export class XcodeBuild {
|
|
|
345
436
|
: 'Output from xcodebuild will only be logged if any errors are present there';
|
|
346
437
|
this.log.debug(`${logMsg}. To change this, use 'showXcodeLog' desired capability`);
|
|
347
438
|
|
|
348
|
-
const onStreamLine = (
|
|
439
|
+
const onStreamLine = (line: string) => {
|
|
349
440
|
if (this.showXcodeLog === false || IGNORED_ERRORS_PATTERN.test(line)) {
|
|
350
441
|
return;
|
|
351
442
|
}
|
|
@@ -368,87 +459,36 @@ export class XcodeBuild {
|
|
|
368
459
|
return xcodebuild;
|
|
369
460
|
}
|
|
370
461
|
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* @param {boolean} [buildOnly=false]
|
|
374
|
-
* @returns {Promise<import('@appium/types').StringRecord>}
|
|
375
|
-
*/
|
|
376
|
-
async start (buildOnly = false) {
|
|
377
|
-
this.xcodebuild = await this.createSubProcess(buildOnly);
|
|
378
|
-
|
|
379
|
-
// wrap the start procedure in a promise so that we can catch, and report,
|
|
380
|
-
// any startup errors that are thrown as events
|
|
381
|
-
return await new B((resolve, reject) => {
|
|
382
|
-
this.xcodebuild.once('exit', (code, signal) => {
|
|
383
|
-
xcodeLog.error(`xcodebuild exited with code '${code}' and signal '${signal}'`);
|
|
384
|
-
this.xcodebuild.removeAllListeners();
|
|
385
|
-
this.didProcessExit = true;
|
|
386
|
-
if (this._didBuildFail || (!signal && code !== 0)) {
|
|
387
|
-
let errorMessage = `xcodebuild failed with code ${code}.` +
|
|
388
|
-
` This usually indicates an issue with the local Xcode setup or WebDriverAgent` +
|
|
389
|
-
` project configuration or the driver-to-platform version mismatch.`;
|
|
390
|
-
if (!this.showXcodeLog) {
|
|
391
|
-
errorMessage += ` Consider setting 'showXcodeLog' capability to true in` +
|
|
392
|
-
` order to check the Appium server log for build-related error messages.`;
|
|
393
|
-
} else if (this.realDevice) {
|
|
394
|
-
errorMessage += ` Consider checking the WebDriverAgent configuration guide` +
|
|
395
|
-
` for real iOS devices at ${REAL_DEVICES_CONFIG_DOCS_LINK}.`;
|
|
396
|
-
}
|
|
397
|
-
return reject(new Error(errorMessage));
|
|
398
|
-
}
|
|
399
|
-
// in the case of just building, the process will exit and that is our finish
|
|
400
|
-
if (buildOnly) {
|
|
401
|
-
return resolve();
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
return (async () => {
|
|
406
|
-
try {
|
|
407
|
-
const timer = new timing.Timer().start();
|
|
408
|
-
await this.xcodebuild.start(true);
|
|
409
|
-
if (!buildOnly) {
|
|
410
|
-
resolve(/** @type {import('@appium/types').StringRecord} */ (await this.waitForStart(timer)));
|
|
411
|
-
}
|
|
412
|
-
} catch (err) {
|
|
413
|
-
let msg = `Unable to start WebDriverAgent: ${err}`;
|
|
414
|
-
this.log.error(msg);
|
|
415
|
-
reject(new Error(msg));
|
|
416
|
-
}
|
|
417
|
-
})();
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
*
|
|
423
|
-
* @param {any} timer
|
|
424
|
-
* @returns {Promise<import('@appium/types').StringRecord?>}
|
|
425
|
-
*/
|
|
426
|
-
async waitForStart (timer) {
|
|
462
|
+
private async waitForStart (timer: timing.Timer): Promise<StringRecord | null> {
|
|
427
463
|
// try to connect once every 0.5 seconds, until `launchTimeout` is up
|
|
428
464
|
const timeout = this.launchTimeout || 60000; // Default to 60 seconds if not set
|
|
429
465
|
this.log.debug(`Waiting up to ${timeout}ms for WebDriverAgent to start`);
|
|
430
|
-
let currentStatus = null;
|
|
466
|
+
let currentStatus: StringRecord | null = null;
|
|
431
467
|
try {
|
|
432
468
|
const retries = Math.trunc(timeout / 500);
|
|
469
|
+
if (!this.noSessionProxy) {
|
|
470
|
+
throw new Error('noSessionProxy was not initialized');
|
|
471
|
+
}
|
|
472
|
+
const noSessionProxy = this.noSessionProxy;
|
|
433
473
|
await retryInterval(retries, 1000, async () => {
|
|
434
474
|
if (this._didProcessExit) {
|
|
435
475
|
// there has been an error elsewhere and we need to short-circuit
|
|
436
476
|
return currentStatus;
|
|
437
477
|
}
|
|
438
478
|
|
|
439
|
-
const proxyTimeout =
|
|
440
|
-
|
|
479
|
+
const proxyTimeout = noSessionProxy.timeout;
|
|
480
|
+
noSessionProxy.timeout = 1000;
|
|
441
481
|
try {
|
|
442
|
-
currentStatus = await
|
|
443
|
-
if (currentStatus && currentStatus.ios && currentStatus.ios.ip) {
|
|
444
|
-
this.agentUrl = currentStatus.ios.ip;
|
|
482
|
+
currentStatus = await noSessionProxy.command('/status', 'GET') as StringRecord;
|
|
483
|
+
if (currentStatus && currentStatus.ios && (currentStatus.ios as any).ip) {
|
|
484
|
+
this.agentUrl = (currentStatus.ios as any).ip;
|
|
445
485
|
}
|
|
446
486
|
this.log.debug(`WebDriverAgent information:`);
|
|
447
487
|
this.log.debug(JSON.stringify(currentStatus, null, 2));
|
|
448
|
-
} catch (err) {
|
|
488
|
+
} catch (err: any) {
|
|
449
489
|
throw new Error(`Unable to connect to running WebDriverAgent: ${err.message}`);
|
|
450
490
|
} finally {
|
|
451
|
-
|
|
491
|
+
noSessionProxy.timeout = proxyTimeout;
|
|
452
492
|
}
|
|
453
493
|
});
|
|
454
494
|
|
|
@@ -458,7 +498,7 @@ export class XcodeBuild {
|
|
|
458
498
|
}
|
|
459
499
|
|
|
460
500
|
this.log.debug(`WebDriverAgent successfully started after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
|
|
461
|
-
} catch (err) {
|
|
501
|
+
} catch (err: any) {
|
|
462
502
|
this.log.debug(err.stack);
|
|
463
503
|
throw new Error(
|
|
464
504
|
`We were not able to retrieve the /status response from the WebDriverAgent server after ${timeout}ms timeout.` +
|
|
@@ -467,13 +507,4 @@ export class XcodeBuild {
|
|
|
467
507
|
}
|
|
468
508
|
return currentStatus;
|
|
469
509
|
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* @returns {Promise<void>}
|
|
473
|
-
*/
|
|
474
|
-
async quit () {
|
|
475
|
-
await killProcess('xcodebuild', this.xcodebuild);
|
|
476
|
-
}
|
|
477
510
|
}
|
|
478
|
-
|
|
479
|
-
export default XcodeBuild;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-webdriveragent",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Package bundling WebDriverAgent",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"test": "mocha --exit --timeout 1m \"./test/unit/**/*-specs.ts\"",
|
|
17
17
|
"e2e-test": "mocha --exit --timeout 10m \"./test/functional/**/*-specs.ts\"",
|
|
18
18
|
"bundle": "npm run bundle:ios && npm run bundle:tv",
|
|
19
|
-
"bundle:ios": "TARGET=runner SDK=sim node ./Scripts/build-webdriveragent.
|
|
20
|
-
"bundle:tv": "TARGET=tv_runner SDK=tv_sim node ./Scripts/build-webdriveragent.
|
|
21
|
-
"fetch-prebuilt-wda": "node ./Scripts/fetch-prebuilt-wda.
|
|
22
|
-
"sync-wda-version": "node ./
|
|
19
|
+
"bundle:ios": "TARGET=runner SDK=sim node ./Scripts/build-webdriveragent.mjs",
|
|
20
|
+
"bundle:tv": "TARGET=tv_runner SDK=tv_sim node ./Scripts/build-webdriveragent.mjs",
|
|
21
|
+
"fetch-prebuilt-wda": "node ./Scripts/fetch-prebuilt-wda.mjs",
|
|
22
|
+
"sync-wda-version": "node ./Scripts/update-wda-version.mjs --package-version=${npm_package_version} && git add WebDriverAgentLib/Info.plist"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
|
|
@@ -86,11 +86,9 @@
|
|
|
86
86
|
"files": [
|
|
87
87
|
"index.ts",
|
|
88
88
|
"lib",
|
|
89
|
-
"build
|
|
90
|
-
"build/lib",
|
|
89
|
+
"build",
|
|
91
90
|
"Scripts/build.sh",
|
|
92
|
-
"Scripts
|
|
93
|
-
"Scripts/build-webdriveragent.js",
|
|
91
|
+
"Scripts/*.mjs",
|
|
94
92
|
"Configurations",
|
|
95
93
|
"PrivateHeaders",
|
|
96
94
|
"WebDriverAgent.xcodeproj",
|
package/lib/constants.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
const DEFAULT_TEST_BUNDLE_SUFFIX = '.xctrunner';
|
|
4
|
-
const WDA_RUNNER_BUNDLE_ID = 'com.facebook.WebDriverAgentRunner';
|
|
5
|
-
const WDA_RUNNER_BUNDLE_ID_FOR_XCTEST = `${WDA_RUNNER_BUNDLE_ID}${DEFAULT_TEST_BUNDLE_SUFFIX}`;
|
|
6
|
-
const WDA_RUNNER_APP = 'WebDriverAgentRunner-Runner.app';
|
|
7
|
-
const WDA_SCHEME = 'WebDriverAgentRunner';
|
|
8
|
-
const PROJECT_FILE = 'project.pbxproj';
|
|
9
|
-
const WDA_BASE_URL = 'http://127.0.0.1';
|
|
10
|
-
|
|
11
|
-
const PLATFORM_NAME_TVOS = 'tvOS';
|
|
12
|
-
const PLATFORM_NAME_IOS = 'iOS';
|
|
13
|
-
|
|
14
|
-
const SDK_SIMULATOR = 'iphonesimulator';
|
|
15
|
-
const SDK_DEVICE = 'iphoneos';
|
|
16
|
-
|
|
17
|
-
const WDA_UPGRADE_TIMESTAMP_PATH = path.join('.appium', 'webdriveragent', 'upgrade.time');
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
WDA_RUNNER_BUNDLE_ID, WDA_RUNNER_APP, PROJECT_FILE,
|
|
21
|
-
WDA_SCHEME, PLATFORM_NAME_TVOS, PLATFORM_NAME_IOS,
|
|
22
|
-
SDK_SIMULATOR, SDK_DEVICE, WDA_BASE_URL, WDA_UPGRADE_TIMESTAMP_PATH,
|
|
23
|
-
WDA_RUNNER_BUNDLE_ID_FOR_XCTEST, DEFAULT_TEST_BUNDLE_SUFFIX
|
|
24
|
-
};
|