@appium/images-plugin 4.0.4 → 4.1.1
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/compare.d.ts +8 -22
- package/build/lib/compare.d.ts.map +1 -1
- package/build/lib/compare.js +17 -23
- package/build/lib/compare.js.map +1 -1
- package/build/lib/constants.d.ts +13 -12
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +0 -31
- package/build/lib/constants.js.map +1 -1
- package/build/lib/finder.d.ts +22 -121
- package/build/lib/finder.d.ts.map +1 -1
- package/build/lib/finder.js +60 -100
- package/build/lib/finder.js.map +1 -1
- package/build/lib/image-element.d.ts +36 -108
- package/build/lib/image-element.d.ts.map +1 -1
- package/build/lib/image-element.js +45 -60
- package/build/lib/image-element.js.map +1 -1
- package/build/lib/index.d.ts +8 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +30 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/logger.d.ts +1 -2
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +2 -2
- package/build/lib/logger.js.map +1 -1
- package/build/lib/plugin.d.ts +15 -34
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/plugin.js +12 -25
- package/build/lib/plugin.js.map +1 -1
- package/build/lib/types.d.ts +127 -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/lib/compare.ts +100 -0
- package/lib/constants.ts +31 -0
- package/lib/{finder.js → finder.ts} +109 -136
- package/lib/{image-element.js → image-element.ts} +67 -85
- package/lib/index.ts +7 -0
- package/lib/logger.ts +3 -0
- package/lib/{plugin.js → plugin.ts} +42 -38
- package/lib/types.ts +187 -0
- package/package.json +14 -14
- package/tsconfig.json +3 -2
- package/index.js +0 -1
- package/lib/compare.js +0 -96
- package/lib/constants.js +0 -70
- package/lib/logger.js +0 -5
|
@@ -7,38 +7,21 @@ exports.ImageElement = void 0;
|
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const driver_1 = require("appium/driver");
|
|
9
9
|
const support_1 = require("@appium/support");
|
|
10
|
-
const logger_1 =
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
11
|
const constants_1 = require("./constants");
|
|
12
12
|
const TAP_DURATION_MS = 125;
|
|
13
|
-
/**
|
|
14
|
-
* @typedef Dimension
|
|
15
|
-
* @property {number} width - width of rect
|
|
16
|
-
* @property {number} height - height of rect
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* @typedef Position
|
|
20
|
-
* @property {number} x - x coordinate
|
|
21
|
-
* @property {number} y - y coordinate
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* @typedef ImageElementOpts
|
|
25
|
-
* @property {Buffer} template - the image which was used to find this ImageElement
|
|
26
|
-
* @property {Rect} rect - bounds of matched image element
|
|
27
|
-
* @property {number} score The similarity score as a float number in range [0.0, 1.0].
|
|
28
|
-
* 1.0 is the highest score (means both images are totally equal).
|
|
29
|
-
* @property {Buffer?} match - the image which has matched marks. Defaults to null.
|
|
30
|
-
* @property {import('./finder').default?} finder - the finder we can use to re-check stale elements
|
|
31
|
-
* @property {import('@appium/types').Rect?} containerRect - The bounding
|
|
32
|
-
* rectangle to limit the search in
|
|
33
|
-
*/
|
|
34
13
|
/**
|
|
35
14
|
* Representation of an "image element", which is simply a set of coordinates
|
|
36
15
|
* and methods that can be used on that set of coordinates via the driver
|
|
37
16
|
*/
|
|
38
17
|
class ImageElement {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
template;
|
|
19
|
+
rect;
|
|
20
|
+
id;
|
|
21
|
+
match;
|
|
22
|
+
score;
|
|
23
|
+
finder;
|
|
24
|
+
containerRect;
|
|
42
25
|
constructor({ template, rect, score, match = null, finder = null, containerRect = null, }) {
|
|
43
26
|
this.template = template;
|
|
44
27
|
this.rect = rect;
|
|
@@ -49,19 +32,19 @@ class ImageElement {
|
|
|
49
32
|
this.containerRect = containerRect;
|
|
50
33
|
}
|
|
51
34
|
/**
|
|
52
|
-
* @returns
|
|
35
|
+
* @returns dimension of element
|
|
53
36
|
*/
|
|
54
37
|
get size() {
|
|
55
38
|
return { width: this.rect.width, height: this.rect.height };
|
|
56
39
|
}
|
|
57
40
|
/**
|
|
58
|
-
* @returns
|
|
41
|
+
* @returns coordinates of top-left corner of element
|
|
59
42
|
*/
|
|
60
43
|
get location() {
|
|
61
44
|
return { x: this.rect.x, y: this.rect.y };
|
|
62
45
|
}
|
|
63
46
|
/**
|
|
64
|
-
* @returns
|
|
47
|
+
* @returns coordinates of center of element
|
|
65
48
|
*/
|
|
66
49
|
get center() {
|
|
67
50
|
return {
|
|
@@ -70,29 +53,28 @@ class ImageElement {
|
|
|
70
53
|
};
|
|
71
54
|
}
|
|
72
55
|
/**
|
|
73
|
-
* @returns
|
|
56
|
+
* @returns the base64-encoded original image used for matching
|
|
74
57
|
*/
|
|
75
58
|
get originalImage() {
|
|
76
59
|
return this.template.toString('base64');
|
|
77
60
|
}
|
|
78
61
|
/**
|
|
79
|
-
* @returns
|
|
62
|
+
* @returns the base64-encoded image which has matched marks
|
|
80
63
|
*/
|
|
81
64
|
get matchedImage() {
|
|
82
65
|
return this.match?.toString('base64') ?? null;
|
|
83
66
|
}
|
|
84
67
|
/**
|
|
85
68
|
*
|
|
86
|
-
* @returns
|
|
69
|
+
* @returns this image element as a WebElement
|
|
87
70
|
*/
|
|
88
71
|
asElement() {
|
|
89
72
|
return support_1.util.wrapElement(this.id);
|
|
90
73
|
}
|
|
91
74
|
/**
|
|
92
|
-
* @param
|
|
75
|
+
* @param other - an ImageElement to compare with this one
|
|
93
76
|
*
|
|
94
|
-
* @returns
|
|
95
|
-
* properties
|
|
77
|
+
* @returns whether the other element and this one have the same properties
|
|
96
78
|
*/
|
|
97
79
|
equals(other) {
|
|
98
80
|
return (this.rect.x === other.rect.x &&
|
|
@@ -104,7 +86,7 @@ class ImageElement {
|
|
|
104
86
|
* Use a driver to tap the screen at the center of this ImageElement's
|
|
105
87
|
* position
|
|
106
88
|
*
|
|
107
|
-
* @param
|
|
89
|
+
* @param driver - driver for calling actions with
|
|
108
90
|
*/
|
|
109
91
|
async click(driver) {
|
|
110
92
|
// before we click we need to make sure the element is actually still there
|
|
@@ -119,10 +101,12 @@ class ImageElement {
|
|
|
119
101
|
}
|
|
120
102
|
let newImgEl;
|
|
121
103
|
if (checkForImageElementStaleness || updatePos) {
|
|
122
|
-
logger_1.
|
|
104
|
+
logger_1.log.info('Checking image element for staleness before clicking');
|
|
123
105
|
try {
|
|
124
|
-
|
|
125
|
-
.
|
|
106
|
+
if (!this.finder) {
|
|
107
|
+
throw new driver_1.errors.StaleElementReferenceError();
|
|
108
|
+
}
|
|
109
|
+
newImgEl = (await this.finder.findByImage(this.template, driver, {
|
|
126
110
|
shouldCheckStaleness: true,
|
|
127
111
|
// Set ignoreDefaultImageTemplateScale because this.template is device screenshot based image
|
|
128
112
|
// managed inside Appium after finidng image by template which managed by a user
|
|
@@ -134,16 +118,16 @@ class ImageElement {
|
|
|
134
118
|
throw new driver_1.errors.StaleElementReferenceError();
|
|
135
119
|
}
|
|
136
120
|
if (!this.equals(newImgEl)) {
|
|
137
|
-
logger_1.
|
|
121
|
+
logger_1.log.warn(`When trying to click on an image element, the image changed ` +
|
|
138
122
|
`position from where it was originally found. It is now at ` +
|
|
139
123
|
`${JSON.stringify(newImgEl.rect)} and was originally at ` +
|
|
140
124
|
`${JSON.stringify(this.rect)}.`);
|
|
141
125
|
if (updatePos) {
|
|
142
|
-
logger_1.
|
|
126
|
+
logger_1.log.warn('Click will proceed at new coordinates');
|
|
143
127
|
this.rect = lodash_1.default.clone(newImgEl.rect);
|
|
144
128
|
}
|
|
145
129
|
else {
|
|
146
|
-
logger_1.
|
|
130
|
+
logger_1.log.warn('Click will take place at original coordinates. If you ' +
|
|
147
131
|
'would like Appium to automatically click the new ' +
|
|
148
132
|
"coordinates, set the 'autoUpdateImageElementPosition' " +
|
|
149
133
|
'setting to true');
|
|
@@ -151,10 +135,10 @@ class ImageElement {
|
|
|
151
135
|
}
|
|
152
136
|
}
|
|
153
137
|
const { x, y } = this.center;
|
|
154
|
-
logger_1.
|
|
138
|
+
logger_1.log.info(`Will tap on image element at coordinate [${x}, ${y}]`);
|
|
155
139
|
if (imageElementTapStrategy === constants_1.IMAGE_EL_TAP_STRATEGY_W3C) {
|
|
156
140
|
// set up a W3C action to click on the image by position
|
|
157
|
-
logger_1.
|
|
141
|
+
logger_1.log.info('Will tap using W3C actions');
|
|
158
142
|
const action = {
|
|
159
143
|
type: 'pointer',
|
|
160
144
|
id: 'mouse',
|
|
@@ -171,11 +155,11 @@ class ImageElement {
|
|
|
171
155
|
return await driver.performActions([action]);
|
|
172
156
|
}
|
|
173
157
|
// if not, warn and fall back to the other method
|
|
174
|
-
logger_1.
|
|
158
|
+
logger_1.log.warn('Driver does not seem to implement W3C actions, falling back ' + 'to TouchActions');
|
|
175
159
|
}
|
|
176
160
|
// if the w3c strategy was not requested, do the only other option (mjsonwp
|
|
177
161
|
// touch actions)
|
|
178
|
-
logger_1.
|
|
162
|
+
logger_1.log.info('Will tap using MJSONWP TouchActions');
|
|
179
163
|
const action = {
|
|
180
164
|
action: 'tap',
|
|
181
165
|
options: { x, y },
|
|
@@ -190,27 +174,33 @@ class ImageElement {
|
|
|
190
174
|
/**
|
|
191
175
|
* Perform lookup of image element(s) inside of the current element
|
|
192
176
|
*
|
|
193
|
-
* @param
|
|
194
|
-
* @param
|
|
195
|
-
* @param
|
|
196
|
-
* @returns
|
|
177
|
+
* @param multiple - Whether to lookup multiple elements
|
|
178
|
+
* @param driver - The driver to use for commands
|
|
179
|
+
* @param args - Rest of arguments for executeScripts
|
|
180
|
+
* @returns WebDriver element with a special id prefix
|
|
197
181
|
*/
|
|
198
182
|
async find(multiple, driver, ...args) {
|
|
199
183
|
const [strategy, selector] = args;
|
|
200
184
|
if (strategy !== constants_1.IMAGE_STRATEGY) {
|
|
201
185
|
throw new driver_1.errors.InvalidSelectorError(`Lookup strategies other than '${constants_1.IMAGE_STRATEGY}' are not supported`);
|
|
202
186
|
}
|
|
203
|
-
|
|
187
|
+
if (!this.finder) {
|
|
188
|
+
throw new Error('Finder is not available');
|
|
189
|
+
}
|
|
190
|
+
return await this.finder.findByImage(Buffer.from(selector, 'base64'), driver, {
|
|
191
|
+
multiple,
|
|
192
|
+
containerRect: this.rect,
|
|
193
|
+
});
|
|
204
194
|
}
|
|
205
195
|
/**
|
|
206
196
|
* Handle various Appium commands that involve an image element
|
|
207
197
|
*
|
|
208
|
-
* @param
|
|
209
|
-
* @param
|
|
210
|
-
* @param
|
|
211
|
-
* @param
|
|
198
|
+
* @param driver - the driver to use for commands
|
|
199
|
+
* @param cmd - the name of the driver command
|
|
200
|
+
* @param imgEl - image element object
|
|
201
|
+
* @param args - Rest of arguments for executeScripts
|
|
212
202
|
*
|
|
213
|
-
* @returns
|
|
203
|
+
* @returns the result of running a command
|
|
214
204
|
*/
|
|
215
205
|
static async execute(driver, imgEl, cmd, ...args) {
|
|
216
206
|
switch (cmd) {
|
|
@@ -248,10 +238,5 @@ class ImageElement {
|
|
|
248
238
|
}
|
|
249
239
|
}
|
|
250
240
|
}
|
|
251
|
-
exports.default = ImageElement;
|
|
252
241
|
exports.ImageElement = ImageElement;
|
|
253
|
-
/**
|
|
254
|
-
* @typedef {import('@appium/types').Rect} Rect
|
|
255
|
-
* @typedef {import('@appium/types').Element} Element
|
|
256
|
-
*/
|
|
257
242
|
//# sourceMappingURL=image-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-element.js","sourceRoot":"","sources":["../../lib/image-element.
|
|
1
|
+
{"version":3,"file":"image-element.js","sourceRoot":"","sources":["../../lib/image-element.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,0CAAqC;AACrC,6CAAqC;AACrC,qCAA6B;AAC7B,2CAMqB;AAKrB,MAAM,eAAe,GA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AAO,IAAI,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC,IAAI,CAAC;YACpB,KAAK,aAAa,CAAC;YACnB,KAAK,mBAAmB;gBACtB,OAAO,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,gBAAgB;gBACnB,OAAO,KAAK,CAAC,IAAI,CAAC;YACpB,KAAK,sBAAsB;gBACzB,OAAO,KAAK,CAAC,aAAa,CAAC;YAC7B,KAAK,cAAc;gBACjB,yDAAyD;gBACzD,wFAAwF;gBACxF,8GAA8G;gBAC9G,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChB,KAAK,QAAQ;wBACX,OAAO,KAAK,CAAC,YAAY,CAAC;oBAC5B,KAAK,OAAO;wBACV,OAAO,KAAK,CAAC,KAAK,CAAC;oBACrB;wBACE,MAAM,IAAI,eAAM,CAAC,sBAAsB,EAAE,CAAC;gBAC9C,CAAC;YACH;gBACE,MAAM,IAAI,eAAM,CAAC,sBAAsB,EAAE,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AAvQD,oCAuQC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ImageElementPlugin, getImgElFromArgs } from './plugin';
|
|
2
|
+
export { IMAGE_STRATEGY } from './constants';
|
|
3
|
+
export { ImageElementFinder } from './finder';
|
|
4
|
+
export { ImageElement } from './image-element';
|
|
5
|
+
export * from './constants';
|
|
6
|
+
export { compareImages } from './compare';
|
|
7
|
+
export type * from './types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAC,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AACxC,mBAAmB,SAAS,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.compareImages = exports.ImageElement = exports.ImageElementFinder = exports.IMAGE_STRATEGY = exports.getImgElFromArgs = exports.ImageElementPlugin = void 0;
|
|
18
|
+
var plugin_1 = require("./plugin");
|
|
19
|
+
Object.defineProperty(exports, "ImageElementPlugin", { enumerable: true, get: function () { return plugin_1.ImageElementPlugin; } });
|
|
20
|
+
Object.defineProperty(exports, "getImgElFromArgs", { enumerable: true, get: function () { return plugin_1.getImgElFromArgs; } });
|
|
21
|
+
var constants_1 = require("./constants");
|
|
22
|
+
Object.defineProperty(exports, "IMAGE_STRATEGY", { enumerable: true, get: function () { return constants_1.IMAGE_STRATEGY; } });
|
|
23
|
+
var finder_1 = require("./finder");
|
|
24
|
+
Object.defineProperty(exports, "ImageElementFinder", { enumerable: true, get: function () { return finder_1.ImageElementFinder; } });
|
|
25
|
+
var image_element_1 = require("./image-element");
|
|
26
|
+
Object.defineProperty(exports, "ImageElement", { enumerable: true, get: function () { return image_element_1.ImageElement; } });
|
|
27
|
+
__exportStar(require("./constants"), exports);
|
|
28
|
+
var compare_1 = require("./compare");
|
|
29
|
+
Object.defineProperty(exports, "compareImages", { enumerable: true, get: function () { return compare_1.compareImages; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA8D;AAAtD,4GAAA,kBAAkB,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAC5C,yCAA2C;AAAnC,2GAAA,cAAc,OAAA;AACtB,mCAA4C;AAApC,4GAAA,kBAAkB,OAAA;AAC1B,iDAA6C;AAArC,6GAAA,YAAY,OAAA;AACpB,8CAA4B;AAC5B,qCAAwC;AAAhC,wGAAA,aAAa,OAAA"}
|
package/build/lib/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,sCAAyC,CAAC"}
|
package/build/lib/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.log = void 0;
|
|
3
4
|
const support_1 = require("appium/support");
|
|
4
|
-
|
|
5
|
-
exports.default = log;
|
|
5
|
+
exports.log = support_1.logger.getLogger('ImageElementPlugin');
|
|
6
6
|
//# sourceMappingURL=logger.js.map
|
package/build/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":";;;AAAA,4CAAsC;AAEzB,QAAA,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC"}
|
package/build/lib/plugin.d.ts
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
export default class ImageElementPlugin extends BasePlugin {
|
|
2
|
-
static newMethodMap: {
|
|
3
|
-
readonly '/session/:sessionId/appium/compare_images': {
|
|
4
|
-
readonly POST: {
|
|
5
|
-
readonly command: "compareImages";
|
|
6
|
-
readonly payloadParams: {
|
|
7
|
-
readonly required: readonly ["mode", "firstImage", "secondImage"];
|
|
8
|
-
readonly optional: readonly ["options"];
|
|
9
|
-
};
|
|
10
|
-
readonly neverProxy: true;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
constructor(pluginName: any);
|
|
15
|
-
finder: ImageElementFinder;
|
|
16
|
-
compareImages(next: any, driver: any, ...args: any[]): Promise<import("./compare").ComparisonResult>;
|
|
17
|
-
findElement(next: any, driver: any, ...args: any[]): Promise<any>;
|
|
18
|
-
findElements(next: any, driver: any, ...args: any[]): Promise<any>;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {boolean} multiple
|
|
22
|
-
* @param {*} next
|
|
23
|
-
* @param {*} driver
|
|
24
|
-
* @param {...any} args
|
|
25
|
-
* @returns {Promise<any>}
|
|
26
|
-
*/
|
|
27
|
-
_find(multiple: boolean, next: any, driver: any, ...args: any[]): Promise<any>;
|
|
28
|
-
handle(next: any, driver: any, cmdName: any, ...args: any[]): Promise<any>;
|
|
29
|
-
performActions(next: any, driver: any, ...args: any[]): Promise<any>;
|
|
30
|
-
}
|
|
31
1
|
import { BasePlugin } from 'appium/plugin';
|
|
32
|
-
import ImageElementFinder from './finder';
|
|
33
|
-
|
|
34
|
-
import {
|
|
35
|
-
export
|
|
2
|
+
import { ImageElementFinder } from './finder';
|
|
3
|
+
import type { ExternalDriver, ActionSequence, MethodMap } from '@appium/types';
|
|
4
|
+
import type { MatchingOptions, SimilarityOptions, OccurrenceOptions } from '@appium/opencv';
|
|
5
|
+
export declare function getImgElFromArgs(args: any[]): string | undefined;
|
|
6
|
+
export declare class ImageElementPlugin extends BasePlugin {
|
|
7
|
+
readonly finder: ImageElementFinder;
|
|
8
|
+
constructor(pluginName: string);
|
|
9
|
+
static newMethodMap: MethodMap<ImageElementPlugin>;
|
|
10
|
+
compareImages(next: () => Promise<any>, driver: ExternalDriver, mode: string, firstImage: string | Buffer, secondImage: string | Buffer, options?: MatchingOptions | SimilarityOptions | OccurrenceOptions): Promise<any>;
|
|
11
|
+
findElement(next: () => Promise<any>, driver: ExternalDriver, ...args: any[]): Promise<any>;
|
|
12
|
+
findElements(next: () => Promise<any>, driver: ExternalDriver, ...args: any[]): Promise<any>;
|
|
13
|
+
private _find;
|
|
14
|
+
handle(next: () => Promise<any>, driver: ExternalDriver, cmdName: string, ...args: any[]): Promise<any>;
|
|
15
|
+
performActions(next: () => Promise<any>, driver: ExternalDriver, actionSequences: ActionSequence[]): Promise<any>;
|
|
16
|
+
}
|
|
36
17
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAC,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAG5C,OAAO,KAAK,EAAC,cAAc,EAAW,cAAc,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,EAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,C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this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ImageElementPlugin = void 0;
|
|
7
7
|
exports.getImgElFromArgs = getImgElFromArgs;
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const driver_1 = require("appium/driver");
|
|
10
10
|
const support_1 = require("@appium/support");
|
|
11
11
|
const plugin_1 = require("appium/plugin");
|
|
12
12
|
const compare_1 = require("./compare");
|
|
13
|
-
const finder_1 =
|
|
13
|
+
const finder_1 = require("./finder");
|
|
14
14
|
const image_element_1 = require("./image-element");
|
|
15
15
|
const constants_1 = require("./constants");
|
|
16
|
-
Object.defineProperty(exports, "IMAGE_STRATEGY", { enumerable: true, get: function () { return constants_1.IMAGE_STRATEGY; } });
|
|
17
16
|
function getImgElFromArgs(args) {
|
|
18
17
|
return args.find((arg) => lodash_1.default.isString(arg) && arg.startsWith(constants_1.IMAGE_ELEMENT_PREFIX));
|
|
19
18
|
}
|
|
20
19
|
class ImageElementPlugin extends plugin_1.BasePlugin {
|
|
20
|
+
finder;
|
|
21
21
|
constructor(pluginName) {
|
|
22
22
|
super(pluginName);
|
|
23
|
-
this.finder = new finder_1.
|
|
23
|
+
this.finder = new finder_1.ImageElementFinder();
|
|
24
24
|
}
|
|
25
25
|
// this plugin supports a non-standard 'compare images' command
|
|
26
|
-
static newMethodMap =
|
|
26
|
+
static newMethodMap = {
|
|
27
27
|
'/session/:sessionId/appium/compare_images': {
|
|
28
28
|
POST: {
|
|
29
29
|
command: 'compareImages',
|
|
@@ -34,10 +34,9 @@ class ImageElementPlugin extends plugin_1.BasePlugin {
|
|
|
34
34
|
neverProxy: true,
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
}
|
|
38
|
-
async compareImages(next, driver,
|
|
39
|
-
|
|
40
|
-
return await (0, compare_1.compareImages)(...args);
|
|
37
|
+
};
|
|
38
|
+
async compareImages(next, driver, mode, firstImage, secondImage, options) {
|
|
39
|
+
return await (0, compare_1.compareImages)(mode, firstImage, secondImage, options);
|
|
41
40
|
}
|
|
42
41
|
async findElement(next, driver, ...args) {
|
|
43
42
|
return await this._find(false, next, driver, ...args);
|
|
@@ -45,14 +44,6 @@ class ImageElementPlugin extends plugin_1.BasePlugin {
|
|
|
45
44
|
async findElements(next, driver, ...args) {
|
|
46
45
|
return await this._find(true, next, driver, ...args);
|
|
47
46
|
}
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {boolean} multiple
|
|
51
|
-
* @param {*} next
|
|
52
|
-
* @param {*} driver
|
|
53
|
-
* @param {...any} args
|
|
54
|
-
* @returns {Promise<any>}
|
|
55
|
-
*/
|
|
56
47
|
async _find(multiple, next, driver, ...args) {
|
|
57
48
|
const [strategy, selector] = args;
|
|
58
49
|
// if we're not actually finding by image, just do the normal thing
|
|
@@ -78,19 +69,16 @@ class ImageElementPlugin extends plugin_1.BasePlugin {
|
|
|
78
69
|
// otherwise just do the normal thing
|
|
79
70
|
return await next();
|
|
80
71
|
}
|
|
81
|
-
async performActions(next, driver,
|
|
72
|
+
async performActions(next, driver, actionSequences) {
|
|
82
73
|
// Replace with coordinates when ActionSequence includes image elements.
|
|
83
|
-
const [actionSequences] = /** @type {[import('@appium/types').ActionSequence[]]} */ (args);
|
|
84
74
|
for (const actionSequence of actionSequences) {
|
|
85
75
|
for (const action of actionSequence.actions) {
|
|
86
76
|
// The actions that can have an Element as the origin are "pointerMove" and "scroll".
|
|
87
|
-
if (!lodash_1.default.isPlainObject(
|
|
88
|
-
/** @type {{origin?: "viewport" | "pointer" | import('@appium/types').Element}} */ (action).origin)) {
|
|
77
|
+
if (!lodash_1.default.isPlainObject(action.origin)) {
|
|
89
78
|
continue;
|
|
90
79
|
}
|
|
91
|
-
const actionWithEl =
|
|
92
|
-
|
|
93
|
-
const elId = support_1.util.unwrapElement(/** @type {import('@appium/types').Element} */ (actionWithEl.origin));
|
|
80
|
+
const actionWithEl = action;
|
|
81
|
+
const elId = support_1.util.unwrapElement(actionWithEl.origin);
|
|
94
82
|
if (!lodash_1.default.startsWith(elId, constants_1.IMAGE_ELEMENT_PREFIX)) {
|
|
95
83
|
continue;
|
|
96
84
|
}
|
|
@@ -108,6 +96,5 @@ class ImageElementPlugin extends plugin_1.BasePlugin {
|
|
|
108
96
|
return await next();
|
|
109
97
|
}
|
|
110
98
|
}
|
|
111
|
-
exports.default = ImageElementPlugin;
|
|
112
99
|
exports.ImageElementPlugin = ImageElementPlugin;
|
|
113
100
|
//# sourceMappingURL=plugin.js.map
|
package/build/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.ts"],"names":[],"mappings":";;;;;;AAWA,4CAEC;AAbD,oDAAuB;AACvB,0CAAqC;AACrC,6CAAqC;AACrC,0CAAyC;AACzC,uCAAwC;AACxC,qCAA4C;AAC5C,mDAA6C;AAC7C,2CAAiE;AAIjE,SAAgB,gBAAgB,CAAC,IAAW;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,gCAAoB,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,MAAa,kBAAmB,SAAQ,mBAAU;IACvC,MAAM,CAAqB;IAEpC,YAAY,UAAkB;QAC5B,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,2BAAkB,EAAE,CAAC;IACzC,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAC,YAAY,GAAkC;QACnD,2CAA2C,EAAE;YAC3C,IAAI,EAAE;gBACJ,OAAO,EAAE,e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E,CAAC;oBACX,MAAM,IAAI,eAAM,CAAC,kBAAkB,EAAE,CAAC;gBACxC,CAAC;gBAED,4DAA4D;gBAC5D,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBACjC,YAAY,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBACjC,+FAA+F;gBAC/F,OAAO,YAAY,CAAC,MAAM,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;;AApHH,gDAqHC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Rect } from '@appium/types';
|
|
2
|
+
import type { ImageElementFinder } from './finder';
|
|
3
|
+
import type { MatchingResult, OccurrenceResult, SimilarityResult } from '@appium/opencv';
|
|
4
|
+
import type { IMAGE_EL_TAP_STRATEGY_W3C, IMAGE_EL_TAP_STRATEGY_MJSONWP } from './constants';
|
|
5
|
+
/**
|
|
6
|
+
* Image settings interface for device settings
|
|
7
|
+
*/
|
|
8
|
+
export interface ImageSettings {
|
|
9
|
+
imageMatchThreshold: number;
|
|
10
|
+
imageMatchMethod: string;
|
|
11
|
+
fixImageFindScreenshotDims: boolean;
|
|
12
|
+
fixImageTemplateSize: boolean;
|
|
13
|
+
fixImageTemplateScale: boolean;
|
|
14
|
+
defaultImageTemplateScale: number;
|
|
15
|
+
checkForImageElementStaleness: boolean;
|
|
16
|
+
autoUpdateImageElementPosition: boolean;
|
|
17
|
+
imageElementTapStrategy: typeof IMAGE_EL_TAP_STRATEGY_W3C | typeof IMAGE_EL_TAP_STRATEGY_MJSONWP;
|
|
18
|
+
getMatchedImageResult: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for finding elements by image
|
|
22
|
+
*/
|
|
23
|
+
export interface FindByImageOptions {
|
|
24
|
+
/** whether this call to find an image is merely to check staleness.
|
|
25
|
+
* If so we can bypass a lot of logic */
|
|
26
|
+
shouldCheckStaleness?: boolean;
|
|
27
|
+
/** Whether we are finding one element or multiple */
|
|
28
|
+
multiple?: boolean;
|
|
29
|
+
/** Whether we ignore defaultImageTemplateScale. It can be used when you would like to
|
|
30
|
+
* scale template with defaultImageTemplateScale setting. */
|
|
31
|
+
ignoreDefaultImageTemplateScale?: boolean;
|
|
32
|
+
/** The bounding rectangle to limit the search in */
|
|
33
|
+
containerRect?: Rect | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Options for creating an ImageElement
|
|
37
|
+
*/
|
|
38
|
+
export interface ImageElementOpts {
|
|
39
|
+
/** the image which was used to find this ImageElement */
|
|
40
|
+
template: Buffer;
|
|
41
|
+
/** bounds of matched image element */
|
|
42
|
+
rect: Rect;
|
|
43
|
+
/** The similarity score as a float number in range [0.0, 1.0]. 1.0 is the highest
|
|
44
|
+
* score (means both images are totally equal). */
|
|
45
|
+
score: number;
|
|
46
|
+
/** the image which has matched marks. Defaults to null. */
|
|
47
|
+
match?: Buffer | null;
|
|
48
|
+
/** the finder we can use to re-check stale elements */
|
|
49
|
+
finder?: ImageElementFinder | null;
|
|
50
|
+
/** The bounding rectangle to limit the search in */
|
|
51
|
+
containerRect?: Rect | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Dimension interface for width and height
|
|
55
|
+
*/
|
|
56
|
+
export interface Dimension {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Position interface for x and y coordinates
|
|
62
|
+
*/
|
|
63
|
+
export interface Position {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Screenshot interface
|
|
69
|
+
*/
|
|
70
|
+
export interface Screenshot {
|
|
71
|
+
screenshot: Buffer;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Screenshot scale interface
|
|
75
|
+
*/
|
|
76
|
+
export interface ScreenshotScale {
|
|
77
|
+
xScale: number;
|
|
78
|
+
yScale: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Image template settings for scaling
|
|
82
|
+
*/
|
|
83
|
+
export interface ImageTemplateSettings {
|
|
84
|
+
/** fixImageTemplateScale in device-settings */
|
|
85
|
+
fixImageTemplateScale?: boolean;
|
|
86
|
+
/** defaultImageTemplateScale in device-settings */
|
|
87
|
+
defaultImageTemplateScale?: number;
|
|
88
|
+
/** Ignore defaultImageTemplateScale if it has true. If the template
|
|
89
|
+
* has been scaled to defaultImageTemplateScale or should ignore the scale,
|
|
90
|
+
* this parameter should be true. e.g. click in image-element module */
|
|
91
|
+
ignoreDefaultImageTemplateScale?: boolean;
|
|
92
|
+
/** Scale ratio for width */
|
|
93
|
+
xScale?: number;
|
|
94
|
+
/** Scale ratio for height */
|
|
95
|
+
yScale?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Occurrence result with visualization (string instead of Buffer)
|
|
99
|
+
*/
|
|
100
|
+
export interface OccurrenceResultWithVisualization {
|
|
101
|
+
rect: Rect;
|
|
102
|
+
score: number;
|
|
103
|
+
visualization?: string | null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Interface for results with string visualization instead of Buffer
|
|
107
|
+
*/
|
|
108
|
+
export interface Visualized {
|
|
109
|
+
visualization?: string | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Matching result with string visualization
|
|
113
|
+
*/
|
|
114
|
+
export type VisualizedMatchingResult = MatchingResult & Visualized;
|
|
115
|
+
/**
|
|
116
|
+
* Occurrence result with string visualization
|
|
117
|
+
*/
|
|
118
|
+
export type VisualizedOccurrenceResult = OccurrenceResult & Visualized;
|
|
119
|
+
/**
|
|
120
|
+
* Similarity result with string visualization
|
|
121
|
+
*/
|
|
122
|
+
export type VisualizedSimilarityResult = SimilarityResult & Visualized;
|
|
123
|
+
/**
|
|
124
|
+
* Result type for image comparison operations
|
|
125
|
+
*/
|
|
126
|
+
export type ComparisonResult = VisualizedMatchingResult | VisualizedOccurrenceResult | VisualizedSimilarityResult | VisualizedSimilarityResult[];
|
|
127
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,aAAa;IAG5B,mBAAmB,EAAE,MAAM,CAAC;IAM5B,gBAAgB,EAAE,MAAM,CAAC;IAIzB,0BAA0B,EAAE,OAAO,CAAC;IAKpC,oBAAoB,EAAE,OAAO,CAAC;IAQ9B,qBAAqB,EAAE,OAAO,CAAC;IAQ/B,yBAAyB,EAAE,MAAM,CAAC;IAIlC,6BAA6B,EAAE,OAAO,CAAC;IAIvC,8BAA8B,EAAE,OAAO,CAAC;IAIxC,uBAAuB,EAAE,OAAO,yBAAyB,GAAG,OAAO,6BAA6B,CAAC;IAIjG,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;4CACwC;IACxC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;gEAC4D;IAC5D,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C,oDAAoD;IACpD,aAAa,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yDAAyD;IAC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