@applitools/driver 1.10.6 → 1.11.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/dist/driver.js +15 -14
- package/dist/element.js +34 -32
- package/package.json +1 -1
- package/types/driver.d.ts +1 -0
- package/types/element.d.ts +6 -0
- package/types/spec-driver.d.ts +1 -0
package/dist/driver.js
CHANGED
|
@@ -152,8 +152,8 @@ class Driver {
|
|
|
152
152
|
this._currentContext = context;
|
|
153
153
|
}
|
|
154
154
|
async init() {
|
|
155
|
-
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;
|
|
156
|
-
var
|
|
155
|
+
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;
|
|
156
|
+
var _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
157
157
|
// NOTE: this is here because saucelabs does not provide right capabilities for the first call
|
|
158
158
|
await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
|
|
159
159
|
const capabilities = await ((_d = (_c = this._spec).getCapabilities) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
|
|
@@ -168,16 +168,16 @@ class Driver {
|
|
|
168
168
|
this._driverInfo.isWebView = !!(world === null || world === void 0 ? void 0 : world.isWebView);
|
|
169
169
|
}
|
|
170
170
|
if (this.isWeb) {
|
|
171
|
-
(_h = (
|
|
172
|
-
(_j = (
|
|
173
|
-
(_k = (
|
|
171
|
+
(_h = (_7 = this._driverInfo).pixelRatio) !== null && _h !== void 0 ? _h : (_7.pixelRatio = await this.execute(snippets.getPixelRatio));
|
|
172
|
+
(_j = (_8 = this._driverInfo).viewportScale) !== null && _j !== void 0 ? _j : (_8.viewportScale = await this.execute(snippets.getViewportScale));
|
|
173
|
+
(_k = (_9 = this._driverInfo).userAgent) !== null && _k !== void 0 ? _k : (_9.userAgent = await this.execute(snippets.getUserAgent));
|
|
174
174
|
if (this._driverInfo.userAgent) {
|
|
175
175
|
const userAgentInfo = (0, user_agent_1.parseUserAgent)(this._driverInfo.userAgent);
|
|
176
176
|
this._driverInfo.browserName = (_l = userAgentInfo.browserName) !== null && _l !== void 0 ? _l : this._driverInfo.browserName;
|
|
177
177
|
this._driverInfo.browserVersion = (_m = userAgentInfo.browserVersion) !== null && _m !== void 0 ? _m : this._driverInfo.browserVersion;
|
|
178
178
|
if (this._driverInfo.isMobile) {
|
|
179
|
-
(_o = (
|
|
180
|
-
(_p = (
|
|
179
|
+
(_o = (_10 = this._driverInfo).platformName) !== null && _o !== void 0 ? _o : (_10.platformName = userAgentInfo.platformName);
|
|
180
|
+
(_p = (_11 = this._driverInfo).platformVersion) !== null && _p !== void 0 ? _p : (_11.platformVersion = userAgentInfo.platformVersion);
|
|
181
181
|
}
|
|
182
182
|
else {
|
|
183
183
|
this._driverInfo.platformName = (_q = userAgentInfo.platformName) !== null && _q !== void 0 ? _q : this._driverInfo.platformName;
|
|
@@ -188,13 +188,13 @@ class Driver {
|
|
|
188
188
|
this._driverInfo.isMobile = true;
|
|
189
189
|
this._driverInfo.isEmulation = this._driverInfo.isChrome;
|
|
190
190
|
}
|
|
191
|
-
(_s = (
|
|
192
|
-
(_t = (
|
|
191
|
+
(_s = (_12 = this._driverInfo).features) !== null && _s !== void 0 ? _s : (_12.features = {});
|
|
192
|
+
(_t = (_13 = this._driverInfo.features).allCookies) !== null && _t !== void 0 ? _t : (_13.allCookies = this._driverInfo.isChrome || (/chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile));
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
195
|
// this value always excludes the height of the navigation bar, and sometimes it also excludes the height of the status bar
|
|
196
196
|
let windowSize = await this._spec.getWindowSize(this.target);
|
|
197
|
-
(_u = (
|
|
197
|
+
(_u = (_14 = this._driverInfo).displaySize) !== null && _u !== void 0 ? _u : (_14.displaySize = windowSize);
|
|
198
198
|
if (((_v = this.orientation) === null || _v === void 0 ? void 0 : _v.startsWith('landscape')) &&
|
|
199
199
|
this._driverInfo.displaySize.height > this._driverInfo.displaySize.width) {
|
|
200
200
|
this._driverInfo.displaySize = {
|
|
@@ -231,17 +231,17 @@ class Driver {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
// bar sizes have to be scaled on android
|
|
234
|
-
(
|
|
235
|
-
(
|
|
234
|
+
(_15 = this._driverInfo).statusBarSize && (_15.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio);
|
|
235
|
+
(_16 = this._driverInfo).navigationBarSize && (_16.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio);
|
|
236
236
|
windowSize = utils.geometry.scale(windowSize, 1 / this.pixelRatio);
|
|
237
|
-
(
|
|
237
|
+
(_17 = this._driverInfo).displaySize && (_17.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
|
|
238
238
|
}
|
|
239
239
|
if (this.isIOS) {
|
|
240
240
|
if ((_2 = this.orientation) === null || _2 === void 0 ? void 0 : _2.startsWith('landscape'))
|
|
241
241
|
this._driverInfo.statusBarSize = 0;
|
|
242
242
|
}
|
|
243
243
|
// calculate viewport location
|
|
244
|
-
(_3 = (
|
|
244
|
+
(_3 = (_18 = this._driverInfo).viewportLocation) !== null && _3 !== void 0 ? _3 : (_18.viewportLocation = {
|
|
245
245
|
x: this.orientation === 'landscape' ? this.navigationBarSize : 0,
|
|
246
246
|
y: this.statusBarSize,
|
|
247
247
|
});
|
|
@@ -278,6 +278,7 @@ class Driver {
|
|
|
278
278
|
? await helper_ios_1.HelperIOS.make({ spec: this._spec, driver: this, logger: this._logger })
|
|
279
279
|
: await helper_android_1.HelperAndroid.make({ spec: this._spec, driver: this, logger: this._logger });
|
|
280
280
|
}
|
|
281
|
+
this._logger.log(`Helper set to ${(_6 = this._helper) === null || _6 === void 0 ? void 0 : _6.name}`);
|
|
281
282
|
}
|
|
282
283
|
this._logger.log('Combined driver info', this._driverInfo);
|
|
283
284
|
return this;
|
package/dist/element.js
CHANGED
|
@@ -110,22 +110,7 @@ class Element {
|
|
|
110
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
|
|
111
111
|
let contentRegion = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getContentRegion(this));
|
|
112
112
|
if (!contentRegion || !this.driver.isAndroid) {
|
|
113
|
-
const nativeContentRegion = await this.
|
|
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
|
-
});
|
|
113
|
+
const nativeContentRegion = await this.getContentSizeFromAttribute();
|
|
129
114
|
contentRegion = {
|
|
130
115
|
x: nativeContentRegion.x,
|
|
131
116
|
y: nativeContentRegion.y,
|
|
@@ -190,6 +175,38 @@ class Element {
|
|
|
190
175
|
this._logger.log('Extracted client region', region);
|
|
191
176
|
return region;
|
|
192
177
|
}
|
|
178
|
+
async getContentSizeFromAttribute() {
|
|
179
|
+
try {
|
|
180
|
+
const data = await this.getAttribute('contentSize');
|
|
181
|
+
const contentSize = JSON.parse(data);
|
|
182
|
+
return {
|
|
183
|
+
x: contentSize.left,
|
|
184
|
+
y: contentSize.top,
|
|
185
|
+
width: contentSize.width,
|
|
186
|
+
height: this.driver.isIOS
|
|
187
|
+
? Math.max(contentSize.height, contentSize.scrollableOffset)
|
|
188
|
+
: contentSize.height + contentSize.scrollableOffset,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`);
|
|
193
|
+
}
|
|
194
|
+
const type = await this.getAttribute('type');
|
|
195
|
+
if (type === 'XCUIElementTypeScrollView') {
|
|
196
|
+
const elementRegion = await this._spec.getElementRegion(this.driver.target, this.target);
|
|
197
|
+
const [childElement] = await this.driver.elements({
|
|
198
|
+
type: 'xpath',
|
|
199
|
+
selector: '//XCUIElementTypeScrollView[1]/*', // We cannot be sure that our element is the first one
|
|
200
|
+
});
|
|
201
|
+
const childElementRegion = await this._spec.getElementRegion(this.driver.target, childElement.target);
|
|
202
|
+
return {
|
|
203
|
+
...elementRegion,
|
|
204
|
+
height: childElementRegion.y + childElementRegion.height - elementRegion.y,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
else
|
|
208
|
+
return this._spec.getElementRegion(this.driver.target, this.target);
|
|
209
|
+
}
|
|
193
210
|
async getContentSize(options = {}) {
|
|
194
211
|
if (this._state.contentSize)
|
|
195
212
|
return this._state.contentSize;
|
|
@@ -206,22 +223,7 @@ class Element {
|
|
|
206
223
|
this._logger.log('Extracted native content region using helper library', contentRegion);
|
|
207
224
|
// on android extraction of this argument will perform non-deterministic touch action, so it is better to avoid it
|
|
208
225
|
if (!contentRegion || !this.driver.isAndroid) {
|
|
209
|
-
const attrContentRegion = await this.
|
|
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
|
-
});
|
|
226
|
+
const attrContentRegion = await this.getContentSizeFromAttribute();
|
|
225
227
|
this._logger.log('Extracted native content region using attribute', attrContentRegion);
|
|
226
228
|
contentRegion = {
|
|
227
229
|
x: attrContentRegion.x,
|
package/package.json
CHANGED
package/types/driver.d.ts
CHANGED
package/types/element.d.ts
CHANGED
|
@@ -41,6 +41,12 @@ export declare class Element<TDriver, TContext, TElement, TSelector> {
|
|
|
41
41
|
init(context: Context<TDriver, TContext, TElement, TSelector>): Promise<this>;
|
|
42
42
|
getRegion(): Promise<Region>;
|
|
43
43
|
getClientRegion(): Promise<Region>;
|
|
44
|
+
getContentSizeFromAttribute(): Promise<{
|
|
45
|
+
x: any;
|
|
46
|
+
y: any;
|
|
47
|
+
width: any;
|
|
48
|
+
height: any;
|
|
49
|
+
}>;
|
|
44
50
|
getContentSize(options?: {
|
|
45
51
|
lazyLoad?: {
|
|
46
52
|
scrollLength?: number;
|