@applitools/driver 1.9.15 → 1.9.18
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/driver.js +35 -30
- package/dist/element.js +64 -47
- package/dist/fake/spec-driver.js +1 -2
- package/dist/helper-android.js +5 -29
- package/dist/helper-ios.js +11 -10
- package/dist/spec-utils.js +7 -1
- package/package.json +4 -3
- package/types/helper-android.d.ts +1 -1
- package/types/helper-ios.d.ts +1 -1
- package/types/spec-utils.d.ts +1 -0
package/dist/driver.js
CHANGED
|
@@ -144,8 +144,8 @@ class Driver {
|
|
|
144
144
|
this._currentContext = context;
|
|
145
145
|
}
|
|
146
146
|
async init() {
|
|
147
|
-
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;
|
|
148
|
-
var
|
|
147
|
+
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;
|
|
148
|
+
var _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
|
149
149
|
const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
|
|
150
150
|
this._logger.log('Driver capabilities', capabilities);
|
|
151
151
|
const capabilitiesInfo = capabilities ? (0, capabilities_1.parseCapabilities)(capabilities, this._customConfig) : undefined;
|
|
@@ -156,39 +156,46 @@ class Driver {
|
|
|
156
156
|
(_e = (await this.getOrientation().catch(() => undefined))) !== null && _e !== void 0 ? _e : this._driverInfo.orientation;
|
|
157
157
|
}
|
|
158
158
|
if (this.isWeb) {
|
|
159
|
-
(_f = (
|
|
160
|
-
(_g = (
|
|
161
|
-
(_h = (
|
|
159
|
+
(_f = (_3 = this._driverInfo).pixelRatio) !== null && _f !== void 0 ? _f : (_3.pixelRatio = await this.execute(snippets.getPixelRatio));
|
|
160
|
+
(_g = (_4 = this._driverInfo).viewportScale) !== null && _g !== void 0 ? _g : (_4.viewportScale = await this.execute(snippets.getViewportScale));
|
|
161
|
+
(_h = (_5 = this._driverInfo).userAgent) !== null && _h !== void 0 ? _h : (_5.userAgent = await this.execute(snippets.getUserAgent));
|
|
162
162
|
if (this._driverInfo.userAgent) {
|
|
163
163
|
const userAgentInfo = (0, user_agent_1.parseUserAgent)(this._driverInfo.userAgent);
|
|
164
164
|
this._driverInfo.browserName = (_j = userAgentInfo.browserName) !== null && _j !== void 0 ? _j : this._driverInfo.browserName;
|
|
165
165
|
this._driverInfo.browserVersion = (_k = userAgentInfo.browserVersion) !== null && _k !== void 0 ? _k : this._driverInfo.browserVersion;
|
|
166
166
|
if (this._driverInfo.isMobile) {
|
|
167
|
-
(_l = (
|
|
168
|
-
(_m = (
|
|
167
|
+
(_l = (_6 = this._driverInfo).platformName) !== null && _l !== void 0 ? _l : (_6.platformName = userAgentInfo.platformName);
|
|
168
|
+
(_m = (_7 = this._driverInfo).platformVersion) !== null && _m !== void 0 ? _m : (_7.platformVersion = userAgentInfo.platformVersion);
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
171
171
|
this._driverInfo.platformName = (_o = userAgentInfo.platformName) !== null && _o !== void 0 ? _o : this._driverInfo.platformName;
|
|
172
172
|
this._driverInfo.platformVersion = (_p = userAgentInfo.platformVersion) !== null && _p !== void 0 ? _p : this._driverInfo.platformVersion;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
(_q = (
|
|
176
|
-
(_r = (
|
|
175
|
+
(_q = (_8 = this._driverInfo).features) !== null && _q !== void 0 ? _q : (_8.features = {});
|
|
176
|
+
(_r = (_9 = this._driverInfo.features).allCookies) !== null && _r !== void 0 ? _r : (_9.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
|
|
177
177
|
}
|
|
178
178
|
else {
|
|
179
179
|
// this value always excludes the height of the navigation bar, and sometimes it also excludes the height of the status bar
|
|
180
180
|
let windowSize = await this._spec.getWindowSize(this.target);
|
|
181
|
-
(_s = (
|
|
181
|
+
(_s = (_10 = this._driverInfo).displaySize) !== null && _s !== void 0 ? _s : (_10.displaySize = windowSize);
|
|
182
|
+
if (((_t = this.orientation) === null || _t === void 0 ? void 0 : _t.startsWith('landscape')) &&
|
|
183
|
+
this._driverInfo.displaySize.height > this._driverInfo.displaySize.width) {
|
|
184
|
+
this._driverInfo.displaySize = {
|
|
185
|
+
width: this._driverInfo.displaySize.height,
|
|
186
|
+
height: this._driverInfo.displaySize.width,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
182
189
|
if (this.isAndroid) {
|
|
183
190
|
// bar sizes could be extracted only on android
|
|
184
|
-
const systemBars = await ((
|
|
191
|
+
const systemBars = await ((_v = (_u = this._spec).getSystemBars) === null || _v === void 0 ? void 0 : _v.call(_u, this.target).catch(() => null));
|
|
185
192
|
const { statusBar, navigationBar } = systemBars !== null && systemBars !== void 0 ? systemBars : {};
|
|
186
193
|
if (statusBar === null || statusBar === void 0 ? void 0 : statusBar.visible) {
|
|
187
194
|
this._logger.log('Driver status bar', statusBar);
|
|
188
195
|
const statusBarSize = statusBar.height;
|
|
189
196
|
// when status bar is overlapping content on android it returns status bar height equal to display height
|
|
190
197
|
if (statusBarSize < this._driverInfo.displaySize.height) {
|
|
191
|
-
this._driverInfo.statusBarSize = Math.max((
|
|
198
|
+
this._driverInfo.statusBarSize = Math.max((_w = this._driverInfo.statusBarSize) !== null && _w !== void 0 ? _w : 0, statusBarSize);
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
if (navigationBar === null || navigationBar === void 0 ? void 0 : navigationBar.visible) {
|
|
@@ -197,40 +204,38 @@ class Driver {
|
|
|
197
204
|
if (navigationBar.x > 0)
|
|
198
205
|
this._driverInfo.orientation = 'landscape-secondary';
|
|
199
206
|
// navigation bar size could be its height or width depending on screen orientation
|
|
200
|
-
const navigationBarSize = navigationBar[((
|
|
207
|
+
const navigationBarSize = navigationBar[((_x = this.orientation) === null || _x === void 0 ? void 0 : _x.startsWith('landscape')) ? 'width' : 'height'];
|
|
201
208
|
// when navigation bar is invisible on android it returns navigation bar size equal to display size
|
|
202
209
|
if (navigationBarSize <
|
|
203
|
-
this._driverInfo.displaySize[((
|
|
204
|
-
this._driverInfo.navigationBarSize = Math.max((
|
|
210
|
+
this._driverInfo.displaySize[((_y = this.orientation) === null || _y === void 0 ? void 0 : _y.startsWith('landscape')) ? 'width' : 'height']) {
|
|
211
|
+
this._driverInfo.navigationBarSize = Math.max((_z = this._driverInfo.navigationBarSize) !== null && _z !== void 0 ? _z : 0, navigationBarSize);
|
|
205
212
|
}
|
|
206
213
|
else {
|
|
207
214
|
this._driverInfo.navigationBarSize = 0;
|
|
208
215
|
}
|
|
209
216
|
}
|
|
210
217
|
// bar sizes have to be scaled on android
|
|
211
|
-
(
|
|
212
|
-
(
|
|
218
|
+
(_11 = this._driverInfo).statusBarSize && (_11.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio);
|
|
219
|
+
(_12 = this._driverInfo).navigationBarSize && (_12.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio);
|
|
213
220
|
windowSize = utils.geometry.scale(windowSize, 1 / this.pixelRatio);
|
|
214
|
-
(
|
|
221
|
+
(_13 = this._driverInfo).displaySize && (_13.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
|
|
222
|
+
}
|
|
223
|
+
if (this.isIOS) {
|
|
224
|
+
if ((_0 = this.orientation) === null || _0 === void 0 ? void 0 : _0.startsWith('landscape'))
|
|
225
|
+
this._driverInfo.statusBarSize = 0;
|
|
215
226
|
}
|
|
216
227
|
// calculate viewport location
|
|
217
|
-
(
|
|
228
|
+
(_1 = (_14 = this._driverInfo).viewportLocation) !== null && _1 !== void 0 ? _1 : (_14.viewportLocation = {
|
|
218
229
|
x: this.orientation === 'landscape' ? this.navigationBarSize : 0,
|
|
219
230
|
y: this.statusBarSize,
|
|
220
231
|
});
|
|
221
232
|
// calculate viewport size
|
|
222
233
|
if (!this._driverInfo.viewportSize) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
this._driverInfo.viewportSize = {
|
|
231
|
-
width: this._driverInfo.displaySize.width,
|
|
232
|
-
height: this._driverInfo.displaySize.height - this.statusBarSize - this.navigationBarSize,
|
|
233
|
-
};
|
|
234
|
+
this._driverInfo.viewportSize = { ...this._driverInfo.displaySize };
|
|
235
|
+
this._driverInfo.viewportSize.height -= this.statusBarSize;
|
|
236
|
+
if (this.isAndroid) {
|
|
237
|
+
this._driverInfo.viewportSize[((_2 = this.orientation) === null || _2 === void 0 ? void 0 : _2.startsWith('landscape')) ? 'width' : 'height'] -=
|
|
238
|
+
this.navigationBarSize;
|
|
234
239
|
}
|
|
235
240
|
}
|
|
236
241
|
// calculate safe area
|
package/dist/element.js
CHANGED
|
@@ -50,7 +50,10 @@ class Element {
|
|
|
50
50
|
else {
|
|
51
51
|
throw new TypeError('Element constructor called with argument of unknown type!');
|
|
52
52
|
}
|
|
53
|
-
if (this._selector
|
|
53
|
+
if (specUtils.isSimpleCommonSelector(this._selector)) {
|
|
54
|
+
this._commonSelector = this._selector;
|
|
55
|
+
}
|
|
56
|
+
else if (this._selector && this._spec.untransformSelector) {
|
|
54
57
|
this._commonSelector = this._spec.untransformSelector(this._spec.transformSelector(this._selector));
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -105,28 +108,33 @@ class Element {
|
|
|
105
108
|
if (await this.equals(innerElement))
|
|
106
109
|
return false;
|
|
107
110
|
// if the inner element region is contained in this element region, then it then could be assumed that the inner element is contained in this element
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
:
|
|
111
|
+
let contentRegion = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getContentRegion(this));
|
|
112
|
+
if (!contentRegion || !this.driver.isAndroid) {
|
|
113
|
+
const nativeContentRegion = await this.getAttribute('contentSize')
|
|
114
|
+
.then(data => {
|
|
115
|
+
const contentSize = JSON.parse(data);
|
|
116
|
+
return {
|
|
117
|
+
x: contentSize.left,
|
|
118
|
+
y: contentSize.top,
|
|
119
|
+
width: contentSize.width,
|
|
120
|
+
height: this.driver.isIOS
|
|
121
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
122
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
123
|
+
};
|
|
124
|
+
})
|
|
125
|
+
.catch(err => {
|
|
126
|
+
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
127
|
+
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
128
|
+
});
|
|
129
|
+
contentRegion = {
|
|
130
|
+
x: nativeContentRegion.x,
|
|
131
|
+
y: nativeContentRegion.y,
|
|
132
|
+
width: Math.max((_c = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.width) !== null && _c !== void 0 ? _c : 0, nativeContentRegion.width),
|
|
133
|
+
height: Math.max((_d = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.height) !== null && _d !== void 0 ? _d : 0, nativeContentRegion.height),
|
|
118
134
|
};
|
|
119
|
-
}
|
|
120
|
-
.catch(() => this._spec.getElementRegion(this.driver.target, this.target));
|
|
121
|
-
const contentSize = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getContentSize(this));
|
|
122
|
-
const region = {
|
|
123
|
-
x: contentRegion.x,
|
|
124
|
-
y: contentRegion.y,
|
|
125
|
-
width: Math.max((_c = contentSize === null || contentSize === void 0 ? void 0 : contentSize.width) !== null && _c !== void 0 ? _c : 0, contentRegion.width),
|
|
126
|
-
height: Math.max((_d = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _d !== void 0 ? _d : 0, contentRegion.height),
|
|
127
|
-
};
|
|
135
|
+
}
|
|
128
136
|
const innerRegion = await this._spec.getElementRegion(this.driver.target, innerElement);
|
|
129
|
-
const contains = utils.geometry.contains(
|
|
137
|
+
const contains = utils.geometry.contains(contentRegion, innerRegion);
|
|
130
138
|
(_e = (_f = this._state).containedElements) !== null && _e !== void 0 ? _e : (_f.containedElements = new Map());
|
|
131
139
|
this._state.containedElements.set(innerElement, contains);
|
|
132
140
|
return contains;
|
|
@@ -194,29 +202,35 @@ class Element {
|
|
|
194
202
|
else {
|
|
195
203
|
this._logger.log('Extracting content size of native element with selector', this.selector);
|
|
196
204
|
try {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
: contentSize.
|
|
205
|
+
let contentRegion = await ((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.getContentRegion(this));
|
|
206
|
+
this._logger.log('Extracted native content region using helper library', contentRegion);
|
|
207
|
+
// on android extraction of this argument will perform non-deterministic touch action, so it is better to avoid it
|
|
208
|
+
if (!contentRegion || !this.driver.isAndroid) {
|
|
209
|
+
const attrContentRegion = await this.getAttribute('contentSize')
|
|
210
|
+
.then(data => {
|
|
211
|
+
const contentSize = JSON.parse(data);
|
|
212
|
+
return {
|
|
213
|
+
x: contentSize.left,
|
|
214
|
+
y: contentSize.top,
|
|
215
|
+
width: contentSize.width,
|
|
216
|
+
height: this.driver.isIOS
|
|
217
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
218
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
219
|
+
};
|
|
220
|
+
})
|
|
221
|
+
.catch(err => {
|
|
222
|
+
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
223
|
+
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
224
|
+
});
|
|
225
|
+
this._logger.log('Extracted native content region using attribute', attrContentRegion);
|
|
226
|
+
contentRegion = {
|
|
227
|
+
x: attrContentRegion.x,
|
|
228
|
+
y: attrContentRegion.y,
|
|
229
|
+
width: Math.max((_b = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.width) !== null && _b !== void 0 ? _b : 0, attrContentRegion.width),
|
|
230
|
+
height: Math.max((_c = contentRegion === null || contentRegion === void 0 ? void 0 : contentRegion.height) !== null && _c !== void 0 ? _c : 0, attrContentRegion.height),
|
|
207
231
|
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
211
|
-
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
212
|
-
});
|
|
213
|
-
this._logger.log('Extracted native content size attribute', contentRegion);
|
|
214
|
-
const contentSize = await ((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.getContentSize(this));
|
|
215
|
-
this._logger.log('Extracted native content size with helper library', contentSize);
|
|
216
|
-
this._state.contentSize = {
|
|
217
|
-
width: Math.max((_b = contentSize === null || contentSize === void 0 ? void 0 : contentSize.width) !== null && _b !== void 0 ? _b : 0, contentRegion.width),
|
|
218
|
-
height: Math.max((_c = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _c !== void 0 ? _c : 0, contentRegion.height),
|
|
219
|
-
};
|
|
232
|
+
}
|
|
233
|
+
this._state.contentSize = utils.geometry.size(contentRegion);
|
|
220
234
|
if (this.driver.isAndroid) {
|
|
221
235
|
this._state.contentSize = utils.geometry.scale(this._state.contentSize, 1 / this.driver.pixelRatio);
|
|
222
236
|
}
|
|
@@ -286,6 +300,7 @@ class Element {
|
|
|
286
300
|
}
|
|
287
301
|
async getTouchPadding() {
|
|
288
302
|
var _a, _b;
|
|
303
|
+
var _c;
|
|
289
304
|
if (this._state.touchPadding == null) {
|
|
290
305
|
if (this.driver.isWeb)
|
|
291
306
|
this._state.touchPadding = 0;
|
|
@@ -293,16 +308,18 @@ class Element {
|
|
|
293
308
|
this._state.touchPadding = 10;
|
|
294
309
|
else if (this.driver.isAndroid) {
|
|
295
310
|
if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android') {
|
|
296
|
-
this._state.touchPadding = await
|
|
311
|
+
this._state.touchPadding = await this.driver.helper.getTouchPadding();
|
|
312
|
+
this._logger.log('Touch padding extracted using helper library', this._state.touchPadding);
|
|
297
313
|
}
|
|
298
|
-
|
|
299
|
-
|
|
314
|
+
else {
|
|
315
|
+
this._state.touchPadding = await this.getAttribute('contentSize')
|
|
300
316
|
.then(data => JSON.parse(data).touchPadding)
|
|
301
317
|
.catch(err => {
|
|
302
318
|
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`);
|
|
303
319
|
});
|
|
304
|
-
this.
|
|
320
|
+
this._logger.log('Touch padding extracted using attribute', this._state.touchPadding);
|
|
305
321
|
}
|
|
322
|
+
(_b = (_c = this._state).touchPadding) !== null && _b !== void 0 ? _b : (_c.touchPadding = 20);
|
|
306
323
|
this._logger.log('Touch padding set:', this._state.touchPadding);
|
|
307
324
|
}
|
|
308
325
|
}
|
package/dist/fake/spec-driver.js
CHANGED
|
@@ -100,8 +100,7 @@ async function getDriverInfo(driver) {
|
|
|
100
100
|
}
|
|
101
101
|
exports.getDriverInfo = getDriverInfo;
|
|
102
102
|
async function getWindowSize(driver) {
|
|
103
|
-
|
|
104
|
-
return rect;
|
|
103
|
+
return utils.geometry.size(await driver.getWindowRect());
|
|
105
104
|
}
|
|
106
105
|
exports.getWindowSize = getWindowSize;
|
|
107
106
|
async function setWindowSize(driver, size) {
|
package/dist/helper-android.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.HelperAndroid = void 0;
|
|
27
|
-
const utils = __importStar(require("@applitools/utils"));
|
|
28
4
|
class HelperAndroid {
|
|
29
5
|
constructor(options) {
|
|
30
6
|
this._spec = options.spec;
|
|
@@ -55,7 +31,7 @@ class HelperAndroid {
|
|
|
55
31
|
return null;
|
|
56
32
|
return resourceId.split('/')[1];
|
|
57
33
|
}
|
|
58
|
-
async
|
|
34
|
+
async getContentRegion(element) {
|
|
59
35
|
let contentHeightString;
|
|
60
36
|
if (this._legacy) {
|
|
61
37
|
await this._input.click();
|
|
@@ -75,9 +51,9 @@ class HelperAndroid {
|
|
|
75
51
|
}
|
|
76
52
|
const region = await this._spec.getElementRegion(this._input.driver.target, element.target);
|
|
77
53
|
const contentHeight = Number(contentHeightString);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
54
|
+
return !Number.isNaN(contentHeight) && contentHeight >= region.height
|
|
55
|
+
? { x: region.x, y: region.y, width: region.width, height: contentHeight }
|
|
56
|
+
: null;
|
|
81
57
|
}
|
|
82
58
|
async getRegion(element) {
|
|
83
59
|
if (this._legacy)
|
|
@@ -135,7 +111,7 @@ class HelperAndroid {
|
|
|
135
111
|
const touchPaddingString = await this._input.getText();
|
|
136
112
|
await this._input.type('');
|
|
137
113
|
const touchPadding = Number(touchPaddingString);
|
|
138
|
-
if (Number.isNaN(touchPadding))
|
|
114
|
+
if (!touchPadding || Number.isNaN(touchPadding))
|
|
139
115
|
return null;
|
|
140
116
|
return touchPadding;
|
|
141
117
|
}
|
package/dist/helper-ios.js
CHANGED
|
@@ -14,8 +14,9 @@ class HelperIOS {
|
|
|
14
14
|
const element = await driver.element({ type: 'name', selector: 'applitools_grab_scrollable_data_button' });
|
|
15
15
|
return element ? new HelperIOS({ driver, element, spec, logger }) : null;
|
|
16
16
|
}
|
|
17
|
-
async
|
|
17
|
+
async getContentRegion(element) {
|
|
18
18
|
await this._element.click();
|
|
19
|
+
const region = await this._spec.getElementRegion(this._driver.target, element.target);
|
|
19
20
|
const sizeLabel = await this._driver.element({ type: 'name', selector: 'applitools_content_size_label' });
|
|
20
21
|
const sizeString = await (sizeLabel === null || sizeLabel === void 0 ? void 0 : sizeLabel.getText());
|
|
21
22
|
if (!sizeString)
|
|
@@ -26,15 +27,15 @@ class HelperIOS {
|
|
|
26
27
|
return null;
|
|
27
28
|
const paddingLabel = await this._driver.element({ type: 'name', selector: 'applitools_content_offset_label' });
|
|
28
29
|
const paddingString = await (paddingLabel === null || paddingLabel === void 0 ? void 0 : paddingLabel.getText());
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return contentSize;
|
|
30
|
+
if (paddingString) {
|
|
31
|
+
const [, x, y] = paddingString.match(/\{(-?\d+(?:\.\d+)?),\s?(-?\d+(?:\.\d+)?)\}/);
|
|
32
|
+
const contentOffset = { x: Number(x), y: Number(y) };
|
|
33
|
+
if (!Number.isNaN(contentOffset.x))
|
|
34
|
+
contentSize.width -= contentOffset.x;
|
|
35
|
+
if (!Number.isNaN(contentOffset.y))
|
|
36
|
+
contentSize.height -= contentOffset.y;
|
|
37
|
+
}
|
|
38
|
+
return contentSize.height >= region.height ? { x: region.x, y: region.y, ...contentSize } : null;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
exports.HelperIOS = HelperIOS;
|
package/dist/spec-utils.js
CHANGED
|
@@ -23,8 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.withFastCache = exports.splitSelector = exports.transformSelector = exports.isSelector = exports.isCommonSelector = void 0;
|
|
26
|
+
exports.withFastCache = exports.splitSelector = exports.transformSelector = exports.isSelector = exports.isCommonSelector = exports.isSimpleCommonSelector = void 0;
|
|
27
27
|
const utils = __importStar(require("@applitools/utils"));
|
|
28
|
+
function isSimpleCommonSelector(selector) {
|
|
29
|
+
return (utils.types.isPlainObject(selector) &&
|
|
30
|
+
utils.types.has(selector, 'selector') &&
|
|
31
|
+
utils.types.isString(selector.selector));
|
|
32
|
+
}
|
|
33
|
+
exports.isSimpleCommonSelector = isSimpleCommonSelector;
|
|
28
34
|
function isCommonSelector(spec, selector) {
|
|
29
35
|
return (utils.types.isPlainObject(selector) &&
|
|
30
36
|
utils.types.has(selector, 'selector') &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.18",
|
|
4
4
|
"description": "Applitools universal framework wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"applitools",
|
|
@@ -79,12 +79,13 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@applitools/logger": "1.1.15",
|
|
82
|
-
"@applitools/snippets": "2.4.
|
|
83
|
-
"@applitools/types": "1.5.
|
|
82
|
+
"@applitools/snippets": "2.4.5",
|
|
83
|
+
"@applitools/types": "1.5.7",
|
|
84
84
|
"@applitools/utils": "1.3.10"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@applitools/bongo": "^2.1.6",
|
|
88
|
+
"@applitools/scripts": "^1.1.0",
|
|
88
89
|
"@types/mocha": "^9.1.1",
|
|
89
90
|
"@types/node": "^17.0.31",
|
|
90
91
|
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
@@ -22,7 +22,7 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
|
|
|
22
22
|
logger?: any;
|
|
23
23
|
});
|
|
24
24
|
_getElementId(element: Element<TDriver, TContext, TElement, TSelector>): Promise<string>;
|
|
25
|
-
|
|
25
|
+
getContentRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;
|
|
26
26
|
getRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;
|
|
27
27
|
scrollToTop(element: Element<TDriver, TContext, TElement, TSelector>): Promise<void>;
|
|
28
28
|
scrollBy(element: Element<TDriver, TContext, TElement, TSelector>, offset: types.Location): Promise<void>;
|
package/types/helper-ios.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export declare class HelperIOS<TDriver, TContext, TElement, TSelector> {
|
|
|
19
19
|
spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
|
|
20
20
|
logger?: Logger;
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
getContentRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>;
|
|
23
23
|
}
|
package/types/spec-utils.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare type CommonSelector<TSelector = never> = {
|
|
|
5
5
|
shadow?: CommonSelector<TSelector> | TSelector | string;
|
|
6
6
|
frame?: CommonSelector<TSelector> | TSelector | string;
|
|
7
7
|
};
|
|
8
|
+
export declare function isSimpleCommonSelector(selector: any): selector is CommonSelector;
|
|
8
9
|
export declare function isCommonSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector'>, selector: any): selector is CommonSelector<TSelector>;
|
|
9
10
|
export declare function isSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector'>, selector: any): selector is types.Selector<TSelector>;
|
|
10
11
|
export declare function transformSelector<TSelector>(spec: Pick<types.SpecDriver<unknown, unknown, unknown, TSelector>, 'isSelector' | 'transformSelector'>, selector: types.Selector<TSelector>, environment?: {
|