@appium/fake-driver 5.2.4 → 5.2.5
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/commands/find.d.ts +2 -1
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +39 -38
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +2 -2
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +1 -0
- package/build/lib/commands/general.js.map +1 -1
- package/lib/commands/find.ts +70 -46
- package/lib/commands/general.ts +3 -2
- package/package.json +2 -2
|
@@ -4,7 +4,8 @@ import { FakeDriver } from '../driver';
|
|
|
4
4
|
interface FakeDriverFindMixin {
|
|
5
5
|
getExistingElementForNode(node: FakeElement): string | null;
|
|
6
6
|
wrapNewEl(obj: FakeElement): Element;
|
|
7
|
-
findElOrEls
|
|
7
|
+
findElOrEls(this: FakeDriver, strategy: string, selector: string, mult: true, context?: any): Promise<Element[]>;
|
|
8
|
+
findElOrEls(this: FakeDriver, strategy: string, selector: string, mult: false, context?: any): Promise<Element>;
|
|
8
9
|
findElement(strategy: string, selector: string): Promise<Element>;
|
|
9
10
|
findElements(strategy: string, selector: string): Promise<Element[]>;
|
|
10
11
|
findElementFromElement(elementId: string, strategy: string, selector: string): Promise<Element>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../lib/commands/find.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../lib/commands/find.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAC,WA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");
|
|
11
11
|
const { W3C_WEB_ELEMENT_IDENTIFIER } = support_1.util;
|
|
12
|
+
async function findElOrEls(strategy, selector, mult, context) {
|
|
13
|
+
const qMap = {
|
|
14
|
+
xpath: 'xpathQuery',
|
|
15
|
+
id: 'idQuery',
|
|
16
|
+
'accessibility id': 'idQuery',
|
|
17
|
+
'class name': 'classQuery',
|
|
18
|
+
'tag name': 'classQuery',
|
|
19
|
+
'css selector': 'cssQuery',
|
|
20
|
+
};
|
|
21
|
+
// TODO this error checking should probably be part of MJSONWP?
|
|
22
|
+
if (!lodash_1.default.includes(lodash_1.default.keys(qMap), strategy)) {
|
|
23
|
+
throw new driver_1.errors.UnknownCommandError();
|
|
24
|
+
}
|
|
25
|
+
if (selector === 'badsel') {
|
|
26
|
+
throw new driver_1.errors.InvalidSelectorError();
|
|
27
|
+
}
|
|
28
|
+
const els = this.appModel[qMap[strategy]](selector, context);
|
|
29
|
+
let retval;
|
|
30
|
+
if (els.length) {
|
|
31
|
+
if (mult) {
|
|
32
|
+
const allEls = [];
|
|
33
|
+
for (const el of els) {
|
|
34
|
+
allEls.push(this.wrapNewEl(el));
|
|
35
|
+
}
|
|
36
|
+
retval = allEls;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
retval = this.wrapNewEl(els[0]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (mult) {
|
|
43
|
+
retval = [];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new driver_1.errors.NoSuchElementError();
|
|
47
|
+
}
|
|
48
|
+
return retval;
|
|
49
|
+
}
|
|
12
50
|
const FindMixin = {
|
|
13
51
|
getExistingElementForNode(node) {
|
|
14
52
|
for (const [id, el] of lodash_1.default.toPairs(this.elMap)) {
|
|
@@ -30,44 +68,7 @@ const FindMixin = {
|
|
|
30
68
|
this.elMap[maxElId] = new fake_element_1.FakeElement(obj, this.appModel);
|
|
31
69
|
return { ELEMENT: maxElId, [W3C_WEB_ELEMENT_IDENTIFIER]: maxElId };
|
|
32
70
|
},
|
|
33
|
-
|
|
34
|
-
const qMap = {
|
|
35
|
-
xpath: 'xpathQuery',
|
|
36
|
-
id: 'idQuery',
|
|
37
|
-
'accessibility id': 'idQuery',
|
|
38
|
-
'class name': 'classQuery',
|
|
39
|
-
'tag name': 'classQuery',
|
|
40
|
-
'css selector': 'cssQuery',
|
|
41
|
-
};
|
|
42
|
-
// TODO this error checking should probably be part of MJSONWP?
|
|
43
|
-
if (!lodash_1.default.includes(lodash_1.default.keys(qMap), strategy)) {
|
|
44
|
-
throw new driver_1.errors.UnknownCommandError();
|
|
45
|
-
}
|
|
46
|
-
if (selector === 'badsel') {
|
|
47
|
-
throw new driver_1.errors.InvalidSelectorError();
|
|
48
|
-
}
|
|
49
|
-
const els = this.appModel[qMap[strategy]](selector, context);
|
|
50
|
-
let retval;
|
|
51
|
-
if (els.length) {
|
|
52
|
-
if (many) {
|
|
53
|
-
const allEls = [];
|
|
54
|
-
for (const el of els) {
|
|
55
|
-
allEls.push(this.wrapNewEl(el));
|
|
56
|
-
}
|
|
57
|
-
retval = allEls;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
retval = this.wrapNewEl(els[0]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (many) {
|
|
64
|
-
retval = [];
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
throw new driver_1.errors.NoSuchElementError();
|
|
68
|
-
}
|
|
69
|
-
return retval;
|
|
70
|
-
},
|
|
71
|
+
findElOrEls,
|
|
71
72
|
/**
|
|
72
73
|
* This should override whatever's in ExternalDriver
|
|
73
74
|
* @param {string} strategy Strategy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../lib/commands/find.ts"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AAEvB,0CAAqC;AACrC,kDAA4C;AAE5C,6CAAqC;AACrC,mCAA8B;AAE9B,MAAM,EAAC,0BA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AAE,QAAgB;QACrE,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,sBAAsB,CAE1B,QAAgB,EAChB,QAAgB,EAChB,SAAiB;QAEjB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,uBAAuB,CAE3B,QAAgB,EAChB,QAAgB,EAChB,SAAiB;QAEjB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IACpE,CAAC;CACF,CAAC;AAEF,IAAA,aAAK,EAAC,SAAS,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { Orientation } from '../driver';
|
|
|
3
3
|
interface FakeDriverGeneralMixin {
|
|
4
4
|
title(): Promise<string>;
|
|
5
5
|
keys(value: string | string[]): Promise<void>;
|
|
6
|
-
setGeoLocation(location: Location): Promise<
|
|
6
|
+
setGeoLocation(location: Location): Promise<Location>;
|
|
7
7
|
getGeoLocation(): Promise<Location>;
|
|
8
8
|
getPageSource(): Promise<string>;
|
|
9
9
|
getOrientation(): Promise<string>;
|
|
@@ -17,7 +17,7 @@ interface FakeDriverGeneralMixin {
|
|
|
17
17
|
doubleClick(): Promise<void>;
|
|
18
18
|
execute(script: string, args: any[]): Promise<any>;
|
|
19
19
|
fakeAddition(a: number, b: number, c?: number): Promise<number>;
|
|
20
|
-
getLog(type: string): Promise<
|
|
20
|
+
getLog(type: string): Promise<any>;
|
|
21
21
|
}
|
|
22
22
|
declare module '../driver' {
|
|
23
23
|
interface FakeDriver extends FakeDriverGeneralMixin {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../lib/commands/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAa,WAAW,EAAC,MAAM,WAAW,CAAC;AAKlD,UAAU,sBAAsB;IAC9B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../lib/commands/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAa,WAAW,EAAC,MAAM,WAAW,CAAC;AAKlD,UAAU,sBAAsB;IAC9B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,aAAa,IAAI,OAAO,CAA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AAC;IAEtC,KAAK,CAAC,OAAO,CAAmB,MAAc,EAAE,IAAW;QACzD,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAAmB,IAAY,EAAE,IAAY,EAAE,IAAI,GAAG,CAAC;QACvE,OAAO,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IACnC,CAAC;CACF,CAAC;AAEF,IAAA,aAAK,EAAC,YAAY,CAAC,CAAC"}
|
package/lib/commands/find.ts
CHANGED
|
@@ -7,17 +7,82 @@ import {util} from '@appium/support';
|
|
|
7
7
|
import {mixin} from './mixin';
|
|
8
8
|
|
|
9
9
|
const {W3C_WEB_ELEMENT_IDENTIFIER} = util;
|
|
10
|
+
|
|
11
|
+
async function findElOrEls<Ctx = any>(
|
|
12
|
+
this: FakeDriver<any>,
|
|
13
|
+
strategy: string,
|
|
14
|
+
selector: string,
|
|
15
|
+
mult: true,
|
|
16
|
+
context?: Ctx
|
|
17
|
+
): Promise<Element[]>;
|
|
18
|
+
async function findElOrEls<Ctx = any>(
|
|
19
|
+
this: FakeDriver<any>,
|
|
20
|
+
strategy: string,
|
|
21
|
+
selector: string,
|
|
22
|
+
mult: false,
|
|
23
|
+
context?: Ctx
|
|
24
|
+
): Promise<Element>;
|
|
25
|
+
async function findElOrEls<Ctx = any>(
|
|
26
|
+
this: FakeDriver<any>,
|
|
27
|
+
strategy: string,
|
|
28
|
+
selector: string,
|
|
29
|
+
mult: boolean,
|
|
30
|
+
context?: Ctx
|
|
31
|
+
): Promise<Element | Element[]> {
|
|
32
|
+
const qMap = {
|
|
33
|
+
xpath: 'xpathQuery',
|
|
34
|
+
id: 'idQuery',
|
|
35
|
+
'accessibility id': 'idQuery',
|
|
36
|
+
'class name': 'classQuery',
|
|
37
|
+
'tag name': 'classQuery',
|
|
38
|
+
'css selector': 'cssQuery',
|
|
39
|
+
} as Record<string, keyof FakeDriver['appModel']>;
|
|
40
|
+
// TODO this error checking should probably be part of MJSONWP?
|
|
41
|
+
if (!_.includes(_.keys(qMap), strategy)) {
|
|
42
|
+
throw new errors.UnknownCommandError();
|
|
43
|
+
}
|
|
44
|
+
if (selector === 'badsel') {
|
|
45
|
+
throw new errors.InvalidSelectorError();
|
|
46
|
+
}
|
|
47
|
+
const els = this.appModel[qMap[strategy]](selector, context);
|
|
48
|
+
|
|
49
|
+
let retval: Element | Element[];
|
|
50
|
+
if (els.length) {
|
|
51
|
+
if (mult) {
|
|
52
|
+
const allEls: Element[] = [];
|
|
53
|
+
for (const el of els) {
|
|
54
|
+
allEls.push(this.wrapNewEl(el));
|
|
55
|
+
}
|
|
56
|
+
retval = allEls;
|
|
57
|
+
} else {
|
|
58
|
+
retval = this.wrapNewEl(els[0]);
|
|
59
|
+
}
|
|
60
|
+
} else if (mult) {
|
|
61
|
+
retval = [];
|
|
62
|
+
} else {
|
|
63
|
+
throw new errors.NoSuchElementError();
|
|
64
|
+
}
|
|
65
|
+
return retval;
|
|
66
|
+
}
|
|
67
|
+
|
|
10
68
|
interface FakeDriverFindMixin {
|
|
11
69
|
getExistingElementForNode(node: FakeElement): string | null;
|
|
12
70
|
wrapNewEl(obj: FakeElement): Element;
|
|
13
71
|
|
|
14
|
-
findElOrEls
|
|
72
|
+
findElOrEls(
|
|
73
|
+
this: FakeDriver,
|
|
74
|
+
strategy: string,
|
|
75
|
+
selector: string,
|
|
76
|
+
mult: true,
|
|
77
|
+
context?: any
|
|
78
|
+
): Promise<Element[]>;
|
|
79
|
+
findElOrEls(
|
|
15
80
|
this: FakeDriver,
|
|
16
81
|
strategy: string,
|
|
17
82
|
selector: string,
|
|
18
|
-
|
|
19
|
-
context?:
|
|
20
|
-
): Promise<
|
|
83
|
+
mult: false,
|
|
84
|
+
context?: any
|
|
85
|
+
): Promise<Element>;
|
|
21
86
|
findElement(strategy: string, selector: string): Promise<Element>;
|
|
22
87
|
findElements(strategy: string, selector: string): Promise<Element[]>;
|
|
23
88
|
findElementFromElement(elementId: string, strategy: string, selector: string): Promise<Element>;
|
|
@@ -56,48 +121,7 @@ const FindMixin: FakeDriverFindMixin = {
|
|
|
56
121
|
return {ELEMENT: maxElId, [W3C_WEB_ELEMENT_IDENTIFIER]: maxElId};
|
|
57
122
|
},
|
|
58
123
|
|
|
59
|
-
|
|
60
|
-
this: FakeDriver,
|
|
61
|
-
strategy: string,
|
|
62
|
-
selector: string,
|
|
63
|
-
many: Many,
|
|
64
|
-
context: Ctx
|
|
65
|
-
): Promise<Many extends true ? Element[] : Element> {
|
|
66
|
-
const qMap = {
|
|
67
|
-
xpath: 'xpathQuery',
|
|
68
|
-
id: 'idQuery',
|
|
69
|
-
'accessibility id': 'idQuery',
|
|
70
|
-
'class name': 'classQuery',
|
|
71
|
-
'tag name': 'classQuery',
|
|
72
|
-
'css selector': 'cssQuery',
|
|
73
|
-
} as Record<string, keyof FakeDriver['appModel']>;
|
|
74
|
-
// TODO this error checking should probably be part of MJSONWP?
|
|
75
|
-
if (!_.includes(_.keys(qMap), strategy)) {
|
|
76
|
-
throw new errors.UnknownCommandError();
|
|
77
|
-
}
|
|
78
|
-
if (selector === 'badsel') {
|
|
79
|
-
throw new errors.InvalidSelectorError();
|
|
80
|
-
}
|
|
81
|
-
const els = this.appModel[qMap[strategy]](selector, context);
|
|
82
|
-
|
|
83
|
-
let retval: Element | Element[];
|
|
84
|
-
if (els.length) {
|
|
85
|
-
if (many) {
|
|
86
|
-
const allEls: Element[] = [];
|
|
87
|
-
for (const el of els) {
|
|
88
|
-
allEls.push(this.wrapNewEl(el));
|
|
89
|
-
}
|
|
90
|
-
retval = allEls;
|
|
91
|
-
} else {
|
|
92
|
-
retval = this.wrapNewEl(els[0]);
|
|
93
|
-
}
|
|
94
|
-
} else if (many) {
|
|
95
|
-
retval = [];
|
|
96
|
-
} else {
|
|
97
|
-
throw new errors.NoSuchElementError();
|
|
98
|
-
}
|
|
99
|
-
return retval as Many extends true ? Element[] : Element;
|
|
100
|
-
},
|
|
124
|
+
findElOrEls,
|
|
101
125
|
|
|
102
126
|
/**
|
|
103
127
|
* This should override whatever's in ExternalDriver
|
package/lib/commands/general.ts
CHANGED
|
@@ -8,7 +8,7 @@ const ORIENTATIONS = new Set(['LANDSCAPE', 'PORTRAIT']);
|
|
|
8
8
|
interface FakeDriverGeneralMixin {
|
|
9
9
|
title(): Promise<string>;
|
|
10
10
|
keys(value: string | string[]): Promise<void>;
|
|
11
|
-
setGeoLocation(location: Location): Promise<
|
|
11
|
+
setGeoLocation(location: Location): Promise<Location>;
|
|
12
12
|
getGeoLocation(): Promise<Location>;
|
|
13
13
|
getPageSource(): Promise<string>;
|
|
14
14
|
getOrientation(): Promise<string>;
|
|
@@ -22,7 +22,7 @@ interface FakeDriverGeneralMixin {
|
|
|
22
22
|
doubleClick(): Promise<void>;
|
|
23
23
|
execute(script: string, args: any[]): Promise<any>;
|
|
24
24
|
fakeAddition(a: number, b: number, c?: number): Promise<number>;
|
|
25
|
-
getLog(type: string): Promise<
|
|
25
|
+
getLog(type: string): Promise<any>;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
declare module '../driver' {
|
|
@@ -46,6 +46,7 @@ const GeneralMixin: FakeDriverGeneralMixin = {
|
|
|
46
46
|
// TODO test this adequately once WD bug is fixed
|
|
47
47
|
this.appModel.lat = location.latitude;
|
|
48
48
|
this.appModel.long = location.longitude;
|
|
49
|
+
return location;
|
|
49
50
|
},
|
|
50
51
|
|
|
51
52
|
async getGeoLocation(this: FakeDriver) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/fake-driver",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.5",
|
|
4
4
|
"description": "Mock driver used internally by Appium for testing. Ignore",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"entryPoint": "./lib/index.js"
|
|
84
84
|
},
|
|
85
85
|
"types": "./build/lib/index.d.ts",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "ed20e007548e10f89a5212b2868ed7ec47f51c2a"
|
|
87
87
|
}
|