@appium/fake-driver 5.1.3 → 5.1.4
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/alert.d.ts +58 -310
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +58 -69
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/contexts.d.ts +81 -330
- package/build/lib/commands/contexts.d.ts.map +1 -1
- package/build/lib/commands/contexts.js +75 -84
- package/build/lib/commands/contexts.js.map +1 -1
- package/build/lib/commands/element.d.ts +146 -315
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +134 -98
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/find.d.ts +83 -327
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +93 -97
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +174 -332
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +119 -90
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/index.d.ts +5 -1523
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +14 -14
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/driver.d.ts +80 -15
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +74 -24
- package/build/lib/driver.js.map +1 -1
- package/build/lib/types.d.ts +1 -24
- package/build/lib/types.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/commands/alert.js +58 -67
- package/lib/commands/contexts.js +72 -81
- package/lib/commands/element.js +135 -94
- package/lib/commands/find.js +94 -98
- package/lib/commands/general.js +119 -91
- package/lib/commands/index.js +5 -13
- package/lib/driver.js +76 -20
- package/lib/types.ts +1 -29
- package/package.json +2 -2
package/lib/commands/contexts.js
CHANGED
|
@@ -1,101 +1,92 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import {errors} from 'appium/driver';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @template {Class<import('../types').IFakeDriver>} T
|
|
7
|
-
* @param {T} Base
|
|
8
|
-
*/
|
|
9
|
-
export function ContextsMixin(Base) {
|
|
4
|
+
export default {
|
|
10
5
|
/**
|
|
11
|
-
* @
|
|
6
|
+
* @this {FakeDriver}
|
|
12
7
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
contexts[`WEBVIEW_${i}`] = wvs[i - 1];
|
|
19
|
-
}
|
|
20
|
-
return contexts;
|
|
8
|
+
getRawContexts() {
|
|
9
|
+
let contexts = {NATIVE_APP: null, PROXY: null};
|
|
10
|
+
let wvs = this.appModel?.getWebviews() ?? [];
|
|
11
|
+
for (let i = 1; i < wvs.length + 1; i++) {
|
|
12
|
+
contexts[`WEBVIEW_${i}`] = wvs[i - 1];
|
|
21
13
|
}
|
|
14
|
+
return contexts;
|
|
15
|
+
},
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @this {FakeDriver}
|
|
19
|
+
*/
|
|
20
|
+
assertWebviewContext() {
|
|
21
|
+
if (this.curContext === 'NATIVE_APP') {
|
|
22
|
+
throw new errors.InvalidContextError();
|
|
27
23
|
}
|
|
24
|
+
},
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @returns {Promise<string>}
|
|
28
|
+
* @this {FakeDriver}
|
|
29
|
+
*/
|
|
30
|
+
async getCurrentContext() {
|
|
31
|
+
return this.curContext;
|
|
32
|
+
},
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Get the list of available contexts
|
|
36
|
+
*
|
|
37
|
+
* @returns {Promise<string[]>}
|
|
38
|
+
* @this {FakeDriver}
|
|
39
|
+
*/
|
|
40
|
+
async getContexts() {
|
|
41
|
+
return _.keys(this.getRawContexts());
|
|
42
|
+
},
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.appModel.activateWebview(contexts[context]);
|
|
63
|
-
this._proxyActive = false;
|
|
64
|
-
}
|
|
44
|
+
/**
|
|
45
|
+
* Set the current context
|
|
46
|
+
*
|
|
47
|
+
* @param {string} context - name of the context
|
|
48
|
+
* @returns {Promise<void>}
|
|
49
|
+
* @this {FakeDriver}
|
|
50
|
+
*/
|
|
51
|
+
async setContext(context) {
|
|
52
|
+
let contexts = this.getRawContexts();
|
|
53
|
+
if (context in contexts) {
|
|
54
|
+
this.curContext = context;
|
|
55
|
+
if (context === 'NATIVE_APP') {
|
|
56
|
+
this.appModel.deactivateWebview();
|
|
57
|
+
this._proxyActive = false;
|
|
58
|
+
} else if (context === 'PROXY') {
|
|
59
|
+
this._proxyActive = true;
|
|
65
60
|
} else {
|
|
66
|
-
|
|
61
|
+
this.appModel.activateWebview(contexts[context]);
|
|
62
|
+
this._proxyActive = false;
|
|
67
63
|
}
|
|
64
|
+
} else {
|
|
65
|
+
throw new errors.NoSuchContextError();
|
|
68
66
|
}
|
|
67
|
+
},
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.appModel.activateFrame(nodes[0]);
|
|
69
|
+
/**
|
|
70
|
+
* Set the active frame
|
|
71
|
+
*
|
|
72
|
+
* @param {number} frameId
|
|
73
|
+
* @returns {Promise<void>}
|
|
74
|
+
* @this {FakeDriver}
|
|
75
|
+
*/
|
|
76
|
+
async setFrame(frameId) {
|
|
77
|
+
this.assertWebviewContext();
|
|
78
|
+
if (frameId === null) {
|
|
79
|
+
this.appModel.deactivateFrame();
|
|
80
|
+
} else {
|
|
81
|
+
let nodes = this.appModel.xpathQuery(`//iframe[@id="${frameId}"]`);
|
|
82
|
+
if (!nodes.length) {
|
|
83
|
+
throw new errors.NoSuchFrameError();
|
|
86
84
|
}
|
|
85
|
+
this.appModel.activateFrame(nodes[0]);
|
|
87
86
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return ContextsCommands;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @typedef {import('../driver').FakeDriverCore} FakeDriverCore
|
|
95
|
-
* @typedef {import('../types').IContextsCommands} IContextsCommands
|
|
96
|
-
*/
|
|
87
|
+
},
|
|
88
|
+
};
|
|
97
89
|
|
|
98
90
|
/**
|
|
99
|
-
* @
|
|
100
|
-
* @typedef {import('@appium/types').Class<T,U,V>} Class
|
|
91
|
+
* @typedef {import('../driver').FakeDriver} FakeDriver
|
|
101
92
|
*/
|
package/lib/commands/element.js
CHANGED
|
@@ -1,120 +1,161 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import {errors} from 'appium/driver';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @template {Class<import('../types').IContextsCommands & import('../types').IAlertCommands>} T
|
|
6
|
-
* @param {T} Base
|
|
7
|
-
*/
|
|
8
|
-
export function ElementMixin(Base) {
|
|
3
|
+
export default {
|
|
9
4
|
/**
|
|
10
|
-
* @
|
|
5
|
+
* @this {FakeDriver}
|
|
11
6
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
throw new errors.StaleElementReferenceError();
|
|
17
|
-
}
|
|
7
|
+
getElements(elIds) {
|
|
8
|
+
for (let elId of elIds) {
|
|
9
|
+
if (!_.has(this.elMap, elId)) {
|
|
10
|
+
throw new errors.StaleElementReferenceError();
|
|
18
11
|
}
|
|
19
|
-
return elIds.map((e) => this.elMap[e]);
|
|
20
12
|
}
|
|
13
|
+
return elIds.map((e) => this.elMap[e]);
|
|
14
|
+
},
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @this {FakeDriver}
|
|
18
|
+
*/
|
|
19
|
+
getElement(elId) {
|
|
20
|
+
return this.getElements([elId])[0];
|
|
21
|
+
},
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @this {FakeDriver}
|
|
25
|
+
*/
|
|
26
|
+
async getName(elementId) {
|
|
27
|
+
let el = this.getElement(elementId);
|
|
28
|
+
return el.tagName;
|
|
29
|
+
},
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @this {FakeDriver}
|
|
33
|
+
*/
|
|
34
|
+
async elementDisplayed(elementId) {
|
|
35
|
+
let el = this.getElement(elementId);
|
|
36
|
+
return el.isVisible();
|
|
37
|
+
},
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @this {FakeDriver}
|
|
41
|
+
*/
|
|
42
|
+
async elementEnabled(elementId) {
|
|
43
|
+
let el = this.getElement(elementId);
|
|
44
|
+
return el.isEnabled();
|
|
45
|
+
},
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @this {FakeDriver}
|
|
49
|
+
*/
|
|
50
|
+
async elementSelected(elementId) {
|
|
51
|
+
let el = this.getElement(elementId);
|
|
52
|
+
return el.isSelected();
|
|
53
|
+
},
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
throw new errors.InvalidElementStateError();
|
|
54
|
-
}
|
|
55
|
-
el.setAttr('value', value);
|
|
55
|
+
/**
|
|
56
|
+
* @this {FakeDriver}
|
|
57
|
+
*/
|
|
58
|
+
async setValue(keys, elementId) {
|
|
59
|
+
let value = keys;
|
|
60
|
+
if (keys instanceof Array) {
|
|
61
|
+
value = keys.join('');
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return el.getAttr('value');
|
|
63
|
+
let el = this.getElement(elementId);
|
|
64
|
+
if (el.type !== 'MockInputField') {
|
|
65
|
+
throw new errors.InvalidElementStateError();
|
|
61
66
|
}
|
|
67
|
+
el.setAttr('value', value);
|
|
68
|
+
},
|
|
62
69
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
/**
|
|
71
|
+
* @this {FakeDriver}
|
|
72
|
+
*/
|
|
73
|
+
async getText(elementId) {
|
|
74
|
+
let el = this.getElement(elementId);
|
|
75
|
+
return el.getAttr('value');
|
|
76
|
+
},
|
|
66
77
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
let el = this.getElement(elementId);
|
|
74
|
-
if (!el.isVisible()) {
|
|
75
|
-
throw new errors.InvalidElementStateError();
|
|
76
|
-
}
|
|
77
|
-
el.click();
|
|
78
|
-
this.focusedElId = elementId;
|
|
79
|
-
}
|
|
78
|
+
/**
|
|
79
|
+
* @this {FakeDriver}
|
|
80
|
+
*/
|
|
81
|
+
async clear(elementId) {
|
|
82
|
+
await this.setValue('', elementId);
|
|
83
|
+
},
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return el.getSize();
|
|
85
|
+
/**
|
|
86
|
+
* This comment should be displayed instead of the one from ExternalDriver
|
|
87
|
+
* @param {string} elementId
|
|
88
|
+
* @this {FakeDriver}
|
|
89
|
+
*/
|
|
90
|
+
async click(elementId) {
|
|
91
|
+
this.assertNoAlert();
|
|
92
|
+
let el = this.getElement(elementId);
|
|
93
|
+
if (!el.isVisible()) {
|
|
94
|
+
throw new errors.InvalidElementStateError();
|
|
92
95
|
}
|
|
96
|
+
el.click();
|
|
97
|
+
this.focusedElId = elementId;
|
|
98
|
+
},
|
|
93
99
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
/**
|
|
101
|
+
* @this {FakeDriver}
|
|
102
|
+
*/
|
|
103
|
+
async getAttribute(attr, elementId) {
|
|
104
|
+
let el = this.getElement(elementId);
|
|
105
|
+
return el.getAttr(attr);
|
|
106
|
+
},
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
/**
|
|
109
|
+
* @this {FakeDriver}
|
|
110
|
+
*/
|
|
111
|
+
getElementRect(elementId) {
|
|
112
|
+
let el = this.getElement(elementId);
|
|
113
|
+
return el.getElementRect();
|
|
114
|
+
},
|
|
105
115
|
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
/**
|
|
117
|
+
* @this {FakeDriver}
|
|
118
|
+
*/
|
|
119
|
+
getSize(elementId) {
|
|
120
|
+
let el = this.getElement(elementId);
|
|
121
|
+
return el.getSize();
|
|
122
|
+
},
|
|
108
123
|
|
|
109
|
-
|
|
110
|
-
}
|
|
124
|
+
/**
|
|
125
|
+
* @this {FakeDriver}
|
|
126
|
+
*/
|
|
127
|
+
equalsElement(el1Id, el2Id) {
|
|
128
|
+
let el1 = this.getElement(el1Id);
|
|
129
|
+
let el2 = this.getElement(el2Id);
|
|
130
|
+
return el1.equals(el2);
|
|
131
|
+
},
|
|
111
132
|
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @this {FakeDriver}
|
|
135
|
+
*/
|
|
136
|
+
async getCssProperty(prop, elementId) {
|
|
137
|
+
this.assertWebviewContext();
|
|
138
|
+
let el = this.getElement(elementId);
|
|
139
|
+
return el.getCss(prop);
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} elementId
|
|
144
|
+
* @this {FakeDriver}
|
|
145
|
+
*/
|
|
146
|
+
async getLocation(elementId) {
|
|
147
|
+
const el = this.getElement(elementId);
|
|
148
|
+
return el.getLocation();
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @this {FakeDriver}
|
|
153
|
+
*/
|
|
154
|
+
async getLocationInView(elementId) {
|
|
155
|
+
return this.getLocation(elementId);
|
|
156
|
+
},
|
|
157
|
+
};
|
|
116
158
|
|
|
117
159
|
/**
|
|
118
|
-
* @
|
|
119
|
-
* @typedef {import('@appium/types').Class<T,U,V>} Class
|
|
160
|
+
* @typedef {import('../driver').FakeDriver} FakeDriver
|
|
120
161
|
*/
|
package/lib/commands/find.js
CHANGED
|
@@ -2,121 +2,117 @@ import _ from 'lodash';
|
|
|
2
2
|
import {errors} from 'appium/driver';
|
|
3
3
|
import {FakeElement} from '../fake-element';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* @template {Class<import('../types').IElementCommands>} T
|
|
7
|
-
* @param {T} Base
|
|
8
|
-
*/
|
|
9
|
-
export function FindMixin(Base) {
|
|
5
|
+
export default {
|
|
10
6
|
/**
|
|
11
|
-
* @
|
|
7
|
+
* @this {FakeDriver}
|
|
12
8
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return id;
|
|
18
|
-
}
|
|
9
|
+
getExistingElementForNode(node) {
|
|
10
|
+
for (let [id, el] of _.toPairs(this.elMap)) {
|
|
11
|
+
if (el.node === node) {
|
|
12
|
+
return id;
|
|
19
13
|
}
|
|
20
|
-
return null;
|
|
21
14
|
}
|
|
15
|
+
return null;
|
|
16
|
+
},
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @this {FakeDriver}
|
|
20
|
+
*/
|
|
21
|
+
wrapNewEl(obj) {
|
|
22
|
+
// first check and see if we already have a ref to this element
|
|
23
|
+
let existingElId = this.getExistingElementForNode(obj);
|
|
24
|
+
if (existingElId) {
|
|
25
|
+
return {ELEMENT: existingElId};
|
|
26
|
+
}
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
// otherwise add the element to the map
|
|
29
|
+
this.maxElId++;
|
|
30
|
+
this.elMap[this.maxElId.toString()] = new FakeElement(obj, this.appModel);
|
|
31
|
+
return {ELEMENT: this.maxElId.toString()};
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @template {boolean} Mult
|
|
36
|
+
* @template [Ctx=any]
|
|
37
|
+
* @param {string} strategy
|
|
38
|
+
* @param {string} selector
|
|
39
|
+
* @param {Mult} mult
|
|
40
|
+
* @param {Ctx} [context]
|
|
41
|
+
* @returns {Promise<Mult extends true ? Element[] : Element>}
|
|
42
|
+
* @this {FakeDriver}
|
|
43
|
+
*/
|
|
44
|
+
async findElOrEls(strategy, selector, mult, context) {
|
|
45
|
+
let qMap = {
|
|
46
|
+
xpath: 'xpathQuery',
|
|
47
|
+
id: 'idQuery',
|
|
48
|
+
'accessibility id': 'idQuery',
|
|
49
|
+
'class name': 'classQuery',
|
|
50
|
+
'tag name': 'classQuery',
|
|
51
|
+
'css selector': 'cssQuery',
|
|
52
|
+
};
|
|
53
|
+
// TODO this error checking should probably be part of MJSONWP?
|
|
54
|
+
if (!_.includes(_.keys(qMap), strategy)) {
|
|
55
|
+
throw new errors.UnknownCommandError();
|
|
34
56
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* @param {string} selector
|
|
40
|
-
* @param {Mult} mult
|
|
41
|
-
* @param {Ctx} [context]
|
|
42
|
-
* @returns {Promise<Mult extends true ? Element[] : Element>}
|
|
43
|
-
*/
|
|
44
|
-
async findElOrEls(strategy, selector, mult, context) {
|
|
45
|
-
let qMap = {
|
|
46
|
-
xpath: 'xpathQuery',
|
|
47
|
-
id: 'idQuery',
|
|
48
|
-
'accessibility id': 'idQuery',
|
|
49
|
-
'class name': 'classQuery',
|
|
50
|
-
'tag name': 'classQuery',
|
|
51
|
-
'css selector': 'cssQuery',
|
|
52
|
-
};
|
|
53
|
-
// TODO this error checking should probably be part of MJSONWP?
|
|
54
|
-
if (!_.includes(_.keys(qMap), strategy)) {
|
|
55
|
-
throw new errors.UnknownCommandError();
|
|
56
|
-
}
|
|
57
|
-
if (selector === 'badsel') {
|
|
58
|
-
throw new errors.InvalidSelectorError();
|
|
59
|
-
}
|
|
60
|
-
let els = this.appModel[qMap[strategy]](selector, context);
|
|
57
|
+
if (selector === 'badsel') {
|
|
58
|
+
throw new errors.InvalidSelectorError();
|
|
59
|
+
}
|
|
60
|
+
let els = this.appModel[qMap[strategy]](selector, context);
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
retval = allEls;
|
|
70
|
-
} else {
|
|
71
|
-
retval = this.wrapNewEl(els[0]);
|
|
62
|
+
let retval;
|
|
63
|
+
if (els.length) {
|
|
64
|
+
if (mult) {
|
|
65
|
+
let allEls = [];
|
|
66
|
+
for (let el of els) {
|
|
67
|
+
allEls.push(this.wrapNewEl(el));
|
|
72
68
|
}
|
|
73
|
-
|
|
74
|
-
retval = [];
|
|
69
|
+
retval = allEls;
|
|
75
70
|
} else {
|
|
76
|
-
|
|
71
|
+
retval = this.wrapNewEl(els[0]);
|
|
77
72
|
}
|
|
78
|
-
|
|
73
|
+
} else if (mult) {
|
|
74
|
+
retval = [];
|
|
75
|
+
} else {
|
|
76
|
+
throw new errors.NoSuchElementError();
|
|
79
77
|
}
|
|
78
|
+
return /** @type {Mult extends true ? Element[] : Element} */ (retval);
|
|
79
|
+
},
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
async findElements(strategy, selector) {
|
|
91
|
-
return this.findElOrEls(strategy, selector, true);
|
|
92
|
-
}
|
|
81
|
+
/**
|
|
82
|
+
* This should override whatever's in ExternalDriver
|
|
83
|
+
* @param {string} strategy Strategy
|
|
84
|
+
* @param {string} selector Selector
|
|
85
|
+
* @this {FakeDriver}
|
|
86
|
+
*/
|
|
87
|
+
async findElement(strategy, selector) {
|
|
88
|
+
return this.findElOrEls(strategy, selector, false);
|
|
89
|
+
},
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
/**
|
|
92
|
+
* @this {FakeDriver}
|
|
93
|
+
*/
|
|
94
|
+
async findElements(strategy, selector) {
|
|
95
|
+
return this.findElOrEls(strategy, selector, true);
|
|
96
|
+
},
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
/**
|
|
99
|
+
* @this {FakeDriver}
|
|
100
|
+
*/
|
|
101
|
+
async findElementFromElement(strategy, selector, elementId) {
|
|
102
|
+
let el = this.getElement(elementId);
|
|
103
|
+
return this.findElOrEls(strategy, selector, false, el.xmlFragment);
|
|
104
|
+
},
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
}
|
|
106
|
+
/**
|
|
107
|
+
* @this {FakeDriver}
|
|
108
|
+
*/
|
|
109
|
+
async findElementsFromElement(strategy, selector, elementId) {
|
|
110
|
+
let el = this.getElement(elementId);
|
|
111
|
+
return this.findElOrEls(strategy, selector, true, el.xmlFragment);
|
|
112
|
+
},
|
|
113
|
+
};
|
|
107
114
|
|
|
108
115
|
/**
|
|
109
|
-
* @typedef {import('../driver').FakeDriverCore} FakeDriverCore
|
|
110
116
|
* @typedef {import('@appium/types').Element} Element
|
|
111
|
-
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @template T,[U={}],[V=Array<any>]
|
|
116
|
-
* @typedef {import('@appium/types').Class<T,U,V>} Class
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @template [Ctx=any]
|
|
121
|
-
* @typedef {import('@appium/types').IFindCommands<Ctx>} IFindCommands
|
|
117
|
+
* @typedef {import('../driver').FakeDriver} FakeDriver
|
|
122
118
|
*/
|