appium-xcuitest-driver 7.8.1 → 7.9.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.
@@ -5,7 +5,7 @@ import B from 'bluebird';
5
5
  import defaultLogger from './logger';
6
6
  import _ from 'lodash';
7
7
  import {exec} from 'teen_process';
8
- import {extractBundleId} from './app-utils';
8
+ import {extractBundleId, SAFARI_BUNDLE_ID} from './app-utils';
9
9
  import {pushFolder} from './ios-fs-helpers';
10
10
  import { Devicectl } from './devicectl';
11
11
 
@@ -20,6 +20,13 @@ const APP_INSTALL_STRATEGY = Object.freeze({
20
20
  IOS_DEPLOY,
21
21
  });
22
22
 
23
+ /**
24
+ * @returns {Promise<string[]>}
25
+ */
26
+ export async function getConnectedDevices() {
27
+ return await utilities.getConnectedDevices();
28
+ }
29
+
23
30
  export class RealDevice {
24
31
  /**
25
32
  * @param {string} udid
@@ -317,6 +324,41 @@ export class RealDevice {
317
324
  async getPlatformVersion() {
318
325
  return await utilities.getOSVersion(this.udid);
319
326
  }
327
+
328
+ /**
329
+ * @param {import('./driver').XCUITestDriverOpts} opts
330
+ * @returns {Promise<void>}
331
+ */
332
+ async reset({bundleId, fullReset, platformVersion}) {
333
+ if (!bundleId) {
334
+ return;
335
+ }
336
+
337
+ if (bundleId === SAFARI_BUNDLE_ID) {
338
+ this.log.debug('Reset requested. About to terminate Safari');
339
+ await this.terminateApp(bundleId, String(platformVersion));
340
+ return;
341
+ }
342
+
343
+ if (!fullReset) {
344
+ return;
345
+ }
346
+
347
+ this.log.debug(`Reset: fullReset requested. Will try to uninstall the app '${bundleId}'.`);
348
+ if (!(await this.isAppInstalled(bundleId))) {
349
+ this.log.debug('Reset: app not installed. No need to uninstall');
350
+ return;
351
+ }
352
+
353
+ try {
354
+ await this.remove(bundleId);
355
+ } catch (err) {
356
+ this.log.error(`Reset: could not remove '${bundleId}' from device: ${err.message}`);
357
+ throw err;
358
+ }
359
+ this.log.debug(`Reset: removed '${bundleId}'`);
360
+ }
361
+
320
362
  }
321
363
 
322
364
  export default RealDevice;
@@ -4,16 +4,9 @@ import {resetTestProcesses} from 'appium-webdriveragent';
4
4
  import _ from 'lodash';
5
5
  import {util, timing} from 'appium/support';
6
6
  import {UDID_AUTO, normalizePlatformName} from './utils';
7
+ import {buildSafariPreferences} from './app-utils';
7
8
 
8
9
  const APPIUM_SIM_PREFIX = 'appiumTest';
9
- const SAFARI_OPTS_ALIASES_MAP = /** @type {const} */ ({
10
- safariAllowPopups: [
11
- ['WebKitJavaScriptCanOpenWindowsAutomatically', 'JavaScriptCanOpenWindowsAutomatically'],
12
- (x) => Number(Boolean(x)),
13
- ],
14
- safariIgnoreFraudWarning: [['WarnAboutFraudulentWebsites'], (x) => Number(!x)],
15
- safariOpenLinksInBackground: [['OpenLinksInBackground'], (x) => Number(Boolean(x))],
16
- });
17
10
 
18
11
  /**
19
12
  * Create a new simulator with `appiumTest-` prefix and return the object.
@@ -290,23 +283,13 @@ export async function shutdownOtherSimulators() {
290
283
  * @return {Promise<boolean>} true if any preferences have been updated
291
284
  */
