@appium/fake-driver 6.1.1 → 6.1.3
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/build/lib/command-maps/execute-method-map.d.ts +22 -0
- package/build/lib/command-maps/execute-method-map.d.ts.map +1 -0
- package/build/lib/command-maps/execute-method-map.js +20 -0
- package/build/lib/command-maps/execute-method-map.js.map +1 -0
- package/build/lib/command-maps/new-bidi-commands.d.ts +26 -0
- package/build/lib/command-maps/new-bidi-commands.d.ts.map +1 -0
- package/build/lib/command-maps/new-bidi-commands.js +29 -0
- package/build/lib/command-maps/new-bidi-commands.js.map +1 -0
- package/build/lib/command-maps/new-method-map.d.ts +30 -0
- package/build/lib/command-maps/new-method-map.d.ts.map +1 -0
- package/build/lib/command-maps/new-method-map.js +19 -0
- package/build/lib/command-maps/new-method-map.js.map +1 -0
- package/build/lib/commands/alert.d.ts +3 -0
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +3 -0
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/contexts.d.ts +4 -0
- package/build/lib/commands/contexts.d.ts.map +1 -1
- package/build/lib/commands/contexts.js +4 -0
- package/build/lib/commands/contexts.js.map +1 -1
- package/build/lib/commands/element.d.ts +14 -0
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +14 -0
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/find.d.ts +6 -0
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +5 -0
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +15 -0
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +15 -0
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/driver.d.ts +84 -84
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +27 -77
- package/build/lib/driver.js.map +1 -1
- package/build/lib/fake-app.d.ts +4 -4
- package/build/lib/fake-app.d.ts.map +1 -1
- package/build/lib/fake-app.js +13 -13
- package/build/lib/fake-app.js.map +1 -1
- package/build/lib/fake-element.d.ts +2 -2
- package/build/lib/fake-element.d.ts.map +1 -1
- package/build/lib/fake-element.js +14 -14
- package/build/lib/fake-element.js.map +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +1 -0
- package/build/lib/index.js.map +1 -1
- package/lib/command-maps/execute-method-map.ts +19 -0
- package/lib/command-maps/new-bidi-commands.ts +27 -0
- package/lib/command-maps/new-method-map.ts +18 -0
- package/lib/commands/alert.ts +3 -0
- package/lib/commands/contexts.ts +4 -0
- package/lib/commands/element.ts +14 -0
- package/lib/commands/find.ts +7 -0
- package/lib/commands/general.ts +15 -0
- package/lib/driver.ts +36 -87
- package/lib/fake-app.ts +16 -16
- package/lib/fake-element.ts +20 -20
- package/lib/index.ts +1 -0
- package/package.json +4 -4
- package/tsconfig.json +4 -0
package/lib/fake-app.ts
CHANGED
|
@@ -24,11 +24,11 @@ export class FakeApp {
|
|
|
24
24
|
activeAlert: FakeElement | null;
|
|
25
25
|
lat: number;
|
|
26
26
|
long: number;
|
|
27
|
-
private _width: number | null;
|
|
28
|
-
private _height: number | null;
|
|
29
27
|
rawXml: string;
|
|
30
28
|
currentOrientation: Orientation;
|
|
31
29
|
actionLog: ActionSequence[][];
|
|
30
|
+
private _width: number | null;
|
|
31
|
+
private _height: number | null;
|
|
32
32
|
|
|
33
33
|
constructor() {
|
|
34
34
|
this.dom = null;
|
|
@@ -66,10 +66,6 @@ export class FakeApp {
|
|
|
66
66
|
return this.currentOrientation;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
set orientation(o: Orientation) {
|
|
70
|
-
this.currentOrientation = o;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
69
|
get width(): number {
|
|
74
70
|
if (this._width === null) {
|
|
75
71
|
this.setDims();
|
|
@@ -92,16 +88,8 @@ export class FakeApp {
|
|
|
92
88
|
return h;
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (!_.isArray(nodes)) {
|
|
98
|
-
throw new Error(
|
|
99
|
-
'Cannot fetch app dimensions because no corresponding node has been found in the source'
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
const app = new FakeElement(nodes[0] as unknown as XmlNodeLike, this);
|
|
103
|
-
this._width = parseInt(app.nodeAttrs.width, 10);
|
|
104
|
-
this._height = parseInt(app.nodeAttrs.height, 10);
|
|
91
|
+
set orientation(o: Orientation) {
|
|
92
|
+
this.currentOrientation = o;
|
|
105
93
|
}
|
|
106
94
|
|
|
107
95
|
async loadApp(appPath: string): Promise<void> {
|
|
@@ -224,6 +212,18 @@ export class FakeApp {
|
|
|
224
212
|
getScreenshot(): string {
|
|
225
213
|
return readFileSync(SCREENSHOT, 'base64');
|
|
226
214
|
}
|
|
215
|
+
|
|
216
|
+
private setDims(): void {
|
|
217
|
+
const nodes = this.xpathQuery('//app');
|
|
218
|
+
if (!_.isArray(nodes)) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
'Cannot fetch app dimensions because no corresponding node has been found in the source'
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
const app = new FakeElement(nodes[0] as unknown as XmlNodeLike, this);
|
|
224
|
+
this._width = parseInt(app.nodeAttrs.width, 10);
|
|
225
|
+
this._height = parseInt(app.nodeAttrs.height, 10);
|
|
226
|
+
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
export class FakeWebViewImpl implements FakeWebView {
|
package/lib/fake-element.ts
CHANGED
|
@@ -38,22 +38,20 @@ export class FakeElement {
|
|
|
38
38
|
this.parseCss();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
private parseCss(): void {
|
|
42
|
-
if (this.nodeAttrs.style) {
|
|
43
|
-
const segments = this.nodeAttrs.style.split(';');
|
|
44
|
-
for (const s of segments) {
|
|
45
|
-
let [prop, val] = s.split(':');
|
|
46
|
-
prop = prop.trim();
|
|
47
|
-
val = val.trim();
|
|
48
|
-
this.css[prop] = val;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
41
|
get tagName(): string {
|
|
54
42
|
return this.node.tagName;
|
|
55
43
|
}
|
|
56
44
|
|
|
45
|
+
get xmlFragment(): XMLDocument {
|
|
46
|
+
const frag = new XMLDom.XMLSerializer().serializeToString(
|
|
47
|
+
this.node as unknown as XMLNode
|
|
48
|
+
);
|
|
49
|
+
return new XMLDom.DOMParser().parseFromString(
|
|
50
|
+
frag,
|
|
51
|
+
XMLDom.MIME_TYPE.XML_TEXT
|
|
52
|
+
) as XMLDocument;
|
|
53
|
+
}
|
|
54
|
+
|
|
57
55
|
setAttr(k: string, v: string): void {
|
|
58
56
|
this.attrs[k] = v;
|
|
59
57
|
}
|
|
@@ -116,13 +114,15 @@ export class FakeElement {
|
|
|
116
114
|
return null;
|
|
117
115
|
}
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
private parseCss(): void {
|
|
118
|
+
if (this.nodeAttrs.style) {
|
|
119
|
+
const segments = this.nodeAttrs.style.split(';');
|
|
120
|
+
for (const s of segments) {
|
|
121
|
+
let [prop, val] = s.split(':');
|
|
122
|
+
prop = prop.trim();
|
|
123
|
+
val = val.trim();
|
|
124
|
+
this.css[prop] = val;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
127
|
}
|
|
128
128
|
}
|
package/lib/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/fake-driver",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.3",
|
|
4
4
|
"description": "Mock driver used internally by Appium for testing. Ignore",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"test:unit": "mocha --exit --timeout 10s --slow 5s \"./test/unit/**/*.spec.ts\""
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@xmldom/xmldom": "0.9.
|
|
44
|
-
"asyncbox": "6.
|
|
43
|
+
"@xmldom/xmldom": "0.9.10",
|
|
44
|
+
"asyncbox": "6.2.0",
|
|
45
45
|
"lodash": "4.18.1",
|
|
46
46
|
"xpath": "0.0.34"
|
|
47
47
|
},
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
},
|
|
79
79
|
"main": "./build/lib/index.js",
|
|
80
80
|
"types": "./build/lib/index.d.ts",
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "915d767085c6b40ae90b7592d5130c76414ca3b5"
|
|
82
82
|
}
|
package/tsconfig.json
CHANGED