appium-xcuitest-driver 10.14.1 → 10.14.2

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/lib/commands/execute.d.ts +10 -22
  3. package/build/lib/commands/execute.d.ts.map +1 -1
  4. package/build/lib/commands/execute.js +12 -28
  5. package/build/lib/commands/execute.js.map +1 -1
  6. package/build/lib/commands/location.d.ts +8 -11
  7. package/build/lib/commands/location.d.ts.map +1 -1
  8. package/build/lib/commands/location.js +7 -15
  9. package/build/lib/commands/location.js.map +1 -1
  10. package/build/lib/commands/navigation.d.ts +14 -26
  11. package/build/lib/commands/navigation.d.ts.map +1 -1
  12. package/build/lib/commands/navigation.js +10 -18
  13. package/build/lib/commands/navigation.js.map +1 -1
  14. package/build/lib/commands/pcap.d.ts +18 -38
  15. package/build/lib/commands/pcap.d.ts.map +1 -1
  16. package/build/lib/commands/pcap.js +9 -14
  17. package/build/lib/commands/pcap.js.map +1 -1
  18. package/build/lib/commands/screenshots.d.ts +15 -9
  19. package/build/lib/commands/screenshots.d.ts.map +1 -1
  20. package/build/lib/commands/screenshots.js +13 -11
  21. package/build/lib/commands/screenshots.js.map +1 -1
  22. package/build/lib/commands/source.d.ts +10 -8
  23. package/build/lib/commands/source.d.ts.map +1 -1
  24. package/build/lib/commands/source.js +11 -14
  25. package/build/lib/commands/source.js.map +1 -1
  26. package/build/lib/driver.js +1 -1
  27. package/build/lib/driver.js.map +1 -1
  28. package/build/lib/execute-method-map.d.ts.map +1 -1
  29. package/build/lib/execute-method-map.js +0 -2
  30. package/build/lib/execute-method-map.js.map +1 -1
  31. package/lib/commands/{execute.js → execute.ts} +41 -37
  32. package/lib/commands/{location.js → location.ts} +19 -22
  33. package/lib/commands/{navigation.js → navigation.ts} +23 -26
  34. package/lib/commands/{pcap.js → pcap.ts} +28 -28
  35. package/lib/commands/{screenshots.js → screenshots.ts} +24 -16
  36. package/lib/commands/{source.js → source.ts} +23 -20
  37. package/lib/driver.ts +1 -1
  38. package/lib/execute-method-map.ts +0 -2
  39. package/npm-shrinkwrap.json +2 -2
  40. package/package.json +1 -1
@@ -1,12 +1,16 @@
1
1
  import _ from 'lodash';
2
2
  import js2xml from 'js2xmlparser2';
3
+ import type {XCUITestDriver} from '../driver';
4
+ import type {SourceFormat} from './types';
3
5
 
4
6
  const APPIUM_AUT_TAG = 'AppiumAUT';
5
7
 
6
8
  /**
7
- * @this {XCUITestDriver}
9
+ * Retrieves the page source of the current application.
10
+ *
11
+ * @returns The page source as XML or HTML string
8
12
  */
