@appium/images-plugin 4.2.7 → 5.0.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/README.md +2 -2
- package/build/lib/compare.d.ts +2 -2
- package/build/lib/compare.d.ts.map +1 -1
- package/build/lib/compare.js +13 -20
- package/build/lib/compare.js.map +1 -1
- package/build/lib/constants.d.ts +1 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +16 -22
- package/build/lib/constants.js.map +1 -1
- package/build/lib/finder.d.ts +3 -3
- package/build/lib/finder.d.ts.map +1 -1
- package/build/lib/finder.js +38 -47
- package/build/lib/finder.js.map +1 -1
- package/build/lib/image-element.d.ts +4 -5
- package/build/lib/image-element.d.ts.map +1 -1
- package/build/lib/image-element.js +26 -31
- package/build/lib/image-element.js.map +1 -1
- package/build/lib/index.d.ts +7 -7
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +6 -29
- package/build/lib/index.js.map +1 -1
- package/build/lib/logger.js +2 -5
- package/build/lib/logger.js.map +1 -1
- package/build/lib/plugin.d.ts +4 -4
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/plugin.js +23 -27
- package/build/lib/plugin.js.map +1 -1
- package/build/lib/types.d.ts +3 -3
- package/build/lib/types.d.ts.map +1 -1
- package/build/lib/types.js +1 -2
- package/lib/compare.ts +10 -13
- package/lib/constants.ts +4 -6
- package/lib/finder.ts +19 -33
- package/lib/image-element.ts +14 -32
- package/lib/index.ts +7 -7
- package/lib/logger.ts +1 -1
- package/lib/plugin.ts +16 -27
- package/lib/types.ts +4 -3
- package/package.json +31 -25
- package/tsconfig.json +14 -5
package/lib/image-element.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {errors} from 'appium/driver';
|
|
2
1
|
import {util} from '@appium/support';
|
|
3
|
-
import {
|
|
2
|
+
import type {ActionSequence, Element, ExternalDriver, Rect} from '@appium/types';
|
|
3
|
+
import {errors} from 'appium/driver.js';
|
|
4
|
+
|
|
4
5
|
import {
|
|
5
|
-
IMAGE_STRATEGY,
|
|
6
6
|
DEFAULT_SETTINGS,
|
|
7
|
-
IMAGE_TAP_STRATEGIES,
|
|
8
|
-
IMAGE_ELEMENT_PREFIX,
|
|
9
7
|
IMAGE_EL_TAP_STRATEGY_W3C,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
IMAGE_ELEMENT_PREFIX,
|
|
9
|
+
IMAGE_STRATEGY,
|
|
10
|
+
IMAGE_TAP_STRATEGIES,
|
|
11
|
+
} from './constants.js';
|
|
12
|
+
import type {ImageElementFinder} from './finder.js';
|
|
13
|
+
import {log} from './logger.js';
|
|
14
|
+
import type {Dimension, ImageElementOpts, ImageSettings, Position} from './types.js';
|
|
14
15
|
|
|
15
16
|
const TAP_DURATION_MS = 125;
|
|
16
17
|
|
|
@@ -27,14 +28,7 @@ export class ImageElement {
|
|
|
27
28
|
readonly finder: ImageElementFinder | null;
|
|
28
29
|
readonly containerRect: Rect | null;
|
|
29
30
|
|
|
30
|
-
constructor({
|
|
31
|
-
template,
|
|
32
|
-
rect,
|
|
33
|
-
score,
|
|
34
|
-
match = null,
|
|
35
|
-
finder = null,
|
|
36
|
-
containerRect = null,
|
|
37
|
-
}: ImageElementOpts) {
|
|
31
|
+
constructor({template, rect, score, match = null, finder = null, containerRect = null}: ImageElementOpts) {
|
|
38
32
|
this.template = template;
|
|
39
33
|
this.rect = rect;
|
|
40
34
|
this.id = `${IMAGE_ELEMENT_PREFIX}${util.uuidV4()}`;
|
|
@@ -92,12 +86,7 @@ export class ImageElement {
|
|
|
92
86
|
*
|
|
93
87
|
* @returns the result of running a command
|
|
94
88
|
*/
|
|
95
|
-
static async execute(
|
|
96
|
-
driver: ExternalDriver,
|
|
97
|
-
imgEl: ImageElement,
|
|
98
|
-
cmd: string,
|
|
99
|
-
...args: any[]
|
|
100
|
-
): Promise<any> {
|
|
89
|
+
static async execute(driver: ExternalDriver, imgEl: ImageElement, cmd: string, ...args: any[]): Promise<any> {
|
|
101
90
|
switch (cmd) {
|
|
102
91
|
case 'click':
|
|
103
92
|
return await imgEl.click(driver);
|
|
@@ -134,7 +123,6 @@ export class ImageElement {
|
|
|
134
123
|
}
|
|
135
124
|
|
|
136
125
|
/**
|
|
137
|
-
*
|
|
138
126
|
* @returns this image element as a WebElement
|
|
139
127
|
*/
|
|
140
128
|
asElement(): Element {
|
|
@@ -273,16 +261,10 @@ export class ImageElement {
|
|
|
273
261
|
* @param args - Rest of arguments for executeScripts
|
|
274
262
|
* @returns WebDriver element with a special id prefix
|
|
275
263
|
*/
|
|
276
|
-
async find(
|
|
277
|
-
multiple: boolean,
|
|
278
|
-
driver: ExternalDriver,
|
|
279
|
-
...args: any[]
|
|
280
|
-
): Promise<Element | Element[] | ImageElement> {
|
|
264
|
+
async find(multiple: boolean, driver: ExternalDriver, ...args: any[]): Promise<Element | Element[] | ImageElement> {
|
|
281
265
|
const [strategy, selector] = args;
|
|
282
266
|
if (strategy !== IMAGE_STRATEGY) {
|
|
283
|
-
throw new errors.InvalidSelectorError(
|
|
284
|
-
`Lookup strategies other than '${IMAGE_STRATEGY}' are not supported`,
|
|
285
|
-
);
|
|
267
|
+
throw new errors.InvalidSelectorError(`Lookup strategies other than '${IMAGE_STRATEGY}' are not supported`);
|
|
286
268
|
}
|
|
287
269
|
if (!this.finder) {
|
|
288
270
|
throw new Error('Finder is not available');
|
package/lib/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {IMAGE_STRATEGY} from './constants';
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
7
|
-
export type * from './types';
|
|
1
|
+
export {compareImages} from './compare.js';
|
|
2
|
+
export {IMAGE_STRATEGY} from './constants.js';
|
|
3
|
+
export * from './constants.js';
|
|
4
|
+
export {ImageElementFinder} from './finder.js';
|
|
5
|
+
export {ImageElement} from './image-element.js';
|
|
6
|
+
export {getImgElFromArgs, ImageElementPlugin} from './plugin.js';
|
|
7
|
+
export type * from './types.js';
|
package/lib/logger.ts
CHANGED
package/lib/plugin.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {MatchingOptions, OccurrenceOptions, SimilarityOptions} from '@appium/opencv';
|
|
2
2
|
import {util} from '@appium/support';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
3
|
+
import type {ActionSequence, Element, ExternalDriver, MethodMap} from '@appium/types';
|
|
4
|
+
import {errors} from 'appium/driver.js';
|
|
5
|
+
import {BasePlugin} from 'appium/plugin.js';
|
|
6
|
+
|
|
7
|
+
import {compareImages} from './compare.js';
|
|
8
|
+
import {IMAGE_ELEMENT_PREFIX, IMAGE_STRATEGY} from './constants.js';
|
|
9
|
+
import {ImageElementFinder} from './finder.js';
|
|
10
|
+
import {ImageElement} from './image-element.js';
|
|
10
11
|
|
|
11
12
|
export class ImageElementPlugin extends BasePlugin {
|
|
12
13
|
// this plugin supports a non-standard 'compare images' command
|
|
@@ -40,28 +41,15 @@ export class ImageElementPlugin extends BasePlugin {
|
|
|
40
41
|
return await compareImages(mode, firstImage, secondImage, options);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
async findElement(
|
|
44
|
-
next: () => Promise<any>,
|
|
45
|
-
driver: ExternalDriver,
|
|
46
|
-
...args: any[]
|
|
47
|
-
): Promise<any> {
|
|
44
|
+
async findElement(next: () => Promise<any>, driver: ExternalDriver, ...args: any[]): Promise<any> {
|
|
48
45
|
return await this._find(false, next, driver, ...args);
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
async findElements(
|
|
52
|
-
next: () => Promise<any>,
|
|
53
|
-
driver: ExternalDriver,
|
|
54
|
-
...args: any[]
|
|
55
|
-
): Promise<any> {
|
|
48
|
+
async findElements(next: () => Promise<any>, driver: ExternalDriver, ...args: any[]): Promise<any> {
|
|
56
49
|
return await this._find(true, next, driver, ...args);
|
|
57
50
|
}
|
|
58
51
|
|
|
59
|
-
async handle(
|
|
60
|
-
next: () => Promise<any>,
|
|
61
|
-
driver: ExternalDriver,
|
|
62
|
-
cmdName: string,
|
|
63
|
-
...args: any[]
|
|
64
|
-
): Promise<any> {
|
|
52
|
+
async handle(next: () => Promise<any>, driver: ExternalDriver, cmdName: string, ...args: any[]): Promise<any> {
|
|
65
53
|
// if we have a command that involves an image element id, attempt to find the image element
|
|
66
54
|
// and execute the command on it
|
|
67
55
|
const imgElId = getImgElFromArgs(args);
|
|
@@ -106,9 +94,10 @@ export class ImageElementPlugin extends BasePlugin {
|
|
|
106
94
|
throw new errors.NoSuchElementError();
|
|
107
95
|
}
|
|
108
96
|
|
|
109
|
-
// Add the element's center
|
|
110
|
-
|
|
111
|
-
actionWithEl.
|
|
97
|
+
// Add the element's center to the offset. An unset offset must count as
|
|
98
|
+
// zero, otherwise the resulting coordinate is NaN.
|
|
99
|
+
actionWithEl.x = (actionWithEl.x ?? 0) + imgEl.center.x;
|
|
100
|
+
actionWithEl.y = (actionWithEl.y ?? 0) + imgEl.center.y;
|
|
112
101
|
// Set the origin to the viewport so that the external driver can process it using coordinates.
|
|
113
102
|
delete actionWithEl.origin;
|
|
114
103
|
}
|
package/lib/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {Rect} from '@appium/types';
|
|
2
|
-
import type {ImageElementFinder} from './finder';
|
|
3
1
|
import type {MatchingResult, OccurrenceResult, SimilarityResult} from '@appium/opencv';
|
|
4
|
-
import type {
|
|
2
|
+
import type {Rect} from '@appium/types';
|
|
3
|
+
|
|
4
|
+
import type {IMAGE_EL_TAP_STRATEGY_MJSONWP, IMAGE_EL_TAP_STRATEGY_W3C} from './constants.js';
|
|
5
|
+
import type {ImageElementFinder} from './finder.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Image settings interface for device settings
|
package/package.json
CHANGED
|
@@ -1,49 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/images-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"gitHead": "b67de03966155ff052076c11c1c8f20cc2ba9134",
|
|
4
5
|
"description": "Plugin for working with images and image elements in Appium",
|
|
5
6
|
"keywords": [
|
|
7
|
+
"android",
|
|
6
8
|
"automation",
|
|
9
|
+
"firefoxos",
|
|
10
|
+
"ios",
|
|
7
11
|
"javascript",
|
|
8
12
|
"selenium",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"android",
|
|
12
|
-
"firefoxos",
|
|
13
|
-
"testing"
|
|
13
|
+
"testing",
|
|
14
|
+
"webdriver"
|
|
14
15
|
],
|
|
15
16
|
"homepage": "https://appium.io",
|
|
16
17
|
"bugs": {
|
|
17
18
|
"url": "https://github.com/appium/appium/issues"
|
|
18
19
|
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"author": "https://github.com/appium",
|
|
19
22
|
"repository": {
|
|
20
23
|
"type": "git",
|
|
21
24
|
"url": "https://github.com/appium/appium.git",
|
|
22
25
|
"directory": "packages/images-plugin"
|
|
23
26
|
},
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"author": "https://github.com/appium",
|
|
26
|
-
"main": "./build/lib/index.js",
|
|
27
|
-
"types": "./build/lib/index.d.ts",
|
|
28
27
|
"files": [
|
|
29
|
-
"build",
|
|
28
|
+
"build/lib",
|
|
30
29
|
"docs",
|
|
31
30
|
"lib",
|
|
32
|
-
"tsconfig.json"
|
|
33
|
-
"!build/tsconfig.tsbuildinfo",
|
|
34
|
-
"!build/test"
|
|
31
|
+
"tsconfig.json"
|
|
35
32
|
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"main": "./build/lib/index.js",
|
|
35
|
+
"types": "./build/lib/index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./build/lib/index.d.ts",
|
|
39
|
+
"import": "./build/lib/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
36
46
|
"scripts": {
|
|
37
47
|
"test": "npm run test:unit",
|
|
38
48
|
"test:smoke": "node ./build/lib/index.js",
|
|
39
|
-
"test:unit": "
|
|
40
|
-
"test:e2e": "
|
|
49
|
+
"test:unit": "node --test --experimental-test-module-mocks --enable-source-maps --test-timeout=5000 \"./build/test/unit/**/*.spec.js\"",
|
|
50
|
+
"test:e2e": "node --test --enable-source-maps --test-force-exit --test-concurrency=1 --test-timeout=20000 \"./build/test/e2e/**/*.spec.js\""
|
|
41
51
|
},
|
|
42
52
|
"dependencies": {
|
|
43
|
-
"@appium/opencv": "
|
|
44
|
-
"@appium/support": "7.2.
|
|
45
|
-
"lru-cache": "11.5.
|
|
46
|
-
"sharp": "0.35.
|
|
53
|
+
"@appium/opencv": "5.0.0",
|
|
54
|
+
"@appium/support": "7.2.7",
|
|
55
|
+
"lru-cache": "11.5.2",
|
|
56
|
+
"sharp": "0.35.3"
|
|
47
57
|
},
|
|
48
58
|
"peerDependencies": {
|
|
49
59
|
"appium": "^3.0.0-beta.0"
|
|
@@ -55,9 +65,5 @@
|
|
|
55
65
|
"appium": {
|
|
56
66
|
"pluginName": "images",
|
|
57
67
|
"mainClass": "ImageElementPlugin"
|
|
58
|
-
}
|
|
59
|
-
"publishConfig": {
|
|
60
|
-
"access": "public"
|
|
61
|
-
},
|
|
62
|
-
"gitHead": "e6b583a2094f7919ef27b0dc28ebf42b3184852b"
|
|
68
|
+
}
|
|
63
69
|
}
|
package/tsconfig.json
CHANGED
|
@@ -5,16 +5,25 @@
|
|
|
5
5
|
"checkJs": true,
|
|
6
6
|
"esModuleInterop": true,
|
|
7
7
|
"strict": true,
|
|
8
|
+
"module": "NodeNext",
|
|
9
|
+
"moduleResolution": "NodeNext",
|
|
8
10
|
"paths": {
|
|
9
|
-
"@appium/opencv": ["../opencv"]
|
|
11
|
+
"@appium/opencv": ["../opencv"],
|
|
12
|
+
"appium": ["../appium"],
|
|
13
|
+
"appium/driver.js": ["../appium/driver.d.ts"],
|
|
14
|
+
"appium/plugin.js": ["../appium/plugin.d.ts"],
|
|
15
|
+
"appium/support.js": ["../appium/support.d.ts"]
|
|
10
16
|
},
|
|
11
|
-
"types": ["
|
|
17
|
+
"types": ["node"]
|
|
12
18
|
},
|
|
13
19
|
"extends": "@appium/tsconfig/tsconfig.plugin.json",
|
|
14
20
|
"include": ["lib", "test"],
|
|
15
21
|
"references": [
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
}
|
|
22
|
+
{"path": "../opencv"},
|
|
23
|
+
{"path": "../base-plugin"},
|
|
24
|
+
{"path": "../logger"},
|
|
25
|
+
{"path": "../support"},
|
|
26
|
+
{"path": "../types"},
|
|
27
|
+
{"path": "../plugin-test-support"}
|
|
19
28
|
]
|
|
20
29
|
}
|