292
285
  export async function setSafariPrefs() {
293
- const safariSettings = _.cloneDeep(this.opts.safariGlobalPreferences ?? {});
294
-
295
- for (const [name, [aliases, valueConverter]] of _.toPairs(SAFARI_OPTS_ALIASES_MAP)) {
296
- if (!_.has(this.opts, name)) {
297
- continue;
298
- }
299
-
300
- for (const alias of aliases) {
301
- safariSettings[alias] = valueConverter(this.opts[name]);
302
- }
303
- }
304
- if (_.isEmpty(safariSettings)) {
286
+ const prefs = buildSafariPreferences(this.opts);
287
+ if (_.isEmpty(prefs)) {
305
288
  return false;
306
289
  }
307
290
 
308
- this.log.debug(`About to update Safari preferences: ${JSON.stringify(safariSettings)}`);
309
- await /** @type {import('./driver').Simulator} */ (this.device).updateSafariSettings(safariSettings);
291
+ this.log.debug(`About to update Safari preferences: ${JSON.stringify(prefs)}`);
292
+ await /** @type {import('./driver').Simulator} */ (this.device).updateSafariSettings(prefs);
310
293
  return true;
311
294
  }
312
295
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-xcuitest-driver",
3
- "version": "7.8.1",
3
+ "version": "7.9.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-xcuitest-driver",
9
- "version": "7.8.1",
9
+ "version": "7.9.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@colors/colors": "^1.6.0",
@@ -14,7 +14,7 @@
14
14
  "appium-ios-device": "^2.5.4",
15
15
  "appium-ios-simulator": "^6.1.2",
16
16
  "appium-remote-debugger": "^11.0.0",
17
- "appium-webdriveragent": "^8.2.1",
17
+ "appium-webdriveragent": "^8.3.0",
18
18
  "appium-xcode": "^5.1.4",
19
19
  "async-lock": "^1.4.0",
20
20
  "asyncbox": "^3.0.0",
@@ -717,9 +717,9 @@
717
717
  }
718
718
  },
719
719
  "node_modules/@types/node": {
720
- "version": "20.11.30",
721
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz",
722
- "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==",
720
+ "version": "20.12.2",
721
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.2.tgz",
722
+ "integrity": "sha512-zQ0NYO87hyN6Xrclcqp7f8ZbXNbRfoGWNcMvHTPQp9UUrwI0mI7XBz+cu7/W6/VClYo2g63B0cjull/srU7LgQ==",
723
723
  "dependencies": {
724
724
  "undici-types": "~5.26.4"
725
725
  }
@@ -953,9 +953,9 @@
953
953
  }
954
954
  },
955
955
  "node_modules/appium-webdriveragent": {
956
- "version": "8.2.1",
957
- "resolved": "https://registry.npmjs.org/appium-webdriveragent/-/appium-webdriveragent-8.2.1.tgz",
958
- "integrity": "sha512-Ai4I5YSyNOKlD6+oGbaRfuPAeGINcLGDB0+CwowvkG4FnReYKm3zfYR6VOquoqoNqOZkzTW8PbxSG0dRSUBxMQ==",
956
+ "version": "8.3.0",
957
+ "resolved": "https://registry.npmjs.org/appium-webdriveragent/-/appium-webdriveragent-8.3.0.tgz",
958
+ "integrity": "sha512-g8vEBH7VdLf/fzH3VIXtem2v5GUVSw+ilHzZfqGg9hOVqOZ4oZ2GfjSVo7mM4Jux1/CidG3gczTriIWgmD3WBA==",
959
959
  "dependencies": {
960
960
  "@appium/base-driver": "^9.0.0",
961
961
  "@appium/strongbox": "^0.x",
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "xcuitest",
9
9
  "xctest"
10
10
  ],
11
- "version": "7.8.1",
11
+ "version": "7.9.0",
12
12
  "author": "Appium Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "repository": {
@@ -81,7 +81,7 @@
81
81
  "appium-ios-device": "^2.5.4",
82
82
  "appium-ios-simulator": "^6.1.2",
83
83
  "appium-remote-debugger": "^11.0.0",
84
- "appium-webdriveragent": "^8.2.1",
84
+ "appium-webdriveragent": "^8.3.0",
85
85
  "appium-xcode": "^5.1.4",
86
86
  "async-lock": "^1.4.0",
87
87
  "asyncbox": "^3.0.0",