@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/general.js
CHANGED
|
@@ -2,118 +2,146 @@ import {errors} from 'appium/driver';
|
|
|
2
2
|
|
|
3
3
|
const ORIENTATIONS = new Set(['LANDSCAPE', 'PORTRAIT']);
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* @template {Class<import('../types').IContextsCommands & import('../types').IElementCommands>} T
|
|
7
|
-
* @param {T} Base
|
|
8
|
-
*/
|
|
9
|
-
export function GeneralMixin(Base) {
|
|
5
|
+
export default {
|
|
10
6
|
/**
|
|
11
|
-
* @
|
|
7
|
+
* @this {FakeDriver}
|
|
12
8
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async keys(value) {
|
|
20
|
-
if (!this.focusedElId) {
|
|
21
|
-
throw new errors.InvalidElementStateError();
|
|
22
|
-
}
|
|
23
|
-
await this.setValue(value, this.focusedElId);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async setGeoLocation(location) {
|
|
27
|
-
// TODO test this adequately once WD bug is fixed
|
|
28
|
-
this.appModel.lat = location.latitude;
|
|
29
|
-
this.appModel.long = location.longitude;
|
|
30
|
-
}
|
|
9
|
+
async title() {
|
|
10
|
+
this.assertWebviewContext();
|
|
11
|
+
return this.appModel.title;
|
|
12
|
+
},
|
|
31
13
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @this {FakeDriver}
|
|
16
|
+
*/
|
|
17
|
+
async keys(value) {
|
|
18
|
+
if (!this.focusedElId) {
|
|
19
|
+
throw new errors.InvalidElementStateError();
|
|
38
20
|
}
|
|
21
|
+
await this.setValue(value, this.focusedElId);
|
|
22
|
+
},
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @this {FakeDriver}
|
|
26
|
+
*/
|
|
27
|
+
async setGeoLocation(location) {
|
|
28
|
+
// TODO test this adequately once WD bug is fixed
|
|
29
|
+
this.appModel.lat = location.latitude;
|
|
30
|
+
this.appModel.long = location.longitude;
|
|
31
|
+
},
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
throw new errors.UnknownError('Orientation must be LANDSCAPE or PORTRAIT');
|
|
51
|
-
}
|
|
52
|
-
this.appModel.orientation = o;
|
|
53
|
-
}
|
|
33
|
+
/**
|
|
34
|
+
* @this {FakeDriver}
|
|
35
|
+
*/
|
|
36
|
+
async getGeoLocation() {
|
|
37
|
+
return this.appModel.currentGeoLocation;
|
|
38
|
+
},
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @this {FakeDriver}
|
|
42
|
+
*/
|
|
43
|
+
async getPageSource() {
|
|
44
|
+
return this.appModel.rawXml;
|
|
45
|
+
},
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @this {FakeDriver}
|
|
49
|
+
*/
|
|
50
|
+
async getOrientation() {
|
|
51
|
+
return this.appModel.orientation;
|
|
52
|
+
},
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param {import('../types').FakeDriverCaps['orientation']} o
|
|
57
|
+
* @this {FakeDriver}
|
|
58
|
+
*/
|
|
59
|
+
async setOrientation(o) {
|
|
60
|
+
if (!ORIENTATIONS.has(o)) {
|
|
61
|
+
throw new errors.UnknownError('Orientation must be LANDSCAPE or PORTRAIT');
|
|
65
62
|
}
|
|
63
|
+
this.appModel.orientation = o;
|
|
64
|
+
},
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @this {FakeDriver}
|
|
68
|
+
*/
|
|
69
|
+
async getScreenshot() {
|
|
70
|
+
return this.appModel.getScreenshot();
|
|
71
|
+
},
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @this {FakeDriver}
|
|
75
|
+
*/
|
|
76
|
+
async getWindowSize() {
|
|
77
|
+
return {width: this.appModel.width, height: this.appModel.height};
|
|
78
|
+
},
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
80
|
+
/**
|
|
81
|
+
* @this {FakeDriver}
|
|
82
|
+
*/
|
|
83
|
+
async getWindowRect() {
|
|
84
|
+
return {width: this.appModel.width, height: this.appModel.height, x: 0, y: 0};
|
|
85
|
+
},
|
|
81
86
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @this {FakeDriver}
|
|
90
|
+
*/
|
|
91
|
+
async performActions(actions) {
|
|
92
|
+
this.appModel.actionLog.push(actions);
|
|
93
|
+
},
|
|
85
94
|
|
|
86
|
-
|
|
95
|
+
/**
|
|
96
|
+
* @this {FakeDriver}
|
|
97
|
+
*/
|
|
98
|
+
async releaseActions() {},
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
/**
|
|
101
|
+
* @this {FakeDriver}
|
|
102
|
+
*/
|
|
103
|
+
async getLog(type) {
|
|
104
|
+
switch (type) {
|
|
105
|
+
case 'actions':
|
|
106
|
+
return this.appModel.actionLog;
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(`Don't understand log type '${type}'`);
|
|
90
109
|
}
|
|
110
|
+
},
|
|
91
111
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* @returns {Promise<number>}
|
|
99
|
-
*/
|
|
100
|
-
async fakeAddition(num1, num2, num3 = 0) {
|
|
101
|
-
return num1 + num2 + (num3 ?? 0);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
112
|
+
/**
|
|
113
|
+
* @this {FakeDriver}
|
|
114
|
+
*/
|
|
115
|
+
async mobileShake() {
|
|
116
|
+
this.shook = true;
|
|
117
|
+
},
|
|
104
118
|
|
|
105
|
-
|
|
106
|
-
}
|
|
119
|
+
/**
|
|
120
|
+
* @this {FakeDriver}
|
|
121
|
+
*/
|
|
122
|
+
async doubleClick() {},
|
|
107
123
|
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
124
|
+
/**
|
|
125
|
+
* @this {FakeDriver}
|
|
126
|
+
*/
|
|
127
|
+
async execute(script, args) {
|
|
128
|
+
return await this.executeMethod(script, args);
|
|
129
|
+
},
|
|
111
130
|
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Add two or maybe even three numbers
|
|
133
|
+
*
|
|
134
|
+
* @param {number} num1
|
|
135
|
+
* @param {number} num2
|
|
136
|
+
* @param {number} [num3]
|
|
137
|
+
* @returns {Promise<number>}
|
|
138
|
+
* @this {FakeDriver}
|
|
139
|
+
*/
|
|
140
|
+
async fakeAddition(num1, num2, num3 = 0) {
|
|
141
|
+
return num1 + num2 + (num3 ?? 0);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
116
144
|
|
|
117
145
|
/**
|
|
118
|
-
* @typedef {import('../
|
|
146
|
+
* @typedef {import('../driver').FakeDriver} FakeDriver
|
|
119
147
|
*/
|
package/lib/commands/index.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {import('@appium/types').Class<import('../driver').FakeDriverCore>} Base
|
|
10
|
-
*/
|
|
11
|
-
export function FakeDriverMixin(Base) {
|
|
12
|
-
return GeneralMixin(FindMixin(ElementMixin(AlertMixin(ContextsMixin(Base)))));
|
|
13
|
-
}
|
|
1
|
+
export {default as alert} from './alert';
|
|
2
|
+
export {default as contexts} from './contexts';
|
|
3
|
+
export {default as element} from './element';
|
|
4
|
+
export {default as find} from './find';
|
|
5
|
+
export {default as general} from './general';
|
|
14
6
|
|
|
15
7
|
/* // TODO:
|
|
16
8
|
//rest.post('/wd/hub/session/:sessionId?/touch/click', controller.doClick);
|
package/lib/driver.js
CHANGED
|
@@ -2,7 +2,7 @@ import B from 'bluebird';
|
|
|
2
2
|
import {BaseDriver, errors} from 'appium/driver';
|
|
3
3
|
import {deprecatedCommandsLogged} from '@appium/base-driver/build/lib/protocol/protocol';
|
|
4
4
|
import {FakeApp} from './fake-app';
|
|
5
|
-
import {
|
|
5
|
+
import {alert, contexts, element, find, general} from './commands';
|
|
6
6
|
|
|
7
7
|
const FAKE_DRIVER_CONSTRAINTS = /** @type {const} */ ({
|
|
8
8
|
app: {
|
|
@@ -22,7 +22,7 @@ const FAKE_DRIVER_CONSTRAINTS = /** @type {const} */ ({
|
|
|
22
22
|
* @extends {BaseDriver<FakeDriverConstraints>}
|
|
23
23
|
* @implements {ExternalDriver<FakeDriverConstraints>}
|
|
24
24
|
*/
|
|
25
|
-
export class
|
|
25
|
+
export class FakeDriver extends BaseDriver {
|
|
26
26
|
desiredCapConstraints = FAKE_DRIVER_CONSTRAINTS;
|
|
27
27
|
|
|
28
28
|
/** @type {string} */
|
|
@@ -190,36 +190,92 @@ export class FakeDriverCore extends BaseDriver {
|
|
|
190
190
|
},
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
/**
|
|
194
|
-
* Add two or maybe even three numbers
|
|
195
|
-
*
|
|
196
|
-
* @param {number} num1
|
|
197
|
-
* @param {number} num2
|
|
198
|
-
* @param {number} [num3]
|
|
199
|
-
* @returns {Promise<number>}
|
|
200
|
-
*/
|
|
201
|
-
// eslint-disable-next-line no-unused-vars
|
|
202
|
-
async fakeAddition(num1, num2, num3 = 0) {
|
|
203
|
-
throw new errors.NotImplementedError();
|
|
204
|
-
}
|
|
205
|
-
|
|
206
193
|
static fakeRoute(req, res) {
|
|
207
194
|
res.send(JSON.stringify({fakedriver: 'fakeResponse'}));
|
|
208
195
|
}
|
|
209
196
|
|
|
210
197
|
static async updateServer(expressApp, httpServer, cliArgs) {
|
|
211
198
|
// eslint-disable-line require-await
|
|
212
|
-
expressApp.all('/fakedriver',
|
|
199
|
+
expressApp.all('/fakedriver', FakeDriver.fakeRoute);
|
|
213
200
|
expressApp.all('/fakedriverCliArgs', (req, res) => {
|
|
214
201
|
res.send(JSON.stringify(cliArgs));
|
|
215
202
|
});
|
|
216
203
|
}
|
|
204
|
+
|
|
205
|
+
/*********
|
|
206
|
+
* ALERT *
|
|
207
|
+
*********/
|
|
208
|
+
assertNoAlert = alert.assertNoAlert;
|
|
209
|
+
assertAlert = alert.assertAlert;
|
|
210
|
+
getAlertText = alert.getAlertText;
|
|
211
|
+
setAlertText = alert.setAlertText;
|
|
212
|
+
postAcceptAlert = alert.postAcceptAlert;
|
|
213
|
+
postDismissAlert = alert.postDismissAlert;
|
|
214
|
+
|
|
215
|
+
/************
|
|
216
|
+
* CONTEXTS *
|
|
217
|
+
************/
|
|
218
|
+
getRawContexts = contexts.getRawContexts;
|
|
219
|
+
assertWebviewContext = contexts.assertWebviewContext;
|
|
220
|
+
getCurrentContext = contexts.getCurrentContext;
|
|
221
|
+
getContexts = contexts.getContexts;
|
|
222
|
+
setContext = contexts.setContext;
|
|
223
|
+
setFrame = contexts.setFrame;
|
|
224
|
+
|
|
225
|
+
/************
|
|
226
|
+
* ELEMENTS *
|
|
227
|
+
************/
|
|
228
|
+
getElements = element.getElements;
|
|
229
|
+
getElement = element.getElement;
|
|
230
|
+
getName = element.getName;
|
|
231
|
+
elementDisplayed = element.elementDisplayed;
|
|
232
|
+
elementEnabled = element.elementEnabled;
|
|
233
|
+
elementSelected = element.elementSelected;
|
|
234
|
+
setValue = element.setValue;
|
|
235
|
+
getText = element.getText;
|
|
236
|
+
clear = element.clear;
|
|
237
|
+
click = element.click;
|
|
238
|
+
getAttribute = element.getAttribute;
|
|
239
|
+
getElementRect = element.getElementRect;
|
|
240
|
+
getSize = element.getSize;
|
|
241
|
+
equalsElement = element.equalsElement;
|
|
242
|
+
getCssProperty = element.getCssProperty;
|
|
243
|
+
getLocation = element.getLocation;
|
|
244
|
+
getLocationInView = element.getLocationInView;
|
|
245
|
+
|
|
246
|
+
/********
|
|
247
|
+
* FIND *
|
|
248
|
+
********/
|
|
249
|
+
getExistingElementForNode = find.getExistingElementForNode;
|
|
250
|
+
wrapNewEl = find.wrapNewEl;
|
|
251
|
+
findElOrEls = find.findElOrEls;
|
|
252
|
+
findElement = find.findElement;
|
|
253
|
+
findElements = find.findElements;
|
|
254
|
+
findElementFromElement = find.findElementFromElement;
|
|
255
|
+
findElementsFromElement = find.findElementsFromElement;
|
|
256
|
+
|
|
257
|
+
/***********
|
|
258
|
+
* GENERAL *
|
|
259
|
+
***********/
|
|
260
|
+
title = general.title;
|
|
261
|
+
keys = general.keys;
|
|
262
|
+
setGeoLocation = general.setGeoLocation;
|
|
263
|
+
getGeoLocation = general.getGeoLocation;
|
|
264
|
+
getPageSource = general.getPageSource;
|
|
265
|
+
getOrientation = general.getOrientation;
|
|
266
|
+
setOrientation = general.setOrientation;
|
|
267
|
+
getScreenshot = general.getScreenshot;
|
|
268
|
+
getWindowSize = general.getWindowSize;
|
|
269
|
+
getWindowRect = general.getWindowRect;
|
|
270
|
+
performActions = general.performActions;
|
|
271
|
+
getLog = general.getLog;
|
|
272
|
+
mobileShake = general.mobileShake;
|
|
273
|
+
doubleClick = general.doubleClick;
|
|
274
|
+
execute = general.execute;
|
|
275
|
+
fakeAddition = general.fakeAddition;
|
|
276
|
+
releaseActions = general.releaseActions;
|
|
217
277
|
}
|
|
218
278
|
|
|
219
|
-
/**
|
|
220
|
-
* @extends FakeDriverCore
|
|
221
|
-
*/
|
|
222
|
-
export class FakeDriver extends FakeDriverMixin(FakeDriverCore) {}
|
|
223
279
|
export default FakeDriver;
|
|
224
280
|
|
|
225
281
|
/**
|
package/lib/types.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type {DriverCaps,
|
|
1
|
+
import type {DriverCaps, W3CDriverCaps} from '@appium/types';
|
|
2
2
|
import type {FakeDriverConstraints} from './driver';
|
|
3
|
-
import {FakeApp} from './fake-app';
|
|
4
|
-
import {FakeElement} from './fake-element';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* W3C-style caps for {@link FakeDriver}
|
|
@@ -14,29 +12,3 @@ export type W3CFakeDriverCaps = W3CDriverCaps<FakeDriverConstraints>;
|
|
|
14
12
|
* @public
|
|
15
13
|
*/
|
|
16
14
|
export type FakeDriverCaps = DriverCaps<FakeDriverConstraints>;
|
|
17
|
-
|
|
18
|
-
export interface IFakeDriver extends ExternalDriver<FakeDriverConstraints> {
|
|
19
|
-
elMap: Record<string, FakeElement>;
|
|
20
|
-
maxElId: number;
|
|
21
|
-
appModel: FakeApp;
|
|
22
|
-
focusedElId: string;
|
|
23
|
-
curContext: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IGeneralCommands extends IFakeDriver {
|
|
27
|
-
fakeAddition(num1: number, num2: number, num3?: number): Promise<number>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface IContextsCommands extends IFakeDriver {
|
|
31
|
-
assertWebviewContext(): void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface IElementCommands extends IFakeDriver {
|
|
35
|
-
getElement(id: string): FakeElement;
|
|
36
|
-
getElements(ids: string[]): FakeElement[];
|
|
37
|
-
setValue(text: string, id: string): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface IAlertCommands extends IFakeDriver {
|
|
41
|
-
assertNoAlert(): void;
|
|
42
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/fake-driver",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.4",
|
|
4
4
|
"description": "Mock driver used internally by Appium for testing. Ignore",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"entryPoint": "./lib/index.js"
|
|
82
82
|
},
|
|
83
83
|
"types": "./build/lib/index.d.ts",
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f1e0a46712b76564cd44c37657882308a7bac706"
|
|
85
85
|
}
|