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.
- package/CHANGELOG.md +6 -0
- package/build/lib/commands/execute.d.ts +10 -22
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +12 -28
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/location.d.ts +8 -11
- package/build/lib/commands/location.d.ts.map +1 -1
- package/build/lib/commands/location.js +7 -15
- package/build/lib/commands/location.js.map +1 -1
- package/build/lib/commands/navigation.d.ts +14 -26
- package/build/lib/commands/navigation.d.ts.map +1 -1
- package/build/lib/commands/navigation.js +10 -18
- package/build/lib/commands/navigation.js.map +1 -1
- package/build/lib/commands/pcap.d.ts +18 -38
- package/build/lib/commands/pcap.d.ts.map +1 -1
- package/build/lib/commands/pcap.js +9 -14
- package/build/lib/commands/pcap.js.map +1 -1
- package/build/lib/commands/screenshots.d.ts +15 -9
- package/build/lib/commands/screenshots.d.ts.map +1 -1
- package/build/lib/commands/screenshots.js +13 -11
- package/build/lib/commands/screenshots.js.map +1 -1
- package/build/lib/commands/source.d.ts +10 -8
- package/build/lib/commands/source.d.ts.map +1 -1
- package/build/lib/commands/source.js +11 -14
- package/build/lib/commands/source.js.map +1 -1
- package/build/lib/driver.js +1 -1
- package/build/lib/driver.js.map +1 -1
- package/build/lib/execute-method-map.d.ts.map +1 -1
- package/build/lib/execute-method-map.js +0 -2
- package/build/lib/execute-method-map.js.map +1 -1
- package/lib/commands/{execute.js → execute.ts} +41 -37
- package/lib/commands/{location.js → location.ts} +19 -22
- package/lib/commands/{navigation.js → navigation.ts} +23 -26
- package/lib/commands/{pcap.js → pcap.ts} +28 -28
- package/lib/commands/{screenshots.js → screenshots.ts} +24 -16
- package/lib/commands/{source.js → source.ts} +23 -20
- package/lib/driver.ts +1 -1
- package/lib/execute-method-map.ts +0 -2
- package/npm-shrinkwrap.json +2 -2
- 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
|
-
*
|
|
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
|
|
32
|
-
* @param
|
|
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
|
|
35
|
-
* @this {XCUITestDriver}
|
|
38
|
+
* @returns The source tree of the current page in the given format.
|
|
36
39
|
*/
|
|
37
|
-
export async function mobileGetSource(
|
|
38
|
-
|
|
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
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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': {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-xcuitest-driver",
|
|
3
|
-
"version": "10.14.
|
|
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.
|
|
9
|
+
"version": "10.14.2",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@appium/strongbox": "^1.0.0-rc.1",
|