9
- export async function getPageSource() {
13
+ export async function getPageSource(this: XCUITestDriver): Promise<string> {
10
14
  if (this.isWebContext()) {
11
15
  const script = 'return document.documentElement.outerHTML';
12
16
  return await this.executeAtom('execute_script', [script, []]);
@@ -28,14 +32,17 @@ export async function getPageSource() {
28
32
  /**
29
33
  * Retrieve the source tree of the current page in XML or JSON format.
30
34
  *
31
- * @param {import('./types').SourceFormat} format - Page tree source representation format.
32
- * @param {string} [excludedAttributes] A comma-separated string of attribute names to exclude from the output. Only works if `format` is `xml`.
35
+ * @param format - Page tree source representation format.
36
+ * @param excludedAttributes - A comma-separated string of attribute names to exclude from the output. Only works if `format` is `xml`.
33
37
  * @privateRemarks Why isn't `excludedAttributes` an array?
34
- * @returns {Promise<string>} The source tree of the current page in the given format.
35
- * @this {XCUITestDriver}
38
+ * @returns The source tree of the current page in the given format.
36
39
  */
37
- export async function mobileGetSource(format = 'xml', excludedAttributes) {
38
- const paramsMap = {
40
+ export async function mobileGetSource(
41
+ this: XCUITestDriver,
42
+ format: SourceFormat = 'xml',
43
+ excludedAttributes?: string,
44
+ ): Promise<string> {
45
+ const paramsMap: Record<string, string> = {
39
46
  format,
40
47
  scope: APPIUM_AUT_TAG,
41
48
  };
@@ -45,7 +52,7 @@ export async function mobileGetSource(format = 'xml', excludedAttributes) {
45
52
  const query = Object.entries(paramsMap)
46
53
  .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
47
54
  .join('&');
48
- return /** @type {string} */ (await this.proxyCommand(`/source?${query}`, 'GET'));
55
+ return await this.proxyCommand(`/source?${query}`, 'GET') as string;
49
56
  }
50
57
 
51
58
  /**
@@ -76,15 +83,14 @@ export async function mobileGetSource(format = 'xml', excludedAttributes) {
76
83
  * rawIdentifier: null }
77
84
  * ```
78
85
  */
79
- function getTreeForXML(srcTree) {
80
- function getTree(element, elementIndex, parentPath) {
81
- let curPath = `${parentPath}/${elementIndex}`;
82
- let rect = element.rect || {};
86
+ function getTreeForXML(srcTree: any): any {
87
+ function getTree(element: any, elementIndex: number, parentPath: string): any {
88
+ const curPath = `${parentPath}/${elementIndex}`;
89
+ const rect = element.rect || {};
83
90
  /**
84
91
  * @privateRemarks I don't even want to try to type this right now
85
- * @type {any}
86
92
  */
87
- let subtree = {
93
+ const subtree: any = {
88
94
  '@': {
89
95
  type: `XCUIElementType${element.type}`,
90
96
  enabled: parseInt(element.isEnabled, 10) === 1,
@@ -114,11 +120,11 @@ function getTreeForXML(srcTree) {
114
120
  [`XCUIElementType${element.type}`]: subtree,
115
121
  };
116
122
  }
117
- let tree = getTree(srcTree, 0, '');
123
+ const tree = getTree(srcTree, 0, '');
118
124
  return tree;
119
125
  }
120
126
 
121
- function getSourceXml(jsonSource) {
127
+ function getSourceXml(jsonSource: any): string {
122
128
  return js2xml('AppiumAUT', jsonSource, {
123
129
  wrapArray: {enabled: false, elementName: 'element'},
124
130
  declaration: {include: true},
@@ -126,6 +132,3 @@ function getSourceXml(jsonSource) {
126
132
  });
127
133
  }
128
134
 
129
- /**
130
- * @typedef {import('../driver').XCUITestDriver} XCUITestDriver
131
- */
package/lib/driver.ts CHANGED
@@ -500,7 +500,7 @@ export class XCUITestDriver
500
500
  this.log.debug(`Executing command '${cmd}'`);
501
501
 
502
502
  if (cmd === 'receiveAsyncResponse') {
503
- return await this.receiveAsyncResponse(...args);
503
+ return await this.receiveAsyncResponse(args[0], args[1]);
504
504
  }
505
505
  // TODO: once this fix gets into base driver remove from here
506
506
  if (cmd === 'getStatus') {
@@ -466,14 +466,12 @@ export const executeMethodMap = {
466
466
  command: 'mobileResetLocationService',
467
467
  },
468
468
  'mobile: startPcap': {
469
- // @ts-expect-error Method exists on XCUITestDriver but is defined in pcap.js (JS file), so TypeScript can't verify it
470
469
  command: 'mobileStartPcap',
471
470
  params: {
472
471
  optional: ['timeLimitSec', 'forceRestart'],
473
472
  },
474
473
  },
475
474
  'mobile: stopPcap': {
476
- // @ts-expect-error Method exists on XCUITestDriver but is defined in pcap.js (JS file), so TypeScript can't verify it
477
475
  command: 'mobileStopPcap',
478
476
  },
479
477
  'mobile: listConditionInducers': {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-xcuitest-driver",
3
- "version": "10.14.1",
3
+ "version": "10.14.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-xcuitest-driver",
9
- "version": "10.14.1",
9
+ "version": "10.14.2",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@appium/strongbox": "^1.0.0-rc.1",
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "xcuitest",
9
9
  "xctest"
10
10
  ],
11
- "version": "10.14.1",
11
+ "version": "10.14.2",
12
12
  "author": "Appium Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "repository": {