@applitools/driver 1.11.28 → 1.11.30
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/dist/context.js +6 -7
- package/dist/driver.js +48 -53
- package/dist/element.js +21 -17
- package/package.json +2 -2
- package/types/context.d.ts +33 -33
- package/types/debug/check-spec-driver.d.ts +4 -4
- package/types/driver.d.ts +26 -28
- package/types/element.d.ts +26 -26
- package/types/helper-android.d.ts +14 -14
- package/types/helper-ios.d.ts +11 -11
- package/types/selector.d.ts +8 -7
- package/types/spec-driver.d.ts +67 -61
- package/types/spec-utils.d.ts +10 -12
package/dist/context.js
CHANGED
|
@@ -30,8 +30,7 @@ const specUtils = __importStar(require("./spec-utils"));
|
|
|
30
30
|
const snippets = require('@applitools/snippets');
|
|
31
31
|
class Context {
|
|
32
32
|
_isReference(reference) {
|
|
33
|
-
return (reference
|
|
34
|
-
utils.types.isInteger(reference) ||
|
|
33
|
+
return (utils.types.isInteger(reference) ||
|
|
35
34
|
utils.types.isString(reference) ||
|
|
36
35
|
reference instanceof element_1.Element ||
|
|
37
36
|
this._spec.isElement(reference) ||
|
|
@@ -47,14 +46,12 @@ class Context {
|
|
|
47
46
|
this._target = options.context;
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
|
-
throw new TypeError('Context constructor called with
|
|
49
|
+
throw new TypeError('Context constructor called with target context of unknown type');
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
if (this._isReference(options.reference)) {
|
|
54
|
-
if (options.reference instanceof Context)
|
|
55
|
-
return options.reference;
|
|
56
53
|
if (!options.parent) {
|
|
57
|
-
throw new TypeError('Cannot construct child context without
|
|
54
|
+
throw new TypeError('Cannot construct child context without parent context');
|
|
58
55
|
}
|
|
59
56
|
this._reference = options.reference;
|
|
60
57
|
this._parent = options.parent;
|
|
@@ -66,7 +63,7 @@ class Context {
|
|
|
66
63
|
this._driver = options.driver;
|
|
67
64
|
}
|
|
68
65
|
else {
|
|
69
|
-
throw new TypeError('Context constructor called with
|
|
66
|
+
throw new TypeError('Context constructor called with context reference of unknown type!');
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
get target() {
|
|
@@ -250,6 +247,8 @@ class Context {
|
|
|
250
247
|
return new Context({ spec: this._spec, parent: this, driver: this.driver, reference, logger: this._logger });
|
|
251
248
|
}
|
|
252
249
|
else if (utils.types.has(reference, 'reference')) {
|
|
250
|
+
if (reference.reference instanceof Context)
|
|
251
|
+
return this;
|
|
253
252
|
const parent = reference.parent ? await this.context(reference.parent) : this;
|
|
254
253
|
return new Context({
|
|
255
254
|
spec: this._spec,
|
package/dist/driver.js
CHANGED
|
@@ -64,9 +64,6 @@ class Driver {
|
|
|
64
64
|
get mainContext() {
|
|
65
65
|
return this._mainContext;
|
|
66
66
|
}
|
|
67
|
-
get helper() {
|
|
68
|
-
return this._helper;
|
|
69
|
-
}
|
|
70
67
|
get features() {
|
|
71
68
|
var _a;
|
|
72
69
|
return (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.features;
|
|
@@ -179,8 +176,8 @@ class Driver {
|
|
|
179
176
|
this._currentContext = context;
|
|
180
177
|
}
|
|
181
178
|
async init() {
|
|
182
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18
|
|
183
|
-
var _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33
|
|
179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
180
|
+
var _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
|
|
184
181
|
// NOTE: this is here because saucelabs does not provide right capabilities for the first call
|
|
185
182
|
await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
|
|
186
183
|
const capabilities = await ((_d = (_c = this._spec).getCapabilities) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
|
|
@@ -188,7 +185,7 @@ class Driver {
|
|
|
188
185
|
const capabilitiesInfo = capabilities ? (0, capabilities_1.parseCapabilities)(capabilities) : undefined;
|
|
189
186
|
const driverInfo = await ((_f = (_e = this._spec).getDriverInfo) === null || _f === void 0 ? void 0 : _f.call(_e, this.target));
|
|
190
187
|
this._driverInfo = { ...capabilitiesInfo, ...driverInfo };
|
|
191
|
-
(_g = (
|
|
188
|
+
(_g = (_19 = this._driverInfo).remoteHostname) !== null && _g !== void 0 ? _g : (_19.remoteHostname = (_k = (_j = (_h = this._spec).extractHostName) === null || _j === void 0 ? void 0 : _j.call(_h, this.target)) !== null && _k !== void 0 ? _k : undefined);
|
|
192
189
|
if (this.isMobile) {
|
|
193
190
|
this._driverInfo.orientation =
|
|
194
191
|
(_l = (await this.getOrientation().catch(() => undefined))) !== null && _l !== void 0 ? _l : this._driverInfo.orientation;
|
|
@@ -197,54 +194,50 @@ class Driver {
|
|
|
197
194
|
}
|
|
198
195
|
if (this.isWeb) {
|
|
199
196
|
const browserInfo = await this.currentContext.executePoll(snippets.getBrowserInfo);
|
|
200
|
-
(_m = (
|
|
201
|
-
(_o = (
|
|
202
|
-
(_p = (
|
|
203
|
-
if (browserInfo.userAgentData) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
else if (this.isMac && Number.parseInt(this.browserVersion) >= 90) {
|
|
211
|
-
this._driverInfo.platformVersion = (_t = browserInfo.platformVersion) !== null && _t !== void 0 ? _t : this._driverInfo.platformVersion;
|
|
212
|
-
}
|
|
197
|
+
(_m = (_20 = this._driverInfo).userAgent) !== null && _m !== void 0 ? _m : (_20.userAgent = browserInfo.userAgent);
|
|
198
|
+
(_o = (_21 = this._driverInfo).pixelRatio) !== null && _o !== void 0 ? _o : (_21.pixelRatio = browserInfo.pixelRatio);
|
|
199
|
+
(_p = (_22 = this._driverInfo).viewportScale) !== null && _p !== void 0 ? _p : (_22.viewportScale = browserInfo.viewportScale);
|
|
200
|
+
if (browserInfo.userAgentData && this.isChromium) {
|
|
201
|
+
if (this.isWindows && Number.parseInt(this.browserVersion) >= 107) {
|
|
202
|
+
this._driverInfo.platformVersion = (_q = browserInfo.platformVersion) !== null && _q !== void 0 ? _q : this._driverInfo.platformVersion;
|
|
203
|
+
}
|
|
204
|
+
else if (this.isMac && Number.parseInt(this.browserVersion) >= 90) {
|
|
205
|
+
this._driverInfo.platformVersion = (_r = browserInfo.platformVersion) !== null && _r !== void 0 ? _r : this._driverInfo.platformVersion;
|
|
213
206
|
}
|
|
214
207
|
}
|
|
215
208
|
if (this._driverInfo.userAgent) {
|
|
216
209
|
const userAgentInfo = (0, user_agent_1.parseUserAgent)(this._driverInfo.userAgent);
|
|
217
210
|
const userAgentDataInfo = browserInfo.userAgentData && (0, user_agent_data_1.parseUserAgentData)(browserInfo.userAgentData);
|
|
218
211
|
this._driverInfo.browserName =
|
|
219
|
-
(
|
|
212
|
+
(_t = (_s = userAgentInfo.browserName) !== null && _s !== void 0 ? _s : userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.browserName) !== null && _t !== void 0 ? _t : this._driverInfo.browserName;
|
|
220
213
|
this._driverInfo.browserVersion =
|
|
221
|
-
(
|
|
222
|
-
(
|
|
223
|
-
(
|
|
214
|
+
(_v = (_u = userAgentInfo.browserVersion) !== null && _u !== void 0 ? _u : userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.browserVersion) !== null && _v !== void 0 ? _v : this._driverInfo.browserVersion;
|
|
215
|
+
(_w = (_23 = this._driverInfo).isMobile) !== null && _w !== void 0 ? _w : (_23.isMobile = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.isMobile);
|
|
216
|
+
(_x = (_24 = this._driverInfo).isChromium) !== null && _x !== void 0 ? _x : (_24.isChromium = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.isChromium);
|
|
224
217
|
if (this._driverInfo.isMobile) {
|
|
225
|
-
(
|
|
226
|
-
(
|
|
218
|
+
(_y = (_25 = this._driverInfo).platformName) !== null && _y !== void 0 ? _y : (_25.platformName = (_z = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformName) !== null && _z !== void 0 ? _z : userAgentInfo.platformName);
|
|
219
|
+
(_0 = (_26 = this._driverInfo).platformVersion) !== null && _0 !== void 0 ? _0 : (_26.platformVersion = (_1 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformVersion) !== null && _1 !== void 0 ? _1 : userAgentInfo.platformVersion);
|
|
227
220
|
}
|
|
228
221
|
else {
|
|
229
222
|
this._driverInfo.platformName =
|
|
230
|
-
(
|
|
223
|
+
(_3 = (_2 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformName) !== null && _2 !== void 0 ? _2 : userAgentInfo.platformName) !== null && _3 !== void 0 ? _3 : this._driverInfo.platformName;
|
|
231
224
|
this._driverInfo.platformVersion =
|
|
232
|
-
(
|
|
225
|
+
(_5 = (_4 = userAgentDataInfo === null || userAgentDataInfo === void 0 ? void 0 : userAgentDataInfo.platformVersion) !== null && _4 !== void 0 ? _4 : userAgentInfo.platformVersion) !== null && _5 !== void 0 ? _5 : this._driverInfo.platformVersion;
|
|
233
226
|
}
|
|
234
227
|
}
|
|
235
228
|
if (!this.isMobile && (this.isAndroid || this.isIOS)) {
|
|
236
229
|
this._driverInfo.isMobile = true;
|
|
237
230
|
this._driverInfo.isEmulation = this._driverInfo.isChrome;
|
|
238
231
|
}
|
|
239
|
-
(
|
|
240
|
-
(
|
|
232
|
+
(_6 = (_27 = this._driverInfo).features) !== null && _6 !== void 0 ? _6 : (_27.features = {});
|
|
233
|
+
(_7 = (_28 = this._driverInfo.features).allCookies) !== null && _7 !== void 0 ? _7 : (_28.allCookies = this._driverInfo.isChrome ||
|
|
241
234
|
(!!this._driverInfo.browserName && /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile));
|
|
242
235
|
}
|
|
243
236
|
else {
|
|
244
237
|
// this value always excludes the height of the navigation bar, and sometimes it also excludes the height of the status bar
|
|
245
238
|
let windowSize = await this._spec.getWindowSize(this.target);
|
|
246
|
-
(
|
|
247
|
-
if (((
|
|
239
|
+
(_8 = (_29 = this._driverInfo).displaySize) !== null && _8 !== void 0 ? _8 : (_29.displaySize = windowSize);
|
|
240
|
+
if (((_9 = this.orientation) === null || _9 === void 0 ? void 0 : _9.startsWith('landscape')) &&
|
|
248
241
|
this._driverInfo.displaySize.height > this._driverInfo.displaySize.width) {
|
|
249
242
|
this._driverInfo.displaySize = {
|
|
250
243
|
width: this._driverInfo.displaySize.height,
|
|
@@ -253,14 +246,14 @@ class Driver {
|
|
|
253
246
|
}
|
|
254
247
|
if (this.isAndroid) {
|
|
255
248
|
// bar sizes could be extracted only on android
|
|
256
|
-
const systemBars = await ((
|
|
249
|
+
const systemBars = await ((_11 = (_10 = this._spec).getSystemBars) === null || _11 === void 0 ? void 0 : _11.call(_10, this.target).catch(() => null));
|
|
257
250
|
const { statusBar, navigationBar } = systemBars !== null && systemBars !== void 0 ? systemBars : {};
|
|
258
251
|
if (statusBar === null || statusBar === void 0 ? void 0 : statusBar.visible) {
|
|
259
252
|
this._logger.log('Driver status bar', statusBar);
|
|
260
253
|
const statusBarSize = statusBar.height;
|
|
261
254
|
// when status bar is overlapping content on android it returns status bar height equal to display height
|
|
262
255
|
if (statusBarSize < this._driverInfo.displaySize.height) {
|
|
263
|
-
this._driverInfo.statusBarSize = Math.max((
|
|
256
|
+
this._driverInfo.statusBarSize = Math.max((_12 = this._driverInfo.statusBarSize) !== null && _12 !== void 0 ? _12 : 0, statusBarSize);
|
|
264
257
|
}
|
|
265
258
|
}
|
|
266
259
|
if (navigationBar === null || navigationBar === void 0 ? void 0 : navigationBar.visible) {
|
|
@@ -269,28 +262,28 @@ class Driver {
|
|
|
269
262
|
if (navigationBar.x > 0)
|
|
270
263
|
this._driverInfo.orientation = 'landscape-secondary';
|
|
271
264
|
// navigation bar size could be its height or width depending on screen orientation
|
|
272
|
-
const navigationBarSize = navigationBar[((
|
|
265
|
+
const navigationBarSize = navigationBar[((_13 = this.orientation) === null || _13 === void 0 ? void 0 : _13.startsWith('landscape')) ? 'width' : 'height'];
|
|
273
266
|
// when navigation bar is invisible on android it returns navigation bar size equal to display size
|
|
274
267
|
if (navigationBarSize <
|
|
275
|
-
this._driverInfo.displaySize[((
|
|
276
|
-
this._driverInfo.navigationBarSize = Math.max((
|
|
268
|
+
this._driverInfo.displaySize[((_14 = this.orientation) === null || _14 === void 0 ? void 0 : _14.startsWith('landscape')) ? 'width' : 'height']) {
|
|
269
|
+
this._driverInfo.navigationBarSize = Math.max((_15 = this._driverInfo.navigationBarSize) !== null && _15 !== void 0 ? _15 : 0, navigationBarSize);
|
|
277
270
|
}
|
|
278
271
|
else {
|
|
279
272
|
this._driverInfo.navigationBarSize = 0;
|
|
280
273
|
}
|
|
281
274
|
}
|
|
282
275
|
// bar sizes have to be scaled on android
|
|
283
|
-
(
|
|
284
|
-
(
|
|
276
|
+
(_30 = this._driverInfo).statusBarSize && (_30.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio);
|
|
277
|
+
(_31 = this._driverInfo).navigationBarSize && (_31.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio);
|
|
285
278
|
windowSize = utils.geometry.scale(windowSize, 1 / this.pixelRatio);
|
|
286
|
-
(
|
|
279
|
+
(_32 = this._driverInfo).displaySize && (_32.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
|
|
287
280
|
}
|
|
288
281
|
if (this.isIOS) {
|
|
289
|
-
if ((
|
|
282
|
+
if ((_16 = this.orientation) === null || _16 === void 0 ? void 0 : _16.startsWith('landscape'))
|
|
290
283
|
this._driverInfo.statusBarSize = 0;
|
|
291
284
|
}
|
|
292
285
|
// calculate viewport location
|
|
293
|
-
(
|
|
286
|
+
(_17 = (_33 = this._driverInfo).viewportLocation) !== null && _17 !== void 0 ? _17 : (_33.viewportLocation = {
|
|
294
287
|
x: this.orientation === 'landscape' ? this.navigationBarSize : 0,
|
|
295
288
|
y: this.statusBarSize,
|
|
296
289
|
});
|
|
@@ -299,7 +292,7 @@ class Driver {
|
|
|
299
292
|
this._driverInfo.viewportSize = { ...this._driverInfo.displaySize };
|
|
300
293
|
this._driverInfo.viewportSize.height -= this.statusBarSize;
|
|
301
294
|
if (this.isAndroid) {
|
|
302
|
-
this._driverInfo.viewportSize[((
|
|
295
|
+
this._driverInfo.viewportSize[((_18 = this.orientation) === null || _18 === void 0 ? void 0 : _18.startsWith('landscape')) ? 'width' : 'height'] -=
|
|
303
296
|
this.navigationBarSize;
|
|
304
297
|
}
|
|
305
298
|
}
|
|
@@ -326,18 +319,22 @@ class Driver {
|
|
|
326
319
|
this._driverInfo.safeArea.height -= bottomOffset;
|
|
327
320
|
}
|
|
328
321
|
}
|
|
329
|
-
// TODO: if user opts into NML, skip initializing the helpers
|
|
330
|
-
// init helper lib
|
|
331
|
-
if (!((_21 = this._customConfig) === null || _21 === void 0 ? void 0 : _21.disableHelper)) {
|
|
332
|
-
this._helper = this.isIOS
|
|
333
|
-
? await helper_ios_1.HelperIOS.make({ spec: this._spec, driver: this, logger: this._logger })
|
|
334
|
-
: await helper_android_1.HelperAndroid.make({ spec: this._spec, driver: this, logger: this._logger });
|
|
335
|
-
}
|
|
336
|
-
this._logger.log(`Helper set to ${(_22 = this._helper) === null || _22 === void 0 ? void 0 : _22.name}`);
|
|
337
322
|
}
|
|
338
323
|
this._logger.log('Combined driver info', this._driverInfo);
|
|
339
324
|
return this;
|
|
340
325
|
}
|
|
326
|
+
async getHelper() {
|
|
327
|
+
var _a, _b, _c;
|
|
328
|
+
if (this._helper === undefined) {
|
|
329
|
+
this._logger.log(`Extracting helper for ${this.isIOS ? 'ios' : 'android'}`);
|
|
330
|
+
this._helper = this.isIOS
|
|
331
|
+
? await helper_ios_1.HelperIOS.make({ spec: this._spec, driver: this, logger: this._logger })
|
|
332
|
+
: await helper_android_1.HelperAndroid.make({ spec: this._spec, driver: this, logger: this._logger });
|
|
333
|
+
this._logger.log(`Extracted helper of type ${(_a = this._helper) === null || _a === void 0 ? void 0 : _a.name}`);
|
|
334
|
+
}
|
|
335
|
+
this._logger.log(`Returning helper for of type ${(_c = (_b = this._helper) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : null}`);
|
|
336
|
+
return this._helper;
|
|
337
|
+
}
|
|
341
338
|
// begin world
|
|
342
339
|
//
|
|
343
340
|
// About the concept of a "World":
|
|
@@ -797,9 +794,7 @@ function isDriver(driver, spec) {
|
|
|
797
794
|
}
|
|
798
795
|
exports.isDriver = isDriver;
|
|
799
796
|
async function makeDriver(options) {
|
|
800
|
-
const driver = options.driver instanceof Driver
|
|
801
|
-
? options.driver
|
|
802
|
-
: new Driver(options);
|
|
797
|
+
const driver = options.driver instanceof Driver ? options.driver : new Driver(options);
|
|
803
798
|
await driver.init();
|
|
804
799
|
await driver.refreshContexts();
|
|
805
800
|
return driver;
|
package/dist/element.js
CHANGED
|
@@ -173,11 +173,12 @@ class Element {
|
|
|
173
173
|
return region;
|
|
174
174
|
}
|
|
175
175
|
async getContentRegion(options = {}) {
|
|
176
|
-
var _a, _b
|
|
176
|
+
var _a, _b;
|
|
177
177
|
if (!this.driver.isNative)
|
|
178
178
|
return null;
|
|
179
179
|
this._logger.log('Extracting content region of native element with selector', this.selector);
|
|
180
|
-
|
|
180
|
+
const helper = await this.driver.getHelper();
|
|
181
|
+
let contentRegion = await (helper === null || helper === void 0 ? void 0 : helper.getContentRegion(this, options));
|
|
181
182
|
this._logger.log('Extracted content region using helper library', contentRegion);
|
|
182
183
|
if (!contentRegion || !this.driver.isAndroid) {
|
|
183
184
|
let attrContentRegion = null;
|
|
@@ -224,8 +225,8 @@ class Element {
|
|
|
224
225
|
contentRegion = {
|
|
225
226
|
x: attrContentRegion.x,
|
|
226
227
|
y: attrContentRegion.y,
|
|
227
|
-
width: Math.max((
|
|
228
|
-
height: Math.max((
|
|
228
|
+
width: Math.max((_a = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.width) !== null && _a !== void 0 ? _a : 0, attrContentRegion.width),
|
|
229
|
+
height: Math.max((_b = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.height) !== null && _b !== void 0 ? _b : 0, attrContentRegion.height),
|
|
229
230
|
};
|
|
230
231
|
}
|
|
231
232
|
}
|
|
@@ -312,16 +313,17 @@ class Element {
|
|
|
312
313
|
return this._spec.executeScript(this.context.target, snippets.getShadowRoot, [this.target]);
|
|
313
314
|
}
|
|
314
315
|
async getTouchPadding() {
|
|
315
|
-
var _a
|
|
316
|
-
var
|
|
316
|
+
var _a;
|
|
317
|
+
var _b;
|
|
317
318
|
if (this._state.touchPadding == null) {
|
|
318
319
|
if (this.driver.isWeb)
|
|
319
320
|
this._state.touchPadding = 0;
|
|
320
321
|
else if (this.driver.isIOS)
|
|
321
322
|
this._state.touchPadding = 10;
|
|
322
323
|
else if (this.driver.isAndroid) {
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
const helper = await this.driver.getHelper();
|
|
325
|
+
if ((helper === null || helper === void 0 ? void 0 : helper.name) === 'android') {
|
|
326
|
+
this._state.touchPadding = await helper.getTouchPadding();
|
|
325
327
|
this._logger.log('Touch padding extracted using helper library', this._state.touchPadding);
|
|
326
328
|
}
|
|
327
329
|
if (!this._state.touchPadding) {
|
|
@@ -332,7 +334,7 @@ class Element {
|
|
|
332
334
|
});
|
|
333
335
|
this._logger.log('Touch padding extracted using attribute', this._state.touchPadding);
|
|
334
336
|
}
|
|
335
|
-
(
|
|
337
|
+
(_a = (_b = this._state).touchPadding) !== null && _a !== void 0 ? _a : (_b.touchPadding = 20);
|
|
336
338
|
this._logger.log('Touch padding set:', this._state.touchPadding);
|
|
337
339
|
}
|
|
338
340
|
}
|
|
@@ -398,7 +400,6 @@ class Element {
|
|
|
398
400
|
}
|
|
399
401
|
async scrollTo(offset, options) {
|
|
400
402
|
return this.withRefresh(async () => {
|
|
401
|
-
var _a;
|
|
402
403
|
this._logger.log(`Scrolling to offset (${offset.x}, ${offset.y}) element with selector`, this.selector);
|
|
403
404
|
offset = utils.geometry.round({ x: Math.max(offset.x, 0), y: Math.max(offset.y, 0) });
|
|
404
405
|
if (this.driver.isWeb) {
|
|
@@ -412,10 +413,13 @@ class Element {
|
|
|
412
413
|
const currentScrollOffset = await this.getScrollOffset();
|
|
413
414
|
if (!(options === null || options === void 0 ? void 0 : options.force) && utils.geometry.equals(offset, currentScrollOffset))
|
|
414
415
|
return currentScrollOffset;
|
|
415
|
-
if (
|
|
416
|
-
await this.driver.
|
|
417
|
-
|
|
418
|
-
|
|
416
|
+
if (utils.geometry.equals(offset, { x: 0, y: 0 }) && this.driver.isAndroid) {
|
|
417
|
+
const helper = await this.driver.getHelper();
|
|
418
|
+
if ((helper === null || helper === void 0 ? void 0 : helper.name) === 'android') {
|
|
419
|
+
await helper.scrollToTop(this);
|
|
420
|
+
this._state.scrollOffset = offset;
|
|
421
|
+
return this._state.scrollOffset;
|
|
422
|
+
}
|
|
419
423
|
}
|
|
420
424
|
const contentSize = await this.getContentSize();
|
|
421
425
|
const scrollableRegion = await this.getClientRegion();
|
|
@@ -649,9 +653,9 @@ class Element {
|
|
|
649
653
|
this._originalOverflow = null;
|
|
650
654
|
});
|
|
651
655
|
}
|
|
652
|
-
async refresh(
|
|
653
|
-
if (this._spec.isElement(
|
|
654
|
-
this._target =
|
|
656
|
+
async refresh(freshTarget) {
|
|
657
|
+
if (this._spec.isElement(freshTarget)) {
|
|
658
|
+
this._target = freshTarget;
|
|
655
659
|
return true;
|
|
656
660
|
}
|
|
657
661
|
if (!this._selector)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.30",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"semver": "7.3.7"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@applitools/bongo": "^2.2.
|
|
91
|
+
"@applitools/bongo": "^2.2.5",
|
|
92
92
|
"@types/mocha": "^9.1.1",
|
|
93
93
|
"@types/node": "12",
|
|
94
94
|
"mocha": "^10.0.0"
|
package/types/context.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import type { Location, Size, Region } from '@applitools/utils';
|
|
2
2
|
import type { Cookie } from './types';
|
|
3
|
-
import { type SpecDriver, type WaitOptions } from './spec-driver';
|
|
3
|
+
import { type SpecType, type SpecDriver, type WaitOptions } from './spec-driver';
|
|
4
4
|
import { type Driver } from './driver';
|
|
5
5
|
import { type Selector } from './selector';
|
|
6
6
|
import { type Logger } from '@applitools/logger';
|
|
7
|
-
import { Element } from './element';
|
|
8
|
-
export type ContextReference<
|
|
9
|
-
export type
|
|
10
|
-
reference: ContextReference<
|
|
11
|
-
scrollingElement?: Element<
|
|
12
|
-
parent?:
|
|
7
|
+
import { Element, type ElementReference } from './element';
|
|
8
|
+
export type ContextReference<T extends SpecType> = Element<T> | ElementReference<T> | string | number;
|
|
9
|
+
export type NestedContextReference<T extends SpecType> = {
|
|
10
|
+
reference: ContextReference<T>;
|
|
11
|
+
scrollingElement?: Element<T>;
|
|
12
|
+
parent?: Context<T> | ContextReference<T> | NestedContextReference<T>;
|
|
13
13
|
};
|
|
14
|
-
type ContextOptions<
|
|
15
|
-
spec: SpecDriver<
|
|
16
|
-
context?:
|
|
17
|
-
driver?: Driver<
|
|
18
|
-
parent?: Context<
|
|
19
|
-
reference?: ContextReference<
|
|
20
|
-
element?: Element<
|
|
21
|
-
scrollingElement?: Element<
|
|
14
|
+
type ContextOptions<T extends SpecType> = {
|
|
15
|
+
spec: SpecDriver<T>;
|
|
16
|
+
context?: T['context'];
|
|
17
|
+
driver?: Driver<T>;
|
|
18
|
+
parent?: Context<T>;
|
|
19
|
+
reference?: ContextReference<T>;
|
|
20
|
+
element?: Element<T>;
|
|
21
|
+
scrollingElement?: Element<T>;
|
|
22
22
|
logger: Logger;
|
|
23
23
|
};
|
|
24
|
-
export declare class Context<
|
|
24
|
+
export declare class Context<T extends SpecType> {
|
|
25
25
|
private _target?;
|
|
26
26
|
private _driver?;
|
|
27
27
|
private _parent?;
|
|
@@ -31,13 +31,13 @@ export declare class Context<TDriver, TContext, TElement, TSelector> {
|
|
|
31
31
|
private _state;
|
|
32
32
|
private _logger;
|
|
33
33
|
private _isReference;
|
|
34
|
-
protected readonly _spec: SpecDriver<
|
|
35
|
-
constructor(options: ContextOptions<
|
|
36
|
-
get target():
|
|
37
|
-
get driver(): Driver<
|
|
38
|
-
get parent(): Context<
|
|
39
|
-
get main(): Context<
|
|
40
|
-
get path(): Context<
|
|
34
|
+
protected readonly _spec: SpecDriver<T>;
|
|
35
|
+
constructor(options: ContextOptions<T>);
|
|
36
|
+
get target(): T['driver'];
|
|
37
|
+
get driver(): Driver<T>;
|
|
38
|
+
get parent(): Context<T> | null;
|
|
39
|
+
get main(): Context<T>;
|
|
40
|
+
get path(): Context<T>[];
|
|
41
41
|
get isMain(): boolean;
|
|
42
42
|
get isCurrent(): boolean;
|
|
43
43
|
get isInitialized(): boolean;
|
|
@@ -45,11 +45,11 @@ export declare class Context<TDriver, TContext, TElement, TSelector> {
|
|
|
45
45
|
private _findElements;
|
|
46
46
|
init(): Promise<this>;
|
|
47
47
|
focus(): Promise<this>;
|
|
48
|
-
equals(context: Context<
|
|
49
|
-
context(reference:
|
|
50
|
-
element(elementOrSelector:
|
|
51
|
-
elements(selectorOrElement:
|
|
52
|
-
waitFor(selector: Selector<
|
|
48
|
+
equals(context: Context<T> | Element<T>): Promise<boolean>;
|
|
49
|
+
context(reference: ContextReference<T> | NestedContextReference<T>): Promise<Context<T>>;
|
|
50
|
+
element(elementOrSelector: ElementReference<T>): Promise<Element<T> | null>;
|
|
51
|
+
elements(selectorOrElement: ElementReference<T>): Promise<Element<T>[]>;
|
|
52
|
+
waitFor(selector: Selector<T>, options?: WaitOptions): Promise<Element<T> | null>;
|
|
53
53
|
execute(script: ((args: any) => any) | string, arg?: any): Promise<any>;
|
|
54
54
|
executePoll(script: ((arg: any) => any) | string | {
|
|
55
55
|
main: ((arg: any) => any) | string;
|
|
@@ -60,11 +60,11 @@ export declare class Context<TDriver, TContext, TElement, TSelector> {
|
|
|
60
60
|
executionTimeout?: number;
|
|
61
61
|
pollTimeout?: number;
|
|
62
62
|
}): Promise<any>;
|
|
63
|
-
getContextElement(): Promise<Element<
|
|
64
|
-
getScrollingElement(): Promise<Element<
|
|
65
|
-
setScrollingElement(scrollingElement: Element<
|
|
66
|
-
blurElement(element?: Element<
|
|
67
|
-
focusElement(element: Element<
|
|
63
|
+
getContextElement(): Promise<Element<T> | null>;
|
|
64
|
+
getScrollingElement(): Promise<Element<T> | null>;
|
|
65
|
+
setScrollingElement(scrollingElement: Element<T> | ElementReference<T> | undefined | null): Promise<void>;
|
|
66
|
+
blurElement(element?: Element<T>): Promise<T['element'] | null>;
|
|
67
|
+
focusElement(element: Element<T>): Promise<any>;
|
|
68
68
|
getRegion(): Promise<Region>;
|
|
69
69
|
getClientRegion(): Promise<Region>;
|
|
70
70
|
getScrollingRegion(): Promise<Region>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type SpecDriver } from '../spec-driver';
|
|
2
|
-
export declare function checkSpecDriver<
|
|
3
|
-
spec: SpecDriver<
|
|
4
|
-
driver:
|
|
1
|
+
import { SpecType, type SpecDriver } from '../spec-driver';
|
|
2
|
+
export declare function checkSpecDriver<T extends SpecType>(options: {
|
|
3
|
+
spec: SpecDriver<T>;
|
|
4
|
+
driver: T['driver'];
|
|
5
5
|
}): Promise<({
|
|
6
6
|
skipped: boolean;
|
|
7
7
|
test: string;
|
package/types/driver.d.ts
CHANGED
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
import type { Size, Region } from '@applitools/utils';
|
|
3
3
|
import type { ScreenOrientation, Cookie } from './types';
|
|
4
4
|
import { type Selector } from './selector';
|
|
5
|
-
import { type SpecDriver, type WaitOptions } from './spec-driver';
|
|
5
|
+
import { type SpecType, type SpecDriver, type WaitOptions } from './spec-driver';
|
|
6
6
|
import { type Element } from './element';
|
|
7
7
|
import { Context, type ContextReference } from './context';
|
|
8
8
|
import { type Logger } from '@applitools/logger';
|
|
9
9
|
import { HelperIOS } from './helper-ios';
|
|
10
10
|
import { HelperAndroid } from './helper-android';
|
|
11
|
-
type DriverOptions<
|
|
12
|
-
spec: SpecDriver<
|
|
13
|
-
driver:
|
|
11
|
+
type DriverOptions<T extends SpecType> = {
|
|
12
|
+
spec: SpecDriver<T>;
|
|
13
|
+
driver: T['driver'];
|
|
14
14
|
logger?: Logger;
|
|
15
15
|
customConfig?: {
|
|
16
16
|
useCeilForViewportSize?: boolean;
|
|
17
|
-
disableHelper?: boolean;
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
|
-
export declare class Driver<
|
|
19
|
+
export declare class Driver<T extends SpecType> {
|
|
21
20
|
private _target;
|
|
22
21
|
private _mainContext;
|
|
23
22
|
private _currentContext;
|
|
@@ -26,12 +25,11 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
26
25
|
private _customConfig;
|
|
27
26
|
private _helper?;
|
|
28
27
|
private _previousWorld?;
|
|
29
|
-
protected readonly _spec: SpecDriver<
|
|
30
|
-
constructor(options: DriverOptions<
|
|
31
|
-
get target():
|
|
32
|
-
get currentContext(): Context<
|
|
33
|
-
get mainContext(): Context<
|
|
34
|
-
get helper(): HelperAndroid<TDriver, TContext, TElement, TSelector> | HelperIOS<TDriver, TContext, TElement, TSelector> | null | undefined;
|
|
28
|
+
protected readonly _spec: SpecDriver<T>;
|
|
29
|
+
constructor(options: DriverOptions<T>);
|
|
30
|
+
get target(): T['driver'];
|
|
31
|
+
get currentContext(): Context<T>;
|
|
32
|
+
get mainContext(): Context<T>;
|
|
35
33
|
get features(): {
|
|
36
34
|
shadowSelector?: boolean | undefined;
|
|
37
35
|
allCookies?: boolean | undefined;
|
|
@@ -64,8 +62,9 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
64
62
|
get isEC(): boolean;
|
|
65
63
|
get sessionId(): string | undefined;
|
|
66
64
|
get remoteHostname(): string | undefined;
|
|
67
|
-
updateCurrentContext(context: Context<
|
|
65
|
+
updateCurrentContext(context: Context<T>): void;
|
|
68
66
|
init(): Promise<this>;
|
|
67
|
+
getHelper(): Promise<HelperAndroid<T> | HelperIOS<T> | null>;
|
|
69
68
|
switchWorld(options?: {
|
|
70
69
|
id?: string;
|
|
71
70
|
restoreState?: boolean;
|
|
@@ -80,16 +79,16 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
80
79
|
isWebView: boolean;
|
|
81
80
|
}>;
|
|
82
81
|
getSessionMetadata(): Promise<any>;
|
|
83
|
-
refreshContexts(): Promise<Context<
|
|
84
|
-
switchTo(context: Context<
|
|
85
|
-
switchToMainContext(): Promise<Context<
|
|
86
|
-
switchToParentContext(elevation?: number): Promise<Context<
|
|
87
|
-
switchToChildContext(...references: ContextReference<
|
|
82
|
+
refreshContexts(): Promise<Context<T>>;
|
|
83
|
+
switchTo(context: Context<T>): Promise<Context<T>>;
|
|
84
|
+
switchToMainContext(): Promise<Context<T>>;
|
|
85
|
+
switchToParentContext(elevation?: number): Promise<Context<T>>;
|
|
86
|
+
switchToChildContext(...references: ContextReference<T>[]): Promise<Context<T>>;
|
|
88
87
|
normalizeRegion(region: Region): Promise<Region>;
|
|
89
|
-
getRegionInViewport(context: Context<
|
|
90
|
-
element(selector: Selector<
|
|
91
|
-
elements(selector: Selector<
|
|
92
|
-
waitFor(selector: Selector<
|
|
88
|
+
getRegionInViewport(context: Context<T>, region: Region): Promise<Region>;
|
|
89
|
+
element(selector: Selector<T>): Promise<Element<T> | null>;
|
|
90
|
+
elements(selector: Selector<T>): Promise<Element<T>[]>;
|
|
91
|
+
waitFor(selector: Selector<T>, options?: WaitOptions): Promise<Element<T> | null>;
|
|
93
92
|
execute(script: ((arg: any) => any) | string, arg?: any): Promise<any>;
|
|
94
93
|
takeScreenshot(): Promise<Buffer>;
|
|
95
94
|
getViewportRegion(): Promise<Region>;
|
|
@@ -103,14 +102,13 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
|
|
|
103
102
|
getUrl(): Promise<string>;
|
|
104
103
|
visit(url: string): Promise<void>;
|
|
105
104
|
}
|
|
106
|
-
export declare function isDriver<
|
|
107
|
-
export declare function makeDriver<
|
|
108
|
-
driver:
|
|
109
|
-
spec?: SpecDriver<
|
|
105
|
+
export declare function isDriver<T extends SpecType>(driver: any, spec?: SpecDriver<T>): driver is Driver<T> | T['driver'];
|
|
106
|
+
export declare function makeDriver<T extends SpecType>(options: {
|
|
107
|
+
driver: Driver<T> | T['driver'];
|
|
108
|
+
spec?: SpecDriver<T>;
|
|
110
109
|
logger?: Logger;
|
|
111
110
|
customConfig?: {
|
|
112
111
|
useCeilForViewportSize?: boolean;
|
|
113
|
-
disableHelper?: boolean;
|
|
114
112
|
};
|
|
115
|
-
}): Promise<Driver<
|
|
113
|
+
}): Promise<Driver<T>>;
|
|
116
114
|
export {};
|
package/types/element.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import type { Location, Size, Region } from '@applitools/utils';
|
|
2
|
-
import { type SpecDriver } from './spec-driver';
|
|
2
|
+
import { type SpecType, type SpecDriver } from './spec-driver';
|
|
3
3
|
import { type Context } from './context';
|
|
4
4
|
import { type Selector } from './selector';
|
|
5
5
|
import { type Logger } from '@applitools/logger';
|
|
6
|
-
export type ElementReference<
|
|
7
|
-
type ElementState
|
|
6
|
+
export type ElementReference<T extends SpecType> = T['element'] | Selector<T>;
|
|
7
|
+
type ElementState = {
|
|
8
8
|
contentSize?: Size;
|
|
9
9
|
scrollOffset?: Location;
|
|
10
10
|
transforms?: any;
|
|
11
11
|
attributes?: Record<string, string | Error>;
|
|
12
12
|
touchPadding?: number;
|
|
13
|
-
containedElements?: Map<
|
|
13
|
+
containedElements?: Map<any, boolean>;
|
|
14
14
|
};
|
|
15
|
-
type ElementOptions<
|
|
16
|
-
spec: SpecDriver<
|
|
17
|
-
context?: Context<
|
|
15
|
+
type ElementOptions<T extends SpecType> = {
|
|
16
|
+
spec: SpecDriver<T>;
|
|
17
|
+
context?: Context<T>;
|
|
18
18
|
logger: Logger;
|
|
19
19
|
} & ({
|
|
20
|
-
element:
|
|
21
|
-
selector?: Selector<
|
|
20
|
+
element: T['element'];
|
|
21
|
+
selector?: Selector<T>;
|
|
22
22
|
index?: number;
|
|
23
23
|
} | {
|
|
24
|
-
selector: Selector<
|
|
24
|
+
selector: Selector<T>;
|
|
25
25
|
index?: number;
|
|
26
26
|
});
|
|
27
|
-
export declare class Element<
|
|
27
|
+
export declare class Element<T extends SpecType> {
|
|
28
28
|
private _target?;
|
|
29
29
|
private _context?;
|
|
30
30
|
private _selector?;
|
|
@@ -33,18 +33,18 @@ export declare class Element<TDriver, TContext, TElement, TSelector> {
|
|
|
33
33
|
private _state;
|
|
34
34
|
private _originalOverflow;
|
|
35
35
|
private _logger;
|
|
36
|
-
protected readonly _spec: SpecDriver<
|
|
37
|
-
constructor(options: ElementOptions<
|
|
38
|
-
get target(): NonNullable<
|
|
39
|
-
get selector(): Selector<
|
|
36
|
+
protected readonly _spec: SpecDriver<T>;
|
|
37
|
+
constructor(options: ElementOptions<T>);
|
|
38
|
+
get target(): NonNullable<T["element"]>;
|
|
39
|
+
get selector(): Selector<T> | undefined;
|
|
40
40
|
get commonSelector(): Selector<never> | null;
|
|
41
41
|
get index(): number | undefined;
|
|
42
|
-
get context(): Context<
|
|
43
|
-
get driver(): import("./driver").Driver<
|
|
42
|
+
get context(): Context<T>;
|
|
43
|
+
get driver(): import("./driver").Driver<T>;
|
|
44
44
|
get isRef(): boolean;
|
|
45
|
-
equals(element: Element<
|
|
46
|
-
contains(innerElement: Element<
|
|
47
|
-
init(context: Context<
|
|
45
|
+
equals(element: Element<T> | T['element']): Promise<boolean>;
|
|
46
|
+
contains(innerElement: Element<T> | T['element']): Promise<boolean>;
|
|
47
|
+
init(context: Context<T>): Promise<this>;
|
|
48
48
|
getRegion(): Promise<Region>;
|
|
49
49
|
getClientRegion(): Promise<Region>;
|
|
50
50
|
getContentRegion(options?: {
|
|
@@ -64,7 +64,7 @@ export declare class Element<TDriver, TContext, TElement, TSelector> {
|
|
|
64
64
|
isPager(): Promise<boolean>;
|
|
65
65
|
isScrollable(): Promise<boolean>;
|
|
66
66
|
isRoot(): Promise<boolean>;
|
|
67
|
-
getShadowRoot(): Promise<
|
|
67
|
+
getShadowRoot(): Promise<T['element'] | null>;
|
|
68
68
|
getTouchPadding(): Promise<number>;
|
|
69
69
|
getText(): Promise<string>;
|
|
70
70
|
getAttribute(name: string): Promise<string>;
|
|
@@ -78,13 +78,13 @@ export declare class Element<TDriver, TContext, TElement, TSelector> {
|
|
|
78
78
|
getInnerOffset(): Promise<Location>;
|
|
79
79
|
click(): Promise<void>;
|
|
80
80
|
type(value: string): Promise<void>;
|
|
81
|
-
preserveState(): Promise<ElementState
|
|
82
|
-
restoreState(state?: ElementState
|
|
81
|
+
preserveState(): Promise<ElementState>;
|
|
82
|
+
restoreState(state?: ElementState): Promise<void>;
|
|
83
83
|
hideScrollbars(): Promise<void>;
|
|
84
84
|
restoreScrollbars(): Promise<void>;
|
|
85
|
-
refresh(
|
|
85
|
+
refresh(freshTarget?: T['element']): Promise<boolean>;
|
|
86
86
|
withRefresh<TResult>(operation: (...args: any[]) => TResult): Promise<TResult>;
|
|
87
|
-
toJSON():
|
|
87
|
+
toJSON(): T['element'];
|
|
88
88
|
}
|
|
89
|
-
export declare function isElementReference<
|
|
89
|
+
export declare function isElementReference<T extends SpecType>(reference: any, spec?: SpecDriver<T>): reference is ElementReference<T>;
|
|
90
90
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Location, Region } from '@applitools/utils';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Logger } from '@applitools/logger';
|
|
3
|
+
import { type SpecType, type SpecDriver } from './spec-driver';
|
|
3
4
|
import { type Driver } from './driver';
|
|
4
5
|
import { type Element } from './element';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
driver: Driver<TDriver, TContext, TElement, TSelector>;
|
|
6
|
+
export declare class HelperAndroid<T extends SpecType> {
|
|
7
|
+
static make<T extends SpecType>(options: {
|
|
8
|
+
spec: SpecDriver<T>;
|
|
9
|
+
driver: Driver<T>;
|
|
10
10
|
logger: Logger;
|
|
11
|
-
}): Promise<HelperAndroid<
|
|
11
|
+
}): Promise<HelperAndroid<T> | null>;
|
|
12
12
|
private readonly _spec;
|
|
13
13
|
private readonly _input;
|
|
14
14
|
private readonly _action;
|
|
@@ -17,16 +17,16 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
17
17
|
private _logger;
|
|
18
18
|
readonly name: 'android' | 'android-legacy';
|
|
19
19
|
constructor(options: {
|
|
20
|
-
spec: SpecDriver<
|
|
21
|
-
input: Element<
|
|
22
|
-
action: Element<
|
|
20
|
+
spec: SpecDriver<T>;
|
|
21
|
+
input: Element<T>;
|
|
22
|
+
action: Element<T> | null;
|
|
23
23
|
legacy: boolean;
|
|
24
24
|
supportAsync: boolean;
|
|
25
25
|
logger: Logger;
|
|
26
26
|
});
|
|
27
27
|
private _getElementId;
|
|
28
28
|
private _command;
|
|
29
|
-
getContentRegion(element: Element<
|
|
29
|
+
getContentRegion(element: Element<T>, options?: {
|
|
30
30
|
lazyLoad?: {
|
|
31
31
|
scrollLength?: number;
|
|
32
32
|
waitingTime?: number;
|
|
@@ -34,7 +34,7 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
34
34
|
};
|
|
35
35
|
}): Promise<Region | null>;
|
|
36
36
|
getTouchPadding(): Promise<number | undefined>;
|
|
37
|
-
getRegion(element: Element<
|
|
38
|
-
scrollToTop(element: Element<
|
|
39
|
-
scrollBy(element: Element<
|
|
37
|
+
getRegion(element: Element<T>): Promise<Region | null>;
|
|
38
|
+
scrollToTop(element: Element<T>): Promise<void>;
|
|
39
|
+
scrollBy(element: Element<T>, offset: Location): Promise<void>;
|
|
40
40
|
}
|
package/types/helper-ios.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import type { Region } from '@applitools/utils';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Logger } from '@applitools/logger';
|
|
3
|
+
import { type SpecType, type SpecDriver } from './spec-driver';
|
|
3
4
|
import { type Driver } from './driver';
|
|
4
5
|
import { type Element } from './element';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
driver: Driver<TDriver, TContext, TElement, TSelector>;
|
|
6
|
+
export declare class HelperIOS<T extends SpecType> {
|
|
7
|
+
static make<T extends SpecType>(options: {
|
|
8
|
+
spec: SpecDriver<T>;
|
|
9
|
+
driver: Driver<T>;
|
|
10
10
|
logger: Logger;
|
|
11
|
-
}): Promise<HelperIOS<
|
|
11
|
+
}): Promise<HelperIOS<T> | null>;
|
|
12
12
|
private readonly _driver;
|
|
13
13
|
private readonly _element;
|
|
14
14
|
private readonly _spec;
|
|
15
15
|
private _logger;
|
|
16
16
|
readonly name: 'ios';
|
|
17
17
|
constructor(options: {
|
|
18
|
-
driver: Driver<
|
|
19
|
-
element: Element<
|
|
20
|
-
spec: SpecDriver<
|
|
18
|
+
driver: Driver<T>;
|
|
19
|
+
element: Element<T>;
|
|
20
|
+
spec: SpecDriver<T>;
|
|
21
21
|
logger: Logger;
|
|
22
22
|
});
|
|
23
|
-
getContentRegion(element: Element<
|
|
23
|
+
getContentRegion(element: Element<T>): Promise<Region | null>;
|
|
24
24
|
}
|
package/types/selector.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type SpecType } from './spec-driver';
|
|
2
|
+
export type Selector<T extends SpecType = never> = T['selector'] | string | CommonSelector<T>;
|
|
3
|
+
export type CommonSelector<T extends SpecType = never> = {
|
|
4
|
+
selector: T['selector'] | string;
|
|
3
5
|
type?: string;
|
|
4
|
-
child?:
|
|
5
|
-
shadow?:
|
|
6
|
-
frame?:
|
|
7
|
-
fallback?:
|
|
6
|
+
child?: T['selector'] | string | CommonSelector<T>;
|
|
7
|
+
shadow?: T['selector'] | string | CommonSelector<T>;
|
|
8
|
+
frame?: T['selector'] | string | CommonSelector<T>;
|
|
9
|
+
fallback?: T['selector'] | string | CommonSelector<T>;
|
|
8
10
|
};
|
|
9
|
-
export type CommonSelector = Selector;
|
package/types/spec-driver.d.ts
CHANGED
|
@@ -2,6 +2,73 @@
|
|
|
2
2
|
import type { Location, Size, Region } from '@applitools/utils';
|
|
3
3
|
import type { ScreenOrientation, Cookie } from './types';
|
|
4
4
|
import { type Selector } from './selector';
|
|
5
|
+
export type SpecType<TDriver = unknown, TContext = unknown, TElement = unknown, TSelector = unknown> = {
|
|
6
|
+
driver: TDriver;
|
|
7
|
+
context: TContext;
|
|
8
|
+
element: TElement;
|
|
9
|
+
selector: TSelector;
|
|
10
|
+
};
|
|
11
|
+
export interface SpecDriver<T extends SpecType> {
|
|
12
|
+
isDriver(driver: any): driver is T['driver'];
|
|
13
|
+
isContext?(context: any): context is T['context'];
|
|
14
|
+
isElement(element: any): element is T['element'];
|
|
15
|
+
isSelector(selector: any): selector is T['selector'];
|
|
16
|
+
transformDriver?(driver: any): T['driver'];
|
|
17
|
+
transformElement?(element: any): T['element'];
|
|
18
|
+
transformSelector?(selector: Selector<T>): T['selector'];
|
|
19
|
+
untransformSelector?(selector: T['selector'] | Selector<T>): Selector | null;
|
|
20
|
+
extractContext?(element: T['driver'] | T['context']): T['context'];
|
|
21
|
+
extractSelector?(element: T['element']): T['selector'];
|
|
22
|
+
isStaleElementError(error: any, selector?: T['selector']): boolean;
|
|
23
|
+
isEqualElements?(context: T['context'], element1: T['element'], element2: T['element']): Promise<boolean>;
|
|
24
|
+
extractHostName?(driver: T['driver']): string | null;
|
|
25
|
+
mainContext(context: T['context']): Promise<T['context']>;
|
|
26
|
+
parentContext?(context: T['context']): Promise<T['context']>;
|
|
27
|
+
childContext(context: T['context'], element: T['element']): Promise<T['context']>;
|
|
28
|
+
executeScript(context: T['context'], script: ((arg?: any) => any) | string, arg?: any): Promise<any>;
|
|
29
|
+
findElement(context: T['context'], selector: T['selector'], parent?: T['element']): Promise<T['element'] | null>;
|
|
30
|
+
findElements(context: T['context'], selector: T['selector'], parent?: T['element']): Promise<T['element'][]>;
|
|
31
|
+
waitForSelector?(context: T['context'], selector: T['selector'], parent?: T['element'], options?: WaitOptions): Promise<T['element'] | null>;
|
|
32
|
+
setElementText?(context: T['context'], element: T['element'], text: string): Promise<void>;
|
|
33
|
+
getElementText?(context: T['context'], element: T['element']): Promise<string>;
|
|
34
|
+
setWindowSize?(driver: T['driver'], size: Size): Promise<void>;
|
|
35
|
+
getWindowSize?(driver: T['driver']): Promise<Size>;
|
|
36
|
+
setViewportSize?(driver: T['driver'], size: Size): Promise<void>;
|
|
37
|
+
getViewportSize?(driver: T['driver']): Promise<Size>;
|
|
38
|
+
getCookies?(driver: T['driver'] | T['context'], context?: boolean): Promise<Cookie[]>;
|
|
39
|
+
getDriverInfo?(driver: T['driver']): Promise<DriverInfo>;
|
|
40
|
+
getCapabilities?(driver: T['driver']): Promise<Record<string, any>>;
|
|
41
|
+
getTitle(driver: T['driver']): Promise<string>;
|
|
42
|
+
getUrl(driver: T['driver']): Promise<string>;
|
|
43
|
+
takeScreenshot(driver: T['driver']): Promise<Buffer | string>;
|
|
44
|
+
click?(context: T['context'], element: T['element'] | T['selector']): Promise<void>;
|
|
45
|
+
visit?(driver: T['driver'], url: string): Promise<void>;
|
|
46
|
+
getOrientation?(driver: T['driver']): Promise<ScreenOrientation>;
|
|
47
|
+
setOrientation?(driver: T['driver'], orientation: ScreenOrientation): Promise<void>;
|
|
48
|
+
getSystemBars?(driver: T['driver']): Promise<{
|
|
49
|
+
statusBar: {
|
|
50
|
+
visible: boolean;
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
height: number;
|
|
54
|
+
width: number;
|
|
55
|
+
};
|
|
56
|
+
navigationBar: {
|
|
57
|
+
visible: boolean;
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
height: number;
|
|
61
|
+
width: number;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
getElementRegion?(driver: T['driver'], element: T['element']): Promise<Region>;
|
|
65
|
+
getElementAttribute?(driver: T['driver'], element: T['element'], attr: string): Promise<string>;
|
|
66
|
+
performAction?(driver: T['driver'], steps: any[]): Promise<void>;
|
|
67
|
+
getCurrentWorld?(driver: T['driver']): Promise<string>;
|
|
68
|
+
getWorlds?(driver: T['driver']): Promise<string[]>;
|
|
69
|
+
switchWorld?(driver: T['driver'], id: string): Promise<void>;
|
|
70
|
+
getSessionMetadata?(driver: T['driver']): Promise<any>;
|
|
71
|
+
}
|
|
5
72
|
export type DriverInfo = {
|
|
6
73
|
sessionId?: string;
|
|
7
74
|
remoteHostname?: string;
|
|
@@ -43,64 +110,3 @@ export type WaitOptions = {
|
|
|
43
110
|
interval?: number;
|
|
44
111
|
timeout?: number;
|
|
45
112
|
};
|
|
46
|
-
export interface SpecDriver<TDriver, TContext, TElement, TSelector> {
|
|
47
|
-
isDriver(driver: any): driver is TDriver;
|
|
48
|
-
isContext?(context: any): context is TContext;
|
|
49
|
-
isElement(element: any): element is TElement;
|
|
50
|
-
isSelector(selector: any): selector is TSelector;
|
|
51
|
-
transformDriver?(driver: any): TDriver;
|
|
52
|
-
transformElement?(element: any): TElement;
|
|
53
|
-
transformSelector?(selector: Selector<TSelector>): TSelector;
|
|
54
|
-
untransformSelector?(selector: TSelector | Selector<TSelector>): Selector | null;
|
|
55
|
-
extractContext?(element: TDriver | TContext): TContext;
|
|
56
|
-
extractSelector?(element: TElement): TSelector;
|
|
57
|
-
isStaleElementError(error: any, selector?: TSelector): boolean;
|
|
58
|
-
isEqualElements?(context: TContext, element1: TElement, element2: TElement): Promise<boolean>;
|
|
59
|
-
extractHostName?(driver: TDriver): string | null;
|
|
60
|
-
mainContext(context: TContext): Promise<TContext>;
|
|
61
|
-
parentContext?(context: TContext): Promise<TContext>;
|
|
62
|
-
childContext(context: TContext, element: TElement): Promise<TContext>;
|
|
63
|
-
executeScript(context: TContext, script: ((arg?: any) => any) | string, arg?: any): Promise<any>;
|
|
64
|
-
findElement(context: TContext, selector: TSelector, parent?: TElement): Promise<TElement | null>;
|
|
65
|
-
findElements(context: TContext, selector: TSelector, parent?: TElement): Promise<TElement[]>;
|
|
66
|
-
waitForSelector?(context: TContext, selector: TSelector, parent?: TElement, options?: WaitOptions): Promise<TElement | null>;
|
|
67
|
-
setElementText?(context: TContext, element: TElement, text: string): Promise<void>;
|
|
68
|
-
getElementText?(context: TContext, element: TElement): Promise<string>;
|
|
69
|
-
setWindowSize?(driver: TDriver, size: Size): Promise<void>;
|
|
70
|
-
getWindowSize?(driver: TDriver): Promise<Size>;
|
|
71
|
-
setViewportSize?(driver: TDriver, size: Size): Promise<void>;
|
|
72
|
-
getViewportSize?(driver: TDriver): Promise<Size>;
|
|
73
|
-
getCookies?(driver: TDriver | TContext, context?: boolean): Promise<Cookie[]>;
|
|
74
|
-
getDriverInfo?(driver: TDriver): Promise<DriverInfo>;
|
|
75
|
-
getCapabilities?(driver: TDriver): Promise<Record<string, any>>;
|
|
76
|
-
getTitle(driver: TDriver): Promise<string>;
|
|
77
|
-
getUrl(driver: TDriver): Promise<string>;
|
|
78
|
-
takeScreenshot(driver: TDriver): Promise<Buffer | string>;
|
|
79
|
-
click?(context: TContext, element: TElement | TSelector): Promise<void>;
|
|
80
|
-
visit?(driver: TDriver, url: string): Promise<void>;
|
|
81
|
-
getOrientation?(driver: TDriver): Promise<ScreenOrientation>;
|
|
82
|
-
setOrientation?(driver: TDriver, orientation: ScreenOrientation): Promise<void>;
|
|
83
|
-
getSystemBars?(driver: TDriver): Promise<{
|
|
84
|
-
statusBar: {
|
|
85
|
-
visible: boolean;
|
|
86
|
-
x: number;
|
|
87
|
-
y: number;
|
|
88
|
-
height: number;
|
|
89
|
-
width: number;
|
|
90
|
-
};
|
|
91
|
-
navigationBar: {
|
|
92
|
-
visible: boolean;
|
|
93
|
-
x: number;
|
|
94
|
-
y: number;
|
|
95
|
-
height: number;
|
|
96
|
-
width: number;
|
|
97
|
-
};
|
|
98
|
-
}>;
|
|
99
|
-
getElementRegion?(driver: TDriver, element: TElement): Promise<Region>;
|
|
100
|
-
getElementAttribute?(driver: TDriver, element: TElement, attr: string): Promise<string>;
|
|
101
|
-
performAction?(driver: TDriver, steps: any[]): Promise<void>;
|
|
102
|
-
getCurrentWorld?(driver: TDriver): Promise<string>;
|
|
103
|
-
getWorlds?(driver: TDriver): Promise<string[]>;
|
|
104
|
-
switchWorld?(driver: TDriver, id: string): Promise<void>;
|
|
105
|
-
getSessionMetadata?(driver: TDriver): Promise<any>;
|
|
106
|
-
}
|
package/types/spec-utils.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { type SpecDriver } from './spec-driver';
|
|
2
|
-
import { type Selector } from './selector';
|
|
3
|
-
type CommonSelector<TSelector = never> = Exclude<Selector<TSelector>, TSelector | string>;
|
|
1
|
+
import { type SpecType, type SpecDriver } from './spec-driver';
|
|
2
|
+
import { type Selector, type CommonSelector } from './selector';
|
|
4
3
|
export declare function isSimpleCommonSelector(selector: any): selector is CommonSelector;
|
|
5
|
-
export declare function isCommonSelector<
|
|
6
|
-
export declare function isSelector<
|
|
7
|
-
export declare function transformSelector<
|
|
4
|
+
export declare function isCommonSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector'>, selector: any): selector is CommonSelector<T>;
|
|
5
|
+
export declare function isSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector'>, selector: any): selector is Selector<T>;
|
|
6
|
+
export declare function transformSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector' | 'transformSelector'>, selector: Selector<T>, environment?: {
|
|
8
7
|
isWeb?: boolean;
|
|
9
8
|
isNative?: boolean;
|
|
10
9
|
isIOS?: boolean;
|
|
11
10
|
isAndroid?: boolean;
|
|
12
|
-
}):
|
|
13
|
-
export declare function splitSelector<
|
|
14
|
-
contextSelectors: Selector<
|
|
15
|
-
elementSelector: Selector<
|
|
11
|
+
}): T['selector'];
|
|
12
|
+
export declare function splitSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector'>, selector: Selector<T>): {
|
|
13
|
+
contextSelectors: Selector<T>[];
|
|
14
|
+
elementSelector: Selector<T>;
|
|
16
15
|
};
|
|
17
|
-
export declare function withFastCache<TSpecDriver extends SpecDriver<
|
|
18
|
-
export {};
|
|
16
|
+
export declare function withFastCache<TSpecDriver extends SpecDriver<SpecType>>(spec: TSpecDriver): TSpecDriver;
|