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