appium-webdriveragent 10.1.3 → 10.2.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.
@@ -36,11 +36,10 @@ export class WebDriverAgent {
36
36
 
37
37
  /**
38
38
  * @param {import('appium-xcode').XcodeVersion} xcodeVersion
39
- * // TODO: make args typed
40
- * @param {import('@appium/types').StringRecord} [args={}]
39
+ * @param {import('./types').WebDriverAgentArgs} args
41
40
  * @param {import('@appium/types').AppiumLogger?} [log=null]
42
41
  */
43
- constructor (xcodeVersion, args = {}, log = null) {
42
+ constructor (xcodeVersion, args, log = null) {
44
43
  this.xcodeVersion = xcodeVersion;
45
44
 
46
45
  this.args = _.clone(args);
@@ -52,7 +51,7 @@ export class WebDriverAgent {
52
51
  this.iosSdkVersion = args.iosSdkVersion;
53
52
  this.host = args.host;
54
53
  this.isRealDevice = !!args.realDevice;
55
- this.idb = (args.device || {}).idb;
54
+ this.idb = args.device.idb;
56
55
  this.wdaBundlePath = args.wdaBundlePath;
57
56
 
58
57
  this.setWDAPaths(args.bootstrapPath, args.agentPath);
@@ -61,7 +60,7 @@ export class WebDriverAgent {
61
60
  this.wdaRemotePort = ((this.isRealDevice ? args.wdaRemotePort : null) ?? args.wdaLocalPort)
62
61
  || WDA_AGENT_PORT;
63
62
  this.wdaBaseUrl = args.wdaBaseUrl || WDA_BASE_URL;
64
-
63
+ this.wdaBindingIP = args.wdaBindingIP;
65
64
  this.prebuildWDA = args.prebuildWDA;
66
65
 
67
66
  // this.args.webDriverAgentUrl guiarantees the capabilities acually
@@ -105,6 +104,7 @@ export class WebDriverAgent {
105
104
  updatedWDABundleId: this.updatedWDABundleId,
106
105
  launchTimeout: this.wdaLaunchTimeout,
107
106
  wdaRemotePort: this.wdaRemotePort,
107
+ wdaBindingIP: this.wdaBindingIP,
108
108
  useXctestrunFile: this.useXctestrunFile,
109
109
  derivedDataPath: args.derivedDataPath,
110
110
  mjpegServerPort: this.mjpegServerPort,
@@ -121,7 +121,7 @@ export class WebDriverAgent {
121
121
  get canSkipXcodebuild () {
122
122
  // Use this.args.webDriverAgentUrl to guarantee
123
123
  // the capabilities set gave the `appium:webDriverAgentUrl`.
124
- return this.usePreinstalledWDA || this.args.webDriverAgentUrl;
124
+ return this.usePreinstalledWDA || !!this.args.webDriverAgentUrl;
125
125
  }
126
126
 
127
127
  /**
@@ -391,12 +391,15 @@ export class WebDriverAgent {
391
391
  if (this.mjpegServerPort) {
392
392
  xctestEnv.MJPEG_SERVER_PORT = this.mjpegServerPort;
393
393
  }
394
+ if (this.wdaBindingIP) {
395
+ xctestEnv.USE_IP = this.wdaBindingIP;
396
+ }
394
397
  this.log.info('Launching WebDriverAgent on the device without xcodebuild');
395
398
  if (this.isRealDevice) {
396
399
  // Current method to launch WDA process can be done via 'xcrun devicectl',
397
400
  // but it has limitation about the WDA preinstalled package.
398
401
  // https://github.com/appium/appium/issues/19206#issuecomment-2014182674
399
- if (util.compareVersions(this.platformVersion, '>=', '17.0')) {
402
+ if (this.platformVersion && util.compareVersions(this.platformVersion, '>=', '17.0')) {
400
403
  await this._launchViaDevicectl({env: xctestEnv});
401
404
  } else {
402
405
  this.xctestApiClient = new Xctest(this.device.udid, this.bundleIdForXctest, null, {env: xctestEnv});
@@ -631,7 +634,7 @@ export class WebDriverAgent {
631
634
  if (!this.args.webDriverAgentUrl) {
632
635
  // if we populated the url ourselves (during `setupCaching` call, for instance)
633
636
  // then clean that up. If the url was supplied, we want to keep it
634
- this.webDriverAgentUrl = null;
637
+ this.webDriverAgentUrl = undefined;
635
638
  }
636
639
  }
637
640
 
package/lib/xcodebuild.js CHANGED
@@ -47,12 +47,11 @@ export class XcodeBuild {
47
47
 
48
48
  /**
49
49
  * @param {import('appium-xcode').XcodeVersion} xcodeVersion
50
- * @param {any} device
51
- * // TODO: make args typed
52
- * @param {import('@appium/types').StringRecord} [args={}]
53
- * @param {import('@appium/types').AppiumLogger?} [log=null]
50
+ * @param {import('./types').AppleDevice} device
51
+ * @param {import('./types').XcodeBuildArgs} args
52
+ * @param {import('@appium/types').AppiumLogger | null} [log=null]
54
53
  */
55
- constructor (xcodeVersion, device, args = {}, log = null) {
54
+ constructor (xcodeVersion, device, args, log = null) {
56
55
  this.xcodeVersion = xcodeVersion;
57
56
 
58
57
  this.device = device;
@@ -84,6 +83,7 @@ export class XcodeBuild {
84
83
  this.launchTimeout = args.launchTimeout;
85
84
 
86
85
  this.wdaRemotePort = args.wdaRemotePort;
86
+ this.wdaBindingIP = args.wdaBindingIP;
87
87
 
88
88
  this.updatedWDABundleId = args.updatedWDABundleId;
89
89
  this.derivedDataPath = args.derivedDataPath;
@@ -110,13 +110,20 @@ export class XcodeBuild {
110
110
  this.noSessionProxy = noSessionProxy;
111
111
 
112
112
  if (this.useXctestrunFile) {
113
- const deviveInfo = {
114
- isRealDevice: this.realDevice,
113
+ /** @type {import('./utils').DeviceInfo} */
114
+ const deviceInfo = {
115
+ isRealDevice: !!this.realDevice,
115
116
  udid: this.device.udid,
116
- platformVersion: this.platformVersion,
117
- platformName: this.platformName
117
+ platformVersion: this.platformVersion || '',
118
+ platformName: this.platformName || ''
118
119
  };
119
- this.xctestrunFilePath = await setXctestrunFile(deviveInfo, this.iosSdkVersion, this.bootstrapPath, this.wdaRemotePort);
120
+ this.xctestrunFilePath = await setXctestrunFile({
121
+ deviceInfo,
122
+ sdkVersion: this.iosSdkVersion || '',
123
+ bootstrapPath: this.bootstrapPath,
124
+ wdaRemotePort: this.wdaRemotePort || 8100,
125
+ wdaBindingIP: this.wdaBindingIP
126
+ });
120
127
  return;
121
128
  }
122
129
 
@@ -200,8 +207,8 @@ export class XcodeBuild {
200
207
  * @returns {Promise<void>}
201
208
  */
202
209
  async cleanProject () {
203
- const libScheme = isTvOS(this.platformName) ? LIB_SCHEME_TV : LIB_SCHEME_IOS;
204
- const runnerScheme = isTvOS(this.platformName) ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
210
+ const libScheme = isTvOS(this.platformName || '') ? LIB_SCHEME_TV : LIB_SCHEME_IOS;
211
+ const runnerScheme = isTvOS(this.platformName || '') ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
205
212
 
206
213
  for (const scheme of [libScheme, runnerScheme]) {
207
214
  this.log.debug(`Cleaning the project scheme '${scheme}' to make sure there are no leftovers from previous installs`);
@@ -249,7 +256,7 @@ export class XcodeBuild {
249
256
  if (this.useXctestrunFile && this.xctestrunFilePath) {
250
257
  args.push('-xctestrun', this.xctestrunFilePath);
251
258
  } else {
252
- const runnerScheme = isTvOS(this.platformName) ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
259
+ const runnerScheme = isTvOS(this.platformName || '') ? RUNNER_SCHEME_TV : RUNNER_SCHEME_IOS;
253
260
  args.push('-project', this.agentPath, '-scheme', runnerScheme);
254
261
  if (this.derivedDataPath) {
255
262
  args.push('-derivedDataPath', this.derivedDataPath);
@@ -257,14 +264,16 @@ export class XcodeBuild {
257
264
  }
258
265
  args.push('-destination', `id=${this.device.udid}`);
259
266
 
260
- const versionMatch = new RegExp(/^(\d+)\.(\d+)/).exec(this.platformVersion);
261
- if (versionMatch) {
267
+ let versionMatch;
268
+ if (this.platformVersion && (versionMatch = new RegExp(/^(\d+)\.(\d+)/).exec(this.platformVersion))) {
262
269
  args.push(
263
- `${isTvOS(this.platformName) ? 'TV' : 'IPHONE'}OS_DEPLOYMENT_TARGET=${versionMatch[1]}.${versionMatch[2]}`
270
+ `${isTvOS(this.platformName || '') ? 'TV' : 'IPHONE'}OS_DEPLOYMENT_TARGET=${versionMatch[1]}.${versionMatch[2]}`
264
271
  );
265
272
  } else {
266
- this.log.warn(`Cannot parse major and minor version numbers from platformVersion "${this.platformVersion}". ` +
267
- 'Will build for the default platform instead');
273
+ this.log.warn(
274
+ `Cannot parse major and minor version numbers from platformVersion "${this.platformVersion}". ` +
275
+ 'Will build for the default platform instead'
276
+ );
268
277
  }
269
278
 
270
279
  if (this.realDevice) {
@@ -413,10 +422,11 @@ export class XcodeBuild {
413
422
  */
414
423
  async waitForStart (timer) {
415
424
  // try to connect once every 0.5 seconds, until `launchTimeout` is up
416
- this.log.debug(`Waiting up to ${this.launchTimeout}ms for WebDriverAgent to start`);
425
+ const timeout = this.launchTimeout || 60000; // Default to 60 seconds if not set
426
+ this.log.debug(`Waiting up to ${timeout}ms for WebDriverAgent to start`);
417
427
  let currentStatus = null;
418
428
  try {
419
- const retries = Math.trunc(this.launchTimeout / 500);
429
+ const retries = Math.trunc(timeout / 500);
420
430
  await retryInterval(retries, 1000, async () => {
421
431
  if (this._didProcessExit) {
422
432
  // there has been an error elsewhere and we need to short-circuit
@@ -448,7 +458,7 @@ export class XcodeBuild {
448
458
  } catch (err) {
449
459
  this.log.debug(err.stack);
450
460
  throw new Error(
451
- `We were not able to retrieve the /status response from the WebDriverAgent server after ${this.launchTimeout}ms timeout.` +
461
+ `We were not able to retrieve the /status response from the WebDriverAgent server after ${timeout}ms timeout.` +
452
462
  `Try to increase the value of 'appium:wdaLaunchTimeout' capability as a possible workaround.`
453
463
  );
454
464
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "10.1.3",
3
+ "version": "10.2.0",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",