@appium/images-plugin 3.0.29 → 3.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/plugin.d.ts +1 -0
- package/build/lib/plugin.d.ts.map +1 -1
- package/build/lib/plugin.js +30 -0
- package/build/lib/plugin.js.map +1 -1
- package/lib/plugin.js +43 -2
- package/package.json +5 -5
package/build/lib/plugin.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export default class ImageElementPlugin extends BasePlugin {
|
|
|
26
26
|
*/
|
|
27
27
|
_find(multiple: boolean, next: any, driver: any, ...args: any[]): Promise<any>;
|
|
28
28
|
handle(next: any, driver: any, cmdName: any, ...args: any[]): Promise<any>;
|
|
29
|
+
performActions(next: any, driver: any, ...args: any[]): Promise<any>;
|
|
29
30
|
}
|
|
30
31
|
import { BasePlugin } from 'appium/plugin';
|
|
31
32
|
import ImageElementFinder from './finder';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":"AAaA;IAOE;;;;;;;;;;;MAWG;IAjBH,6BAGC;IADC,2BAAsC;IAiBxC,qGAGC;IAED,kEAEC;IAED,mEAEC;IAED;;;;;;;OAOG;IACH,gBANW,OAAO,QACP,GAAC,UACD,GAAC,WACG,GAAG,EAAA,GACL,OAAO,CAAC,GAAG,CAAC,CAWxB;IAED,2EAkBC;IAED,qEAwCC;CACF;2BA3HwB,eAAe;+BAET,UAAU;AAIzC,iDAEC;+BAJkD,aAAa"}
|
package/build/lib/plugin.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.IMAGE_STRATEGY = 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
|
+
const support_1 = require("@appium/support");
|
|
10
11
|
const plugin_1 = require("appium/plugin");
|
|
11
12
|
const compare_1 = require("./compare");
|
|
12
13
|
const finder_1 = __importDefault(require("./finder"));
|
|
@@ -64,6 +65,35 @@ class ImageElementPlugin extends plugin_1.BasePlugin {
|
|
|
64
65
|
// otherwise just do the normal thing
|
|
65
66
|
return await next();
|
|
66
67
|
}
|
|
68
|
+
async performActions(next, driver, ...args) {
|
|
69
|
+
// Replace with coordinates when ActionSequence includes image elements.
|
|
70
|
+
const [actionSequences] = /** @type {[import('@appium/types').ActionSequence[]]} */ (args);
|
|
71
|
+
for (const actionSequence of actionSequences) {
|
|
72
|
+
for (const action of actionSequence.actions) {
|
|
73
|
+
// The actions that can have an Element as the origin are "pointerMove" and "scroll".
|
|
74
|
+
if (!lodash_1.default.isPlainObject(
|
|
75
|
+
/** @type {{origin?: "viewport" | "pointer" | import('@appium/types').Element}} */ (action).origin)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const actionWithEl =
|
|
79
|
+
/** @type {import('@appium/types').PointerMoveAction | import('@appium/types').ScrollAction} */ (action);
|
|
80
|
+
const elId = support_1.util.unwrapElement(/** @type {import('@appium/types').Element} */ (actionWithEl.origin));
|
|
81
|
+
if (!lodash_1.default.startsWith(elId, constants_1.IMAGE_ELEMENT_PREFIX)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const imgEl = this.finder.getImageElement(elId);
|
|
85
|
+
if (!imgEl) {
|
|
86
|
+
throw new driver_1.errors.NoSuchElementError();
|
|
87
|
+
}
|
|
88
|
+
// Add the element's center coordinates to the offset value.
|
|
89
|
+
actionWithEl.x += imgEl.center.x;
|
|
90
|
+
actionWithEl.y += imgEl.center.y;
|
|
91
|
+
// Set the origin to the viewport so that the external driver can process it using coordinates.
|
|
92
|
+
delete actionWithEl.origin;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return await next();
|
|
96
|
+
}
|
|
67
97
|
}
|
|
68
98
|
exports.ImageElementPlugin = ImageElementPlugin;
|
|
69
99
|
// this plugin supports a non-standard 'compare images' command
|
package/build/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":";;;;;;AAgI4B,4CAAgB;AAhI5C,oDAAuB;AACvB,0CAAqC;AACrC,6CAAqC;AACrC,0CAAyC;AACzC,uCAAwC;AACxC,sDAA0C;AAC1C,mDAA6C;AAC7C,2CAAiE;AAyHnB,+FAzHtC,0BAAc,OAyHsC;AAvH5D,SAAS,gBAAgB,CAAC,IAAI;IAC5B,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,MAAqB,kBAAmB,SAAQ,mBAAU;IACxD,YAAY,UAAU;QACpB,KAAK,CAAC,UAAU,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAkB,EAAE,CAAC;IACzC,CAAC;IAgBD,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;QACvC,0CAA0C;QAC1C,OAAO,MAAM,IAAA,uBAAa,EAAC,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;QACrC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE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YACJ,OAAO,EAAE,eAAe;YACxB,aAAa,EAAE;gBACb,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC;gBAC/C,QAAQ,EAAE,CAAC,SAAS,CAAC;aACtB;YACD,UAAU,EAAE,IAAI;SACjB;KACF;CACF,CAAC,CAAC;kBAlBgB,kBAAkB"}
|
package/lib/plugin.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import _ from 'lodash';
|
|
4
2
|
import {errors} from 'appium/driver';
|
|
3
|
+
import {util} from '@appium/support';
|
|
5
4
|
import {BasePlugin} from 'appium/plugin';
|
|
6
5
|
import {compareImages} from './compare';
|
|
7
6
|
import ImageElementFinder from './finder';
|
|
@@ -83,6 +82,48 @@ export default class ImageElementPlugin extends BasePlugin {
|
|
|
83
82
|
// otherwise just do the normal thing
|
|
84
83
|
return await next();
|
|
85
84
|
}
|
|
85
|
+
|
|
86
|
+
async performActions(next, driver, ...args) {
|
|
87
|
+
// Replace with coordinates when ActionSequence includes image elements.
|
|
88
|
+
const [actionSequences] = /** @type {[import('@appium/types').ActionSequence[]]} */ (args);
|
|
89
|
+
for (const actionSequence of actionSequences) {
|
|
90
|
+
for (const action of actionSequence.actions) {
|
|
91
|
+
// The actions that can have an Element as the origin are "pointerMove" and "scroll".
|
|
92
|
+
if (
|
|
93
|
+
!_.isPlainObject(
|
|
94
|
+
/** @type {{origin?: "viewport" | "pointer" | import('@appium/types').Element}} */ (
|
|
95
|
+
action
|
|
96
|
+
).origin,
|
|
97
|
+
)
|
|
98
|
+
) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const actionWithEl =
|
|
103
|
+
/** @type {import('@appium/types').PointerMoveAction | import('@appium/types').ScrollAction} */ (
|
|
104
|
+
action
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const elId = util.unwrapElement(/** @type {import('@appium/types').Element} */ (actionWithEl.origin));
|
|
108
|
+
if (!_.startsWith(elId, IMAGE_ELEMENT_PREFIX)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const imgEl = this.finder.getImageElement(elId);
|
|
113
|
+
if (!imgEl) {
|
|
114
|
+
throw new errors.NoSuchElementError();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Add the element's center coordinates to the offset value.
|
|
118
|
+
actionWithEl.x += imgEl.center.x;
|
|
119
|
+
actionWithEl.y += imgEl.center.y;
|
|
120
|
+
// Set the origin to the viewport so that the external driver can process it using coordinates.
|
|
121
|
+
delete actionWithEl.origin;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return await next();
|
|
126
|
+
}
|
|
86
127
|
}
|
|
87
128
|
|
|
88
129
|
export {ImageElementPlugin, getImgElFromArgs, IMAGE_STRATEGY};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/images-plugin",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Plugin for working with images and image elements in Appium",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "npm run test:unit",
|
|
37
|
-
"test:e2e": "mocha --timeout 40s --slow 20s \"./test/e2e/**/*.spec
|
|
37
|
+
"test:e2e": "mocha --timeout 40s --slow 20s \"./test/e2e/**/*.spec.*js\"",
|
|
38
38
|
"test:smoke": "node ./index.js",
|
|
39
|
-
"test:unit": "mocha \"./test/unit/**/*.spec
|
|
39
|
+
"test:unit": "mocha \"./test/unit/**/*.spec.*js\""
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@appium/opencv": "^3.0.8",
|
|
43
|
-
"@appium/support": "^6.0.
|
|
43
|
+
"@appium/support": "^6.0.7",
|
|
44
44
|
"lodash": "4.17.21",
|
|
45
45
|
"lru-cache": "10.4.3",
|
|
46
46
|
"sharp": "0.33.5",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "7c05f5c213e284b6be0f1ecf5550a40d84e0899e"
|
|
64
64
|
}
|