@appium/images-plugin 4.0.3 → 4.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 +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/LICENSE +0 -201
- package/index.js +0 -1
- package/lib/compare.js +0 -96
- package/lib/constants.js +0 -70
- package/lib/logger.js +0 -5
package/build/lib/compare.d.ts
CHANGED
|
@@ -1,39 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
4
|
-
export type MatchingResult = import("@appium/opencv").MatchingResult & Visualized;
|
|
5
|
-
export type OccurrenceResult = import("@appium/opencv").OccurrenceResult & Visualized;
|
|
6
|
-
export type SimilarityResult = import("@appium/opencv").SimilarityResult & Visualized;
|
|
7
|
-
export type ComparisonResult = MatchingResult | OccurrenceResult | SimilarityResult | SimilarityResult[];
|
|
8
|
-
/**
|
|
9
|
-
* @typedef {{visualization: string|null|undefined}} Visualized
|
|
10
|
-
* @typedef {import('@appium/opencv').MatchingResult & Visualized} MatchingResult
|
|
11
|
-
* @typedef {import('@appium/opencv').OccurrenceResult & Visualized} OccurrenceResult
|
|
12
|
-
* @typedef {import('@appium/opencv').SimilarityResult & Visualized} SimilarityResult
|
|
13
|
-
* @typedef {MatchingResult|OccurrenceResult|SimilarityResult|SimilarityResult[]} ComparisonResult
|
|
14
|
-
*/
|
|
1
|
+
import { type MatchingOptions, type SimilarityOptions, type OccurrenceOptions } from '@appium/opencv';
|
|
2
|
+
import type { ComparisonResult } from './types';
|
|
15
3
|
/**
|
|
16
4
|
* Performs images comparison using OpenCV framework features.
|
|
17
5
|
* It is expected that both OpenCV framework and opencv4nodejs
|
|
18
6
|
* module are installed on the machine where Appium server is running.
|
|
19
7
|
*
|
|
20
|
-
* @param
|
|
8
|
+
* @param mode - One of possible comparison modes:
|
|
21
9
|
* matchFeatures, getSimilarity, matchTemplate
|
|
22
|
-
* @param
|
|
10
|
+
* @param firstImage - Base64-encoded image file.
|
|
23
11
|
* All image formats, that OpenCV library itself accepts, are supported.
|
|
24
|
-
* @param
|
|
12
|
+
* @param secondImage - Base64-encoded image file.
|
|
25
13
|
* All image formats, that OpenCV library itself accepts, are supported.
|
|
26
|
-
* @param
|
|
27
|
-
* |import('@appium/opencv').SimilarityOptions
|
|
28
|
-
* |import('@appium/opencv').OccurrenceOptions} [options={}] - The content of this dictionary depends
|
|
14
|
+
* @param options - The content of this dictionary depends
|
|
29
15
|
* on the actual `mode` value. See the documentation on `@appium/support`
|
|
30
16
|
* module for more details.
|
|
31
|
-
* @returns
|
|
17
|
+
* @returns The content of the resulting dictionary depends
|
|
32
18
|
* on the actual `mode` and `options` values. See the documentation on
|
|
33
19
|
* `@appium/support` module for more details.
|
|
34
20
|
* @throws {Error} If required OpenCV modules are not installed or
|
|
35
21
|
* if `mode` value is incorrect or if there was an unexpected issue while
|
|
36
22
|
* matching the images.
|
|
37
23
|
*/
|
|
38
|
-
export function compareImages(mode: string, firstImage: string | Buffer, secondImage: string | Buffer, options?:
|
|
24
|
+
export declare function compareImages(mode: string, firstImage: string | Buffer, secondImage: string | Buffer, options?: MatchingOptions | SimilarityOptions | OccurrenceOptions): Promise<ComparisonResult>;
|
|
39
25
|
//# sourceMappingURL=compare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../lib/compare.
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../lib/compare.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,OAAO,GAAE,eAAe,GAAG,iBAAiB,GAAG,iBAAsB,GACpE,OAAO,CAAC,gBAAgB,CAAC,CAuC3B"}
|
package/build/lib/compare.js
CHANGED
|
@@ -8,30 +8,21 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const driver_1 = require("appium/driver");
|
|
9
9
|
const opencv_1 = require("@appium/opencv");
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {{visualization: string|null|undefined}} Visualized
|
|
13
|
-
* @typedef {import('@appium/opencv').MatchingResult & Visualized} MatchingResult
|
|
14
|
-
* @typedef {import('@appium/opencv').OccurrenceResult & Visualized} OccurrenceResult
|
|
15
|
-
* @typedef {import('@appium/opencv').SimilarityResult & Visualized} SimilarityResult
|
|
16
|
-
* @typedef {MatchingResult|OccurrenceResult|SimilarityResult|SimilarityResult[]} ComparisonResult
|
|
17
|
-
*/
|
|
18
11
|
/**
|
|
19
12
|
* Performs images comparison using OpenCV framework features.
|
|
20
13
|
* It is expected that both OpenCV framework and opencv4nodejs
|
|
21
14
|
* module are installed on the machine where Appium server is running.
|
|
22
15
|
*
|
|
23
|
-
* @param
|
|
16
|
+
* @param mode - One of possible comparison modes:
|
|
24
17
|
* matchFeatures, getSimilarity, matchTemplate
|
|
25
|
-
* @param
|
|
18
|
+
* @param firstImage - Base64-encoded image file.
|
|
26
19
|
* All image formats, that OpenCV library itself accepts, are supported.
|
|
27
|
-
* @param
|
|
20
|
+
* @param secondImage - Base64-encoded image file.
|
|
28
21
|
* All image formats, that OpenCV library itself accepts, are supported.
|
|
29
|
-
* @param
|
|
30
|
-
* |import('@appium/opencv').SimilarityOptions
|
|
31
|
-
* |import('@appium/opencv').OccurrenceOptions} [options={}] - The content of this dictionary depends
|
|
22
|
+
* @param options - The content of this dictionary depends
|
|
32
23
|
* on the actual `mode` value. See the documentation on `@appium/support`
|
|
33
24
|
* module for more details.
|
|
34
|
-
* @returns
|
|
25
|
+
* @returns The content of the resulting dictionary depends
|
|
35
26
|
* on the actual `mode` and `options` values. See the documentation on
|
|
36
27
|
* `@appium/support` module for more details.
|
|
37
28
|
* @throws {Error} If required OpenCV modules are not installed or
|
|
@@ -45,22 +36,25 @@ async function compareImages(mode, firstImage, secondImage, options = {}) {
|
|
|
45
36
|
switch (lodash_1.default.toLower(mode)) {
|
|
46
37
|
case constants_1.MATCH_FEATURES_MODE.toLowerCase():
|
|
47
38
|
try {
|
|
48
|
-
result = await (0, opencv_1.getImagesMatches)(img1, img2,
|
|
39
|
+
result = await (0, opencv_1.getImagesMatches)(img1, img2, options);
|
|
49
40
|
}
|
|
50
41
|
catch {
|
|
51
42
|
// might throw if no matches
|
|
52
|
-
result =
|
|
43
|
+
result = { count: 0 };
|
|
53
44
|
}
|
|
54
45
|
break;
|
|
55
46
|
case constants_1.GET_SIMILARITY_MODE.toLowerCase():
|
|
56
|
-
result = await (0, opencv_1.getImagesSimilarity)(img1, img2,
|
|
47
|
+
result = await (0, opencv_1.getImagesSimilarity)(img1, img2, options);
|
|
57
48
|
break;
|
|
58
49
|
case constants_1.MATCH_TEMPLATE_MODE.toLowerCase(): {
|
|
59
|
-
const opts =
|
|
50
|
+
const opts = options;
|
|
60
51
|
// firstImage/img1 is the full image and secondImage/img2 is the partial one
|
|
61
52
|
result = await (0, opencv_1.getImageOccurrence)(img1, img2, opts);
|
|
62
53
|
if (opts.multiple && result.multiple) {
|
|
63
|
-
|
|
54
|
+
const multipleResults = result.multiple;
|
|
55
|
+
if (multipleResults) {
|
|
56
|
+
return multipleResults.map(convertVisualizationToBase64);
|
|
57
|
+
}
|
|
64
58
|
}
|
|
65
59
|
break;
|
|
66
60
|
}
|
|
@@ -78,14 +72,14 @@ async function compareImages(mode, firstImage, secondImage, options = {}) {
|
|
|
78
72
|
* base64 encodes the visualization part of the result
|
|
79
73
|
* (if necessary)
|
|
80
74
|
*
|
|
81
|
-
* @param
|
|
82
|
-
* @returns
|
|
75
|
+
* @param element - occurrence result
|
|
76
|
+
* @returns result with base64-encoded visualization
|
|
83
77
|
**/
|
|
84
78
|
function convertVisualizationToBase64(element) {
|
|
85
79
|
return Buffer.isBuffer(element.visualization)
|
|
86
80
|
? {
|
|
87
|
-
...
|
|
88
|
-
visualization: element.visualization.toString('base64')
|
|
81
|
+
...element,
|
|
82
|
+
visualization: element.visualization.toString('base64'),
|
|
89
83
|
}
|
|
90
84
|
: element;
|
|
91
85
|
}
|
package/build/lib/compare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../lib/compare.
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../lib/compare.ts"],"names":[],"mappings":";;;;;AAqCA,sCA4CC;AAjFD,oDAAuB;AACvB,0CAAqC;AACrC,2CAUwB;AACxB,2CAA0F;AAG1F;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,UAA2B,EAC3B,WAA4B,EAC5B,UAAmE,EAAE;IAErE,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,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC7F,IAAI,MAA4D,CAAC;IACjE,QAAQ,gBAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,+BAAmB,CAAC,WAAW,EAAE;YACpC,IAAI,CAAC;gBACH,MAAM,GAAG,MAAM,IAAA,yBAAgB,EAAC,IAAI,EAAE,IAAI,EAAE,OAA0B,CAAC,CAAC;YAC1E,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;gBAC5B,MAAM,GAAG,EAAC,KAAK,EAAE,CAAC,EAAmB,CAAC;YACxC,CAAC;YACD,MAAM;QACR,KAAK,+BAAmB,CAAC,WAAW,EAAE;YACpC,MAAM,GAAG,MAAM,IAAA,4BAAmB,EAAC,IAAI,EAAE,IAAI,EAAE,OAA4B,CAAC,CAAC;YAC7E,MAAM;QACR,KAAK,+BAAmB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,OAA4B,CAAC;YAC1C,4EAA4E;YAC5E,MAAM,GAAG,MAAM,IAAA,2BAAkB,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACpD,IAAI,IAAI,CAAC,QAAQ,IAAK,MAA2B,CAAC,QAAQ,EAAE,CAAC;gBAC3D,MAAM,eAAe,GAAI,MAA2B,CAAC,QAAQ,CAAC;gBAC9D,IAAI,eAAe,EAAE,CAAC;oBACpB,OAAO,eAAe,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;YACD,MAAM;QACR,CAAC;QACD;YACE,MAAM,IAAI,eAAM,CAAC,oBAAoB,CACnC,IAAI,IAAI,uCAAuC;gBAC7C,QAAQ,IAAI,CAAC,SAAS,CAAC;oBACrB,+BAAmB;oBACnB,+BAAmB;oBACnB,+BAAmB;iBACpB,CAAC,uBAAuB,CAC5B,CAAC;IACN,CAAC;IACD,OAAO,4BAA4B,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;IAMI;AACJ,SAAS,4BAA4B,CACnC,OAAgD;IAEhD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3C,CAAC,CAAC;YACE,GAAG,OAAO;YACV,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;SACxD;QACH,CAAC,CAAC,OAAO,CAAC;AACd,CAAC"}
|
package/build/lib/constants.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
1
|
+
import type { ImageSettings } from './types';
|
|
2
|
+
export declare const IMAGE_STRATEGY = "-image";
|
|
3
|
+
export declare const IMAGE_ELEMENT_PREFIX = "appium-image-element-";
|
|
4
|
+
export declare const IMAGE_EL_TAP_STRATEGY_W3C = "w3cActions";
|
|
5
|
+
export declare const IMAGE_EL_TAP_STRATEGY_MJSONWP = "touchActions";
|
|
6
|
+
export declare const IMAGE_TAP_STRATEGIES: readonly ["touchActions", "w3cActions"];
|
|
7
|
+
export declare const DEFAULT_TEMPLATE_IMAGE_SCALE = 1;
|
|
8
|
+
export declare const MATCH_FEATURES_MODE = "matchFeatures";
|
|
9
|
+
export declare const GET_SIMILARITY_MODE = "getSimilarity";
|
|
10
|
+
export declare const MATCH_TEMPLATE_MODE = "matchTemplate";
|
|
11
|
+
export declare const DEFAULT_MATCH_THRESHOLD = 0.4;
|
|
12
|
+
export declare const DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = 1;
|
|
13
|
+
export declare const DEFAULT_SETTINGS: ImageSettings;
|
|
13
14
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAC5D,eAAO,MAAM,yBAAyB,eAAe,CAAC;AACtD,eAAO,MAAM,6BAA6B,iBAAiB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,yCAAsE,CAAC;AACxG,eAAO,MAAM,4BAA4B,IAAM,CAAC;AAEhD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD,eAAO,MAAM,gBAAgB,EAWvB,aAAa,CAAC"}
|
package/build/lib/constants.js
CHANGED
|
@@ -14,46 +14,15 @@ exports.MATCH_TEMPLATE_MODE = 'matchTemplate';
|
|
|
14
14
|
exports.DEFAULT_MATCH_THRESHOLD = 0.4;
|
|
15
15
|
exports.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = 1;
|
|
16
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
17
|
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
18
|
imageMatchMethod: '',
|
|
25
|
-
// if the image returned by getScreenshot differs in size or aspect ratio
|
|
26
|
-
// from the screen, attempt to fix it automatically
|
|
27
19
|
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
20
|
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
21
|
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
22
|
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
23
|
checkForImageElementStaleness: true,
|
|
49
|
-
// whether before clicking on an image element Appium should re-determine the
|
|
50
|
-
// position of the element on screen
|
|
51
24
|
autoUpdateImageElementPosition: false,
|
|
52
|
-
// which method to use for tapping by coordinate for image elements. the
|
|
53
|
-
// options are 'w3c' or 'mjsonwp'
|
|
54
25
|
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
26
|
getMatchedImageResult: false,
|
|
58
27
|
});
|
|
59
28
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.ts"],"names":[],"mappings":";;;AAAA,4CAAoC;AAGvB,QAAA,cAAc,GAAG,QAAQ,CAAC;AAE1B,QAAA,oBAAoB,GAAG,uBAAuB,CAAC;AAC/C,QAAA,yBAAyB,GAAG,YAAY,CAAC;AACzC,QAAA,6BAA6B,GAAG,cAAc,CAAC;AAC/C,QAAA,oBAAoB,GAAG,CAAC,qCAA6B,EAAE,iCAAyB,CAAU,CAAC;AAC3F,QAAA,4BAA4B,GAAG,GAAG,CAAC;AAEnC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AACtC,QAAA,mBAAmB,GAAG,eAAe,CAAC;AAEtC,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAE9B,QAAA,gCAAgC,GAAG,CAAC,CAAC;AAErC,QAAA,gBAAgB,GAAG,cAAI,CAAC,UAAU,CAAC;IAC9C,mBAAmB,EAAE,+BAAuB;IAC5C,gBAAgB,EAAE,EAAE;IACpB,0BAA0B,EAAE,IAAI;IAChC,oBAAoB,EAAE,KAAK;IAC3B,qBAAqB,EAAE,KAAK;IAC5B,yBAAyB,EAAE,oCAA4B;IACvD,6BAA6B,EAAE,IAAI;IACnC,8BAA8B,EAAE,KAAK;IACrC,uBAAuB,EAAE,iCAAyB;IAClD,qBAAqB,EAAE,KAAK;CAC7B,CAAkB,CAAC"}
|
package/build/lib/finder.d.ts
CHANGED
|
@@ -1,152 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ImageElement } from './image-element';
|
|
2
|
+
import type { ExternalDriver, Element, Size } from '@appium/types';
|
|
3
|
+
import type { FindByImageOptions, Screenshot, ScreenshotScale, ImageTemplateSettings } from './types';
|
|
4
|
+
export declare class ImageElementFinder {
|
|
5
|
+
private _imgElCache;
|
|
5
6
|
constructor(max?: number);
|
|
6
|
-
/** @type {LRUCache<string,ImageElement>} */
|
|
7
|
-
_imgElCache: LRUCache<string, ImageElement>;
|
|
8
|
-
/**
|
|
9
|
-
* @param {ImageElement} imgEl
|
|
10
|
-
* @returns {Element}
|
|
11
|
-
*/
|
|
12
7
|
registerImageElement(imgEl: ImageElement): Element;
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} imgElId
|
|
15
|
-
* @returns {ImageElement|undefined}
|
|
16
|
-
*/
|
|
17
8
|
getImageElement(imgElId: string): ImageElement | undefined;
|
|
18
9
|
clearImageElements(): void;
|
|
19
|
-
/**
|
|
20
|
-
* @typedef FindByImageOptions
|
|
21
|
-
* @property {boolean} [shouldCheckStaleness=false] - whether this call to find an
|
|
22
|
-
* image is merely to check staleness. If so we can bypass a lot of logic
|
|
23
|
-
* @property {boolean} [multiple=false] - Whether we are finding one element or
|
|
24
|
-
* multiple
|
|
25
|
-
* @property {boolean} [ignoreDefaultImageTemplateScale=false] - Whether we
|
|
26
|
-
* ignore defaultImageTemplateScale. It can be used when you would like to
|
|
27
|
-
* scale template with defaultImageTemplateScale setting.
|
|
28
|
-
* @property {import('@appium/types').Rect?} [containerRect=null] - The bounding
|
|
29
|
-
* rectangle to limit the search in
|
|
30
|
-
*/
|
|
31
10
|
/**
|
|
32
11
|
* Find a screen rect represented by an ImageElement corresponding to an image
|
|
33
12
|
* template sent in by the client
|
|
34
13
|
*
|
|
35
|
-
* @param
|
|
36
|
-
*
|
|
37
|
-
* @param
|
|
38
|
-
* @param {FindByImageOptions} opts - additional options
|
|
14
|
+
* @param template - image used as a template to be matched in the screenshot
|
|
15
|
+
* @param driver
|
|
16
|
+
* @param opts - additional options
|
|
39
17
|
*
|
|
40
|
-
* @returns
|
|
18
|
+
* @returns WebDriver element with a special id prefix
|
|
41
19
|
*/
|
|
42
|
-
findByImage(template: Buffer, driver: ExternalDriver, { shouldCheckStaleness, multiple, ignoreDefaultImageTemplateScale, containerRect }:
|
|
43
|
-
/**
|
|
44
|
-
* - whether this call to find an
|
|
45
|
-
* image is merely to check staleness. If so we can bypass a lot of logic
|
|
46
|
-
*/
|
|
47
|
-
shouldCheckStaleness?: boolean | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* - Whether we are finding one element or
|
|
50
|
-
* multiple
|
|
51
|
-
*/
|
|
52
|
-
multiple?: boolean | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* - Whether we
|
|
55
|
-
* ignore defaultImageTemplateScale. It can be used when you would like to
|
|
56
|
-
* scale template with defaultImageTemplateScale setting.
|
|
57
|
-
*/
|
|
58
|
-
ignoreDefaultImageTemplateScale?: boolean | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* - The bounding
|
|
61
|
-
* rectangle to limit the search in
|
|
62
|
-
*/
|
|
63
|
-
containerRect?: import("@appium/types").Rect | null | undefined;
|
|
64
|
-
}): Promise<Element | Element[] | ImageElement>;
|
|
20
|
+
findByImage(template: Buffer, driver: ExternalDriver, { shouldCheckStaleness, multiple, ignoreDefaultImageTemplateScale, containerRect, }?: FindByImageOptions): Promise<Element | Element[] | ImageElement>;
|
|
65
21
|
/**
|
|
66
22
|
* Ensure that the image template sent in for a find is of a suitable size
|
|
67
23
|
*
|
|
68
|
-
* @param
|
|
69
|
-
* @param
|
|
24
|
+
* @param template - template image
|
|
25
|
+
* @param maxSize - size of the bounding rectangle
|
|
70
26
|
*
|
|
71
|
-
* @returns
|
|
27
|
+
* @returns image, potentially resized
|
|
72
28
|
*/
|
|
73
|
-
ensureTemplateSize(template: Buffer, maxSize:
|
|
29
|
+
ensureTemplateSize(template: Buffer, maxSize: Size): Promise<Buffer>;
|
|
74
30
|
/**
|
|
75
31
|
* Get the screenshot image that will be used for find by element, potentially
|
|
76
32
|
* altering it in various ways based on user-requested settings
|
|
77
33
|
*
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
34
|
+
* @param driver
|
|
35
|
+
* @param screenSize - The original size of the screen
|
|
80
36
|
*
|
|
81
|
-
* @returns
|
|
37
|
+
* @returns PNG screenshot and ScreenshotScale
|
|
82
38
|
*/
|
|
83
|
-
getScreenshotForImageFind(driver: ExternalDriver, screenSize:
|
|
39
|
+
getScreenshotForImageFind(driver: ExternalDriver, screenSize: Size): Promise<Screenshot & {
|
|
84
40
|
scale?: ScreenshotScale;
|
|
85
41
|
}>;
|
|
86
|
-
/**
|
|
87
|
-
* @typedef ImageTemplateSettings
|
|
88
|
-
* @property {boolean} [fixImageTemplateScale=false] - fixImageTemplateScale in device-settings
|
|
89
|
-
* @property {number} [defaultImageTemplateScale=DEFAULT_TEMPLATE_IMAGE_SCALE] - defaultImageTemplateScale in device-settings
|
|
90
|
-
* @property {boolean} [ignoreDefaultImageTemplateScale=false] - Ignore defaultImageTemplateScale if it has true.
|
|
91
|
-
* If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
|
|
92
|
-
* this parameter should be true. e.g. click in image-element module
|
|
93
|
-
* @property {number} [xScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for width
|
|
94
|
-
* @property {number} [yScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for height
|
|
95
|
-
|
|
96
|
-
*/
|
|
97
42
|
/**
|
|
98
43
|
* Get a image that will be used for template matching.
|
|
99
44
|
* Returns scaled image if scale ratio is provided.
|
|
100
45
|
*
|
|
101
|
-
* @param
|
|
102
|
-
*
|
|
103
|
-
* @param {ImageTemplateSettings} opts - Image template scale related options
|
|
46
|
+
* @param template - image used as a template to be matched in the screenshot
|
|
47
|
+
* @param opts - Image template scale related options
|
|
104
48
|
*
|
|
105
|
-
* @returns
|
|
49
|
+
* @returns scaled template screenshot
|
|
106
50
|
*/
|
|
107
|
-
fixImageTemplateScale(template: Buffer, opts:
|
|
108
|
-
/**
|
|
109
|
-
* - fixImageTemplateScale in device-settings
|
|
110
|
-
*/
|
|
111
|
-
fixImageTemplateScale?: boolean | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* - defaultImageTemplateScale in device-settings
|
|
114
|
-
*/
|
|
115
|
-
defaultImageTemplateScale?: number | undefined;
|
|
116
|
-
/**
|
|
117
|
-
* - Ignore defaultImageTemplateScale if it has true.
|
|
118
|
-
* If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
|
|
119
|
-
* this parameter should be true. e.g. click in image-element module
|
|
120
|
-
*/
|
|
121
|
-
ignoreDefaultImageTemplateScale?: boolean | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* - Scale ratio for width
|
|
124
|
-
*/
|
|
125
|
-
xScale?: number | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* - Scale ratio for height
|
|
128
|
-
*/
|
|
129
|
-
yScale?: number | undefined;
|
|
130
|
-
}): Promise<Buffer>;
|
|
51
|
+
fixImageTemplateScale(template: Buffer, opts?: ImageTemplateSettings): Promise<Buffer>;
|
|
131
52
|
}
|
|
132
|
-
export type ExternalDriver = import("@appium/types").ExternalDriver;
|
|
133
|
-
export type Element = import("@appium/types").Element;
|
|
134
|
-
export type Screenshot = {
|
|
135
|
-
/**
|
|
136
|
-
* - screenshot image as PNG
|
|
137
|
-
*/
|
|
138
|
-
screenshot: Buffer;
|
|
139
|
-
};
|
|
140
|
-
export type ScreenshotScale = {
|
|
141
|
-
/**
|
|
142
|
-
* - Scale ratio for width
|
|
143
|
-
*/
|
|
144
|
-
xScale: number;
|
|
145
|
-
/**
|
|
146
|
-
* - Scale ratio for height
|
|
147
|
-
*/
|
|
148
|
-
yScale: number;
|
|
149
|
-
};
|
|
150
|
-
import { LRUCache } from 'lru-cache';
|
|
151
|
-
import { ImageElement } from './image-element';
|
|
152
53
|
//# sourceMappingURL=finder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finder.d.ts","sourceRoot":"","sources":["../../lib/finder.
|
|
1
|
+
{"version":3,"file":"finder.d.ts","sourceRoot":"","sources":["../../lib/finder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAU7C,OAAO,KAAK,EAAC,cAAc,EAAE,OAAO,EAAQ,IAAI,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAEV,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AA2BjB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,WAAW,CAAiC;gBAExC,GAAG,GAAE,MAAwB;IAQzC,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAKlD,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI1D,kBAAkB,IAAI,IAAI;IAI1B;;;;;;;;;OASG;IACG,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,EACtB,EACE,oBAA4B,EAC5B,QAAgB,EAChB,+BAAuC,EACvC,aAAoB,GACrB,GAAE,kBAAuB,GACzB,OAAO,CAAC,OAAO,GAAG,OAAO,EAAE,GAAG,YAAY,CAAC;IA8I9C;;;;;;;OAOG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B1E;;;;;;;;OAQG;IACG,yBAAyB,CAC7B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,IAAI,GACf,OAAO,CAAC,UAAU,GAAG;QAAC,KAAK,CAAC,EAAE,eAAe,CAAA;KAAC,CAAC;IA+HlD;;;;;;;;OAQG;IACG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;CAsE7F"}
|