@appium/images-plugin 2.0.10 → 2.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/compare.d.ts +0 -4
- package/build/lib/compare.d.ts.map +1 -1
- package/build/lib/compare.js +12 -19
- package/build/lib/compare.js.map +1 -1
- package/build/lib/constants.d.ts +13 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +59 -0
- package/build/lib/constants.js.map +1 -0
- package/build/lib/finder.d.ts +37 -48
- package/build/lib/finder.d.ts.map +1 -1
- package/build/lib/finder.js +167 -160
- package/build/lib/finder.js.map +1 -1
- package/build/lib/image-element.d.ts +60 -20
- package/build/lib/image-element.d.ts.map +1 -1
- package/build/lib/image-element.js +56 -34
- package/build/lib/image-element.js.map +1 -1
- package/build/lib/plugin.d.ts +3 -2
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/plugin.js +10 -12
- package/build/lib/plugin.js.map +1 -1
- package/lib/compare.js +6 -17
- package/lib/constants.js +70 -0
- package/lib/finder.js +186 -195
- package/lib/image-element.js +64 -31
- package/lib/plugin.js +10 -12
- package/package.json +4 -3
package/build/lib/compare.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export type OccurrenceResult = import('@appium/opencv').OccurrenceResult;
|
|
2
2
|
export function compareImages(next: import("@appium/types").NextPluginCallback<unknown>, driver: [string, string, string, any], ...args: Promise<import("@appium/opencv").OccurrenceResult>): Promise<unknown>;
|
|
3
|
-
export const DEFAULT_MATCH_THRESHOLD: 0.4;
|
|
4
|
-
export const MATCH_TEMPLATE_MODE: "matchTemplate";
|
|
5
|
-
export const MATCH_FEATURES_MODE: "matchFeatures";
|
|
6
|
-
export const GET_SIMILARITY_MODE: "getSimilarity";
|
|
7
3
|
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../lib/compare.js"],"names":[],"mappings":"+
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../lib/compare.js"],"names":[],"mappings":"+BAoFa,OAAO,gBAAgB,EAAE,gBAAgB;AAEkmC,+MAAsF"}
|
package/build/lib/compare.js
CHANGED
|
@@ -3,18 +3,11 @@ var __importDefault = (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.compareImages = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const driver_1 = require("appium/driver");
|
|
9
9
|
const opencv_1 = require("@appium/opencv");
|
|
10
|
-
const
|
|
11
|
-
exports.MATCH_FEATURES_MODE = MATCH_FEATURES_MODE;
|
|
12
|
-
const GET_SIMILARITY_MODE = 'getSimilarity';
|
|
13
|
-
exports.GET_SIMILARITY_MODE = GET_SIMILARITY_MODE;
|
|
14
|
-
const MATCH_TEMPLATE_MODE = 'matchTemplate';
|
|
15
|
-
exports.MATCH_TEMPLATE_MODE = MATCH_TEMPLATE_MODE;
|
|
16
|
-
const DEFAULT_MATCH_THRESHOLD = 0.4;
|
|
17
|
-
exports.DEFAULT_MATCH_THRESHOLD = DEFAULT_MATCH_THRESHOLD;
|
|
10
|
+
const constants_1 = require("./constants");
|
|
18
11
|
/**
|
|
19
12
|
* Performs images comparison using OpenCV framework features.
|
|
20
13
|
* It is expected that both OpenCV framework and opencv4nodejs
|
|
@@ -22,9 +15,9 @@ exports.DEFAULT_MATCH_THRESHOLD = DEFAULT_MATCH_THRESHOLD;
|
|
|
22
15
|
*
|
|
23
16
|
* @param {string} mode - One of possible comparison modes:
|
|
24
17
|
* matchFeatures, getSimilarity, matchTemplate
|
|
25
|
-
* @param {string} firstImage - Base64-encoded image file.
|
|
18
|
+
* @param {string|Buffer} firstImage - Base64-encoded image file.
|
|
26
19
|
* All image formats, that OpenCV library itself accepts, are supported.
|
|
27
|
-
* @param {string} secondImage - Base64-encoded image file.
|
|
20
|
+
* @param {string|Buffer} secondImage - Base64-encoded image file.
|
|
28
21
|
* All image formats, that OpenCV library itself accepts, are supported.
|
|
29
22
|
* @param {object} [options] - The content of this dictionary depends
|
|
30
23
|
* on the actual `mode` value. See the documentation on `@appium/support`
|
|
@@ -40,11 +33,11 @@ exports.DEFAULT_MATCH_THRESHOLD = DEFAULT_MATCH_THRESHOLD;
|
|
|
40
33
|
* @type {import('@appium/types').PluginCommand<[string, string, string, object|undefined], Promise<OccurrenceResult>>}
|
|
41
34
|
*/
|
|
42
35
|
async function compareImages(mode, firstImage, secondImage, options = {}) {
|
|
43
|
-
const img1 = Buffer.from(firstImage, 'base64');
|
|
44
|
-
const img2 = Buffer.from(secondImage, 'base64');
|
|
36
|
+
const img1 = Buffer.isBuffer(firstImage) ? firstImage : Buffer.from(firstImage, 'base64');
|
|
37
|
+
const img2 = Buffer.isBuffer(secondImage) ? secondImage : Buffer.from(secondImage, 'base64');
|
|
45
38
|
let result = null;
|
|
46
39
|
switch (lodash_1.default.toLower(mode)) {
|
|
47
|
-
case MATCH_FEATURES_MODE.toLowerCase():
|
|
40
|
+
case constants_1.MATCH_FEATURES_MODE.toLowerCase():
|
|
48
41
|
try {
|
|
49
42
|
result = await (0, opencv_1.getImagesMatches)(img1, img2, options);
|
|
50
43
|
}
|
|
@@ -53,10 +46,10 @@ async function compareImages(mode, firstImage, secondImage, options = {}) {
|
|
|
53
46
|
result = { count: 0 };
|
|
54
47
|
}
|
|
55
48
|
break;
|
|
56
|
-
case GET_SIMILARITY_MODE.toLowerCase():
|
|
49
|
+
case constants_1.GET_SIMILARITY_MODE.toLowerCase():
|
|
57
50
|
result = await (0, opencv_1.getImagesSimilarity)(img1, img2, options);
|
|
58
51
|
break;
|
|
59
|
-
case MATCH_TEMPLATE_MODE.toLowerCase():
|
|
52
|
+
case constants_1.MATCH_TEMPLATE_MODE.toLowerCase():
|
|
60
53
|
// firstImage/img1 is the full image and secondImage/img2 is the partial one
|
|
61
54
|
result = await (0, opencv_1.getImageOccurrence)(img1, img2, options);
|
|
62
55
|
if (options.multiple) {
|
|
@@ -66,9 +59,9 @@ async function compareImages(mode, firstImage, secondImage, options = {}) {
|
|
|
66
59
|
default:
|
|
67
60
|
throw new driver_1.errors.InvalidArgumentError(`'${mode}' images comparison mode is unknown. ` +
|
|
68
61
|
`Only ${JSON.stringify([
|
|
69
|
-
MATCH_FEATURES_MODE,
|
|
70
|
-
GET_SIMILARITY_MODE,
|
|
71
|
-
MATCH_TEMPLATE_MODE,
|
|
62
|
+
constants_1.MATCH_FEATURES_MODE,
|
|
63
|
+
constants_1.GET_SIMILARITY_MODE,
|
|
64
|
+
constants_1.MATCH_TEMPLATE_MODE,
|
|
72
65
|
])} modes are supported.`);
|
|
73
66
|
}
|
|
74
67
|
return convertVisualizationToBase64(result);
|
package/build/lib/compare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../lib/compare.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,0CAAqC;AACrC,2CAAyF;
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../lib/compare.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,0CAAqC;AACrC,2CAAyF;AACzF,2CAA0F;AAE1F;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;GAEG;AACH,KAAK,UAAU,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,GAAG,EAAE;IACtE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC1F,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,WAA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aAAa,CAAC,EAAE;QACrC,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAClE;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAID;;GAEG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const IMAGE_STRATEGY: "-image";
|
|
2
|
+
export const IMAGE_ELEMENT_PREFIX: "appium-image-element-";
|
|
3
|
+
export const IMAGE_EL_TAP_STRATEGY_W3C: "w3cActions";
|
|
4
|
+
export const IMAGE_EL_TAP_STRATEGY_MJSONWP: "touchActions";
|
|
5
|
+
export const IMAGE_TAP_STRATEGIES: string[];
|
|
6
|
+
export const DEFAULT_TEMPLATE_IMAGE_SCALE: 1;
|
|
7
|
+
export const MATCH_FEATURES_MODE: "matchFeatures";
|
|
8
|
+
export const GET_SIMILARITY_MODE: "getSimilarity";
|
|
9
|
+
export const MATCH_TEMPLATE_MODE: "matchTemplate";
|
|
10
|
+
export const DEFAULT_MATCH_THRESHOLD: 0.4;
|
|
11
|
+
export const DEFAULT_FIX_IMAGE_TEMPLATE_SCALE: 1;
|
|
12
|
+
export const DEFAULT_SETTINGS: any;
|
|
13
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.js"],"names":[],"mappings":"AAEA,sCAAuC;AAEvC,2DAA4D;AAC5D,qDAAsD;AACtD,2DAA4D;AAC5D,4CAA+F;AAC/F,6CAAgD;AAEhD,kDAAmD;AACnD,kDAAmD;AACnD,kDAAmD;AAEnD,0CAA2C;AAE3C,iDAAkD;AAElD,mCAmDG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SETTINGS = exports.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = exports.DEFAULT_MATCH_THRESHOLD = exports.MATCH_TEMPLATE_MODE = exports.GET_SIMILARITY_MODE = exports.MATCH_FEATURES_MODE = exports.DEFAULT_TEMPLATE_IMAGE_SCALE = exports.IMAGE_TAP_STRATEGIES = exports.IMAGE_EL_TAP_STRATEGY_MJSONWP = exports.IMAGE_EL_TAP_STRATEGY_W3C = exports.IMAGE_ELEMENT_PREFIX = exports.IMAGE_STRATEGY = void 0;
|
|
4
|
+
const support_1 = require("@appium/support");
|
|
5
|
+
exports.IMAGE_STRATEGY = '-image';
|
|
6
|
+
exports.IMAGE_ELEMENT_PREFIX = 'appium-image-element-';
|
|
7
|
+
exports.IMAGE_EL_TAP_STRATEGY_W3C = 'w3cActions';
|
|
8
|
+
exports.IMAGE_EL_TAP_STRATEGY_MJSONWP = 'touchActions';
|
|
9
|
+
exports.IMAGE_TAP_STRATEGIES = [exports.IMAGE_EL_TAP_STRATEGY_MJSONWP, exports.IMAGE_EL_TAP_STRATEGY_W3C];
|
|
10
|
+
exports.DEFAULT_TEMPLATE_IMAGE_SCALE = 1.0;
|
|
11
|
+
exports.MATCH_FEATURES_MODE = 'matchFeatures';
|
|
12
|
+
exports.GET_SIMILARITY_MODE = 'getSimilarity';
|
|
13
|
+
exports.MATCH_TEMPLATE_MODE = 'matchTemplate';
|
|
14
|
+
exports.DEFAULT_MATCH_THRESHOLD = 0.4;
|
|
15
|
+
exports.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = 1;
|
|
16
|
+
exports.DEFAULT_SETTINGS = support_1.node.deepFreeze({
|
|
17
|
+
// value between 0 and 1 representing match strength, below which an image
|
|
18
|
+
// element will not be found
|
|
19
|
+
imageMatchThreshold: exports.DEFAULT_MATCH_THRESHOLD,
|
|
20
|
+
// One of possible image matching methods.
|
|
21
|
+
// Read https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html
|
|
22
|
+
// for more details.
|
|
23
|
+
// TM_CCOEFF_NORMED by default
|
|
24
|
+
imageMatchMethod: '',
|
|
25
|
+
// if the image returned by getScreenshot differs in size or aspect ratio
|
|
26
|
+
// from the screen, attempt to fix it automatically
|
|
27
|
+
fixImageFindScreenshotDims: true,
|
|
28
|
+
// whether Appium should ensure that an image template sent in during image
|
|
29
|
+
// element find should have its size adjusted so the match algorithm will not
|
|
30
|
+
// complain
|
|
31
|
+
fixImageTemplateSize: false,
|
|
32
|
+
// whether Appium should ensure that an image template sent in during image
|
|
33
|
+
// element find should have its scale adjusted to display size so the match
|
|
34
|
+
// algorithm will not complain.
|
|
35
|
+
// e.g. iOS has `width=375, height=667` window rect, but its screenshot is
|
|
36
|
+
// `width=750 × height=1334` pixels. This setting help to adjust the scale
|
|
37
|
+
// if a user use `width=750 × height=1334` pixels's base template image.
|
|
38
|
+
fixImageTemplateScale: false,
|
|
39
|
+
// Users might have scaled template image to reduce their storage size.
|
|
40
|
+
// This setting allows users to scale a template image they send to Appium server
|
|
41
|
+
// so that the Appium server compares the actual scale users originally had.
|
|
42
|
+
// e.g. If a user has an image of 270 x 32 pixels which was originally 1080 x 126 pixels,
|
|
43
|
+
// the user can set {defaultImageTemplateScale: 4.0} to scale the small image
|
|
44
|
+
// to the original one so that Appium can compare it as the original one.
|
|
45
|
+
defaultImageTemplateScale: exports.DEFAULT_TEMPLATE_IMAGE_SCALE,
|
|
46
|
+
// whether Appium should re-check that an image element can be matched
|
|
47
|
+
// against the current screenshot before clicking it
|
|
48
|
+
checkForImageElementStaleness: true,
|
|
49
|
+
// whether before clicking on an image element Appium should re-determine the
|
|
50
|
+
// position of the element on screen
|
|
51
|
+
autoUpdateImageElementPosition: false,
|
|
52
|
+
// which method to use for tapping by coordinate for image elements. the
|
|
53
|
+
// options are 'w3c' or 'mjsonwp'
|
|
54
|
+
imageElementTapStrategy: exports.IMAGE_EL_TAP_STRATEGY_W3C,
|
|
55
|
+
// which method to use to save the matched image area in ImageElement class.
|
|
56
|
+
// It is used for debugging purpose.
|
|
57
|
+
getMatchedImageResult: false,
|
|
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E,IAAI;IAEnC,6EAA6E;IAC7E,oCAAoC;IACpC,8BAA8B,EAAE,KAAK;IAErC,wEAAwE;IACxE,iCAAiC;IACjC,uBAAuB,EAAE,iCAAyB;IAElD,4EAA4E;IAC5E,oCAAoC;IACpC,qBAAqB,EAAE,KAAK;CAC7B,CAAC,CAAC"}
|
package/build/lib/finder.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export default class ImageElementFinder {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {ExternalDriver} driver
|
|
5
|
-
* @param {number} [maxSize]
|
|
3
|
+
* @param {number} max
|
|
6
4
|
*/
|
|
7
|
-
constructor(
|
|
8
|
-
/** @type {ExternalDriver} */
|
|
9
|
-
driver: ExternalDriver;
|
|
5
|
+
constructor(max?: number);
|
|
10
6
|
/** @type {LRU<string,ImageElement>} */
|
|
11
|
-
|
|
12
|
-
setDriver(driver: any): void;
|
|
7
|
+
_imgElCache: LRU<string, ImageElement>;
|
|
13
8
|
/**
|
|
14
9
|
* @param {ImageElement} imgEl
|
|
15
10
|
* @returns {Element}
|
|
16
11
|
*/
|
|
17
12
|
registerImageElement(imgEl: ImageElement): Element;
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} imgElId
|
|
15
|
+
* @returns {ImageElement|undefined}
|
|
16
|
+
*/
|
|
17
|
+
getImageElement(imgElId: string): ImageElement | undefined;
|
|
18
|
+
clearImageElements(): void;
|
|
18
19
|
/**
|
|
19
20
|
* @typedef FindByImageOptions
|
|
20
21
|
* @property {boolean} [shouldCheckStaleness=false] - whether this call to find an
|
|
@@ -23,19 +24,22 @@ export default class ImageElementFinder {
|
|
|
23
24
|
* multiple
|
|
24
25
|
* @property {boolean} [ignoreDefaultImageTemplateScale=false] - Whether we
|
|
25
26
|
* ignore defaultImageTemplateScale. It can be used when you would like to
|
|
26
|
-
* scale
|
|
27
|
+
* scale template with defaultImageTemplateScale setting.
|
|
28
|
+
* @property {import('@appium/types').Rect?} containerRect - The bounding
|
|
29
|
+
* rectangle to limit the search in
|
|
27
30
|
*/
|
|
28
31
|
/**
|
|
29
32
|
* Find a screen rect represented by an ImageElement corresponding to an image
|
|
30
33
|
* template sent in by the client
|
|
31
34
|
*
|
|
32
|
-
* @param {
|
|
35
|
+
* @param {Buffer} template - image used as a template to be
|
|
33
36
|
* matched in the screenshot
|
|
37
|
+
* @param {ExternalDriver} driver
|
|
34
38
|
* @param {FindByImageOptions} opts - additional options
|
|
35
39
|
*
|
|
36
40
|
* @returns {Promise<Element|Element[]|ImageElement>} - WebDriver element with a special id prefix
|
|
37
41
|
*/
|
|
38
|
-
findByImage(
|
|
42
|
+
findByImage(template: Buffer, driver: ExternalDriver, { shouldCheckStaleness, multiple, ignoreDefaultImageTemplateScale, containerRect }: {
|
|
39
43
|
/**
|
|
40
44
|
* - whether this call to find an
|
|
41
45
|
* image is merely to check staleness. If so we can bypass a lot of logic
|
|
@@ -49,30 +53,34 @@ export default class ImageElementFinder {
|
|
|
49
53
|
/**
|
|
50
54
|
* - Whether we
|
|
51
55
|
* ignore defaultImageTemplateScale. It can be used when you would like to
|
|
52
|
-
* scale
|
|
56
|
+
* scale template with defaultImageTemplateScale setting.
|
|
53
57
|
*/
|
|
54
58
|
ignoreDefaultImageTemplateScale?: boolean | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* - The bounding
|
|
61
|
+
* rectangle to limit the search in
|
|
62
|
+
*/
|
|
63
|
+
containerRect: import('@appium/types').Rect | null;
|
|
55
64
|
}): Promise<Element | Element[] | ImageElement>;
|
|
56
65
|
/**
|
|
57
66
|
* Ensure that the image template sent in for a find is of a suitable size
|
|
58
67
|
*
|
|
59
|
-
* @param {
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {number} screenHeight - height of screen
|
|
68
|
+
* @param {Buffer} template - template image
|
|
69
|
+
* @param {import('@appium/types').Size} maxSize - size of the bounding rectangle
|
|
62
70
|
*
|
|
63
|
-
* @returns {Promise<
|
|
71
|
+
* @returns {Promise<Buffer>} image, potentially resized
|
|
64
72
|
*/
|
|
65
|
-
ensureTemplateSize(
|
|
73
|
+
ensureTemplateSize(template: Buffer, maxSize: import('@appium/types').Size): Promise<Buffer>;
|
|
66
74
|
/**
|
|
67
75
|
* Get the screenshot image that will be used for find by element, potentially
|
|
68
76
|
* altering it in various ways based on user-requested settings
|
|
69
77
|
*
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {
|
|
78
|
+
* @param {ExternalDriver} driver
|
|
79
|
+
* @param {import('@appium/types').Size} screenSize - The original size of the screen
|
|
72
80
|
*
|
|
73
|
-
* @returns {Promise<Screenshot & {scale?: ScreenshotScale}>}
|
|
81
|
+
* @returns {Promise<Screenshot & {scale?: ScreenshotScale}>} PNG screenshot and ScreenshotScale
|
|
74
82
|
*/
|
|
75
|
-
getScreenshotForImageFind(
|
|
83
|
+
getScreenshotForImageFind(driver: ExternalDriver, screenSize: import('@appium/types').Size): Promise<Screenshot & {
|
|
76
84
|
scale?: ScreenshotScale | undefined;
|
|
77
85
|
}>;
|
|
78
86
|
/**
|
|
@@ -80,7 +88,7 @@ export default class ImageElementFinder {
|
|
|
80
88
|
* @property {boolean} fixImageTemplateScale - fixImageTemplateScale in device-settings
|
|
81
89
|
* @property {number} defaultImageTemplateScale - defaultImageTemplateScale in device-settings
|
|
82
90
|
* @property {boolean} ignoreDefaultImageTemplateScale - Ignore defaultImageTemplateScale if it has true.
|
|
83
|
-
* If
|
|
91
|
+
* If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
|
|
84
92
|
* this parameter should be true. e.g. click in image-element module
|
|
85
93
|
* @property {number} xScale - Scale ratio for width
|
|
86
94
|
* @property {number} yScale - Scale ratio for height
|
|
@@ -90,14 +98,13 @@ export default class ImageElementFinder {
|
|
|
90
98
|
* Get a image that will be used for template maching.
|
|
91
99
|
* Returns scaled image if scale ratio is provided.
|
|
92
100
|
*
|
|
93
|
-
*
|
|
94
|
-
* @param {string} b64Template - base64-encoded image used as a template to be
|
|
101
|
+
* @param {Buffer} template - image used as a template to be
|
|
95
102
|
* matched in the screenshot
|
|
96
103
|
* @param {ImageTemplateSettings} opts - Image template scale related options
|
|
97
104
|
*
|
|
98
|
-
* @returns {Promise<
|
|
105
|
+
* @returns {Promise<Buffer>} scaled template screenshot
|
|
99
106
|
*/
|
|
100
|
-
fixImageTemplateScale(
|
|
107
|
+
fixImageTemplateScale(template: Buffer, opts: {
|
|
101
108
|
/**
|
|
102
109
|
* - fixImageTemplateScale in device-settings
|
|
103
110
|
*/
|
|
@@ -108,7 +115,7 @@ export default class ImageElementFinder {
|
|
|
108
115
|
defaultImageTemplateScale: number;
|
|
109
116
|
/**
|
|
110
117
|
* - Ignore defaultImageTemplateScale if it has true.
|
|
111
|
-
* If
|
|
118
|
+
* If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
|
|
112
119
|
* this parameter should be true. e.g. click in image-element module
|
|
113
120
|
*/
|
|
114
121
|
ignoreDefaultImageTemplateScale: boolean;
|
|
@@ -120,15 +127,15 @@ export default class ImageElementFinder {
|
|
|
120
127
|
* - Scale ratio for height
|
|
121
128
|
*/
|
|
122
129
|
yScale: number;
|
|
123
|
-
}): Promise<
|
|
130
|
+
}): Promise<Buffer>;
|
|
124
131
|
}
|
|
125
132
|
export type ExternalDriver = import('@appium/types').ExternalDriver;
|
|
126
133
|
export type Element = import('@appium/types').Element;
|
|
127
134
|
export type Screenshot = {
|
|
128
135
|
/**
|
|
129
|
-
* -
|
|
136
|
+
* - screenshot image as PNG
|
|
130
137
|
*/
|
|
131
|
-
|
|
138
|
+
screenshot: Buffer;
|
|
132
139
|
};
|
|
133
140
|
export type ScreenshotScale = {
|
|
134
141
|
/**
|
|
@@ -142,22 +149,4 @@ export type ScreenshotScale = {
|
|
|
142
149
|
};
|
|
143
150
|
import LRU from "lru-cache";
|
|
144
151
|
import { ImageElement } from "./image-element";
|
|
145
|
-
export const W3C_ELEMENT_KEY: "element-6066-11e4-a52e-4f735466cecf";
|
|
146
|
-
export const MJSONWP_ELEMENT_KEY: "ELEMENT";
|
|
147
|
-
export namespace DEFAULT_SETTINGS {
|
|
148
|
-
export { DEFAULT_MATCH_THRESHOLD as imageMatchThreshold };
|
|
149
|
-
export const imageMatchMethod: string;
|
|
150
|
-
export const fixImageFindScreenshotDims: boolean;
|
|
151
|
-
export const fixImageTemplateSize: boolean;
|
|
152
|
-
export const fixImageTemplateScale: boolean;
|
|
153
|
-
export { DEFAULT_TEMPLATE_IMAGE_SCALE as defaultImageTemplateScale };
|
|
154
|
-
export const checkForImageElementStaleness: boolean;
|
|
155
|
-
export const autoUpdateImageElementPosition: boolean;
|
|
156
|
-
export { IMAGE_EL_TAP_STRATEGY_W3C as imageElementTapStrategy };
|
|
157
|
-
export const getMatchedImageResult: boolean;
|
|
158
|
-
}
|
|
159
|
-
export const DEFAULT_FIX_IMAGE_TEMPLATE_SCALE: 1;
|
|
160
|
-
import { DEFAULT_MATCH_THRESHOLD } from "./compare";
|
|
161
|
-
import { DEFAULT_TEMPLATE_IMAGE_SCALE } from "./image-element";
|
|
162
|
-
import { IMAGE_EL_TAP_STRATEGY_W3C } from "./image-element";
|
|
163
152
|
//# sourceMappingURL=finder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finder.d.ts","sourceRoot":"","sources":["../../lib/finder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"finder.d.ts","sourceRoot":"","sources":["../../lib/finder.js"],"names":[],"mappings":"AAmCA;IAIE;;OAEG;IACH,kBAFW,MAAM,EAQhB;IAZD,uCAAuC;IACvC,aADW,IAAI,MAAM,EAAC,YAAY,CAAC,CACvB;IAaZ;;;OAGG;IACH,4BAHW,YAAY,GACV,OAAO,CAKnB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,YAAY,GAAC,SAAS,CAIlC;IAED,2BAEC;IAED;;;;;;;;;;;OAWG;IAEH;;;;;;;;;;OAUG;IACH,sBAPW,MAAM,UAEN,cAAc;;;;;;;;;;;;;;;;;;;;;uBAVX,OAAO,eAAe,EAAE,IAAI;QAa7B,QAAQ,OAAO,GAAC,OAAO,EAAE,GAAC,YAAY,CAAC,CAsInD;IAED;;;;;;;OAOG;IACH,6BALW,MAAM,WACN,OAAO,eAAe,EAAE,IAAI,GAE1B,QAAQ,MAAM,CAAC,CA0B3B;IAED;;;;;;;;OAQG;IACH,kCALW,cAAc,cACd,OAAO,eAAe,EAAE,IAAI;;OAiItC;IAED;;;;;;;;;;OAUG;IACH;;;;;;;;;OASG;IACH,gCANW,MAAM;;;;+BAbH,OAAO;;;;mCACP,MAAM;;;;;;yCACN,OAAO;;;;gBAGP,MAAM;;;;gBACN,MAAM;QAWP,QAAQ,MAAM,CAAC,CAkE3B;CACF;6BAGY,OAAO,eAAe,EAAE,cAAc;sBACtC,OAAO,eAAe,EAAE,OAAO;;;;;gBAK9B,MAAM;;;;;;YAKN,MAAM;;;;YACN,MAAM"}
|