@applitools/driver
Advanced tools
Comparing version 1.10.6 to 1.10.7
@@ -155,4 +155,4 @@ "use strict"; | ||
async init() { | ||
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; | ||
var _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; | ||
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; | ||
var _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18; | ||
// NOTE: this is here because saucelabs does not provide right capabilities for the first call | ||
@@ -172,5 +172,5 @@ await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target)); | ||
if (this.isWeb) { | ||
(_h = (_6 = this._driverInfo).pixelRatio) !== null && _h !== void 0 ? _h : (_6.pixelRatio = await this.execute(snippets.getPixelRatio)); | ||
(_j = (_7 = this._driverInfo).viewportScale) !== null && _j !== void 0 ? _j : (_7.viewportScale = await this.execute(snippets.getViewportScale)); | ||
(_k = (_8 = this._driverInfo).userAgent) !== null && _k !== void 0 ? _k : (_8.userAgent = await this.execute(snippets.getUserAgent)); | ||
(_h = (_7 = this._driverInfo).pixelRatio) !== null && _h !== void 0 ? _h : (_7.pixelRatio = await this.execute(snippets.getPixelRatio)); | ||
(_j = (_8 = this._driverInfo).viewportScale) !== null && _j !== void 0 ? _j : (_8.viewportScale = await this.execute(snippets.getViewportScale)); | ||
(_k = (_9 = this._driverInfo).userAgent) !== null && _k !== void 0 ? _k : (_9.userAgent = await this.execute(snippets.getUserAgent)); | ||
if (this._driverInfo.userAgent) { | ||
@@ -181,4 +181,4 @@ const userAgentInfo = (0, user_agent_1.parseUserAgent)(this._driverInfo.userAgent); | ||
if (this._driverInfo.isMobile) { | ||
(_o = (_9 = this._driverInfo).platformName) !== null && _o !== void 0 ? _o : (_9.platformName = userAgentInfo.platformName); | ||
(_p = (_10 = this._driverInfo).platformVersion) !== null && _p !== void 0 ? _p : (_10.platformVersion = userAgentInfo.platformVersion); | ||
(_o = (_10 = this._driverInfo).platformName) !== null && _o !== void 0 ? _o : (_10.platformName = userAgentInfo.platformName); | ||
(_p = (_11 = this._driverInfo).platformVersion) !== null && _p !== void 0 ? _p : (_11.platformVersion = userAgentInfo.platformVersion); | ||
} | ||
@@ -194,4 +194,4 @@ else { | ||
} | ||
(_s = (_11 = this._driverInfo).features) !== null && _s !== void 0 ? _s : (_11.features = {}); | ||
(_t = (_12 = this._driverInfo.features).allCookies) !== null && _t !== void 0 ? _t : (_12.allCookies = this._driverInfo.isChrome || (/chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile)); | ||
(_s = (_12 = this._driverInfo).features) !== null && _s !== void 0 ? _s : (_12.features = {}); | ||
(_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)); | ||
} | ||
@@ -201,3 +201,3 @@ else { | ||
let windowSize = await this._spec.getWindowSize(this.target); | ||
(_u = (_13 = this._driverInfo).displaySize) !== null && _u !== void 0 ? _u : (_13.displaySize = windowSize); | ||
(_u = (_14 = this._driverInfo).displaySize) !== null && _u !== void 0 ? _u : (_14.displaySize = windowSize); | ||
if (((_v = this.orientation) === null || _v === void 0 ? void 0 : _v.startsWith('landscape')) && | ||
@@ -239,6 +239,6 @@ this._driverInfo.displaySize.height > this._driverInfo.displaySize.width) { | ||
// bar sizes have to be scaled on android | ||
(_14 = this._driverInfo).statusBarSize && (_14.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio); | ||
(_15 = this._driverInfo).navigationBarSize && (_15.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio); | ||
(_15 = this._driverInfo).statusBarSize && (_15.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio); | ||
(_16 = this._driverInfo).navigationBarSize && (_16.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio); | ||
windowSize = utils.geometry.scale(windowSize, 1 / this.pixelRatio); | ||
(_16 = this._driverInfo).displaySize && (_16.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio)); | ||
(_17 = this._driverInfo).displaySize && (_17.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio)); | ||
} | ||
@@ -250,3 +250,3 @@ if (this.isIOS) { | ||
// calculate viewport location | ||
(_3 = (_17 = this._driverInfo).viewportLocation) !== null && _3 !== void 0 ? _3 : (_17.viewportLocation = { | ||
(_3 = (_18 = this._driverInfo).viewportLocation) !== null && _3 !== void 0 ? _3 : (_18.viewportLocation = { | ||
x: this.orientation === 'landscape' ? this.navigationBarSize : 0, | ||
@@ -288,2 +288,3 @@ y: this.statusBarSize, | ||
} | ||
this._logger.log(`Helper set to ${(_6 = this._helper) === null || _6 === void 0 ? void 0 : _6.name}`); | ||
} | ||
@@ -290,0 +291,0 @@ this._logger.log('Combined driver info', this._driverInfo); |
@@ -113,18 +113,3 @@ "use strict"; | ||
if (!contentRegion || !this.driver.isAndroid) { | ||
const nativeContentRegion = await this.getAttribute('contentSize') | ||
.then(data => { | ||
const contentSize = JSON.parse(data); | ||
return { | ||
x: contentSize.left, | ||
y: contentSize.top, | ||
width: contentSize.width, | ||
height: this.driver.isIOS | ||
? Math.max(contentSize.height, contentSize.scrollableOffset) | ||
: contentSize.height + contentSize.scrollableOffset, | ||
}; | ||
}) | ||
.catch(err => { | ||
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`); | ||
return this._spec.getElementRegion(this.driver.target, this.target); | ||
}); | ||
const nativeContentRegion = await this.getContentSizeFromAttribute(); | ||
contentRegion = { | ||
@@ -194,2 +179,34 @@ x: nativeContentRegion.x, | ||
} | ||
async getContentSizeFromAttribute() { | ||
try { | ||
const data = await this.getAttribute('contentSize'); | ||
const contentSize = JSON.parse(data); | ||
return { | ||
x: contentSize.left, | ||
y: contentSize.top, | ||
width: contentSize.width, | ||
height: this.driver.isIOS | ||
? Math.max(contentSize.height, contentSize.scrollableOffset) | ||
: contentSize.height + contentSize.scrollableOffset, | ||
}; | ||
} | ||
catch (err) { | ||
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`); | ||
} | ||
const type = await this.getAttribute('type'); | ||
if (type === 'XCUIElementTypeScrollView') { | ||
const elementRegion = await this._spec.getElementRegion(this.driver.target, this.target); | ||
const [childElement] = await this.driver.elements({ | ||
type: 'xpath', | ||
selector: '//XCUIElementTypeScrollView[1]/*', // We cannot be sure that our element is the first one | ||
}); | ||
const childElementRegion = await this._spec.getElementRegion(this.driver.target, childElement.target); | ||
return { | ||
...elementRegion, | ||
height: childElementRegion.y + childElementRegion.height - elementRegion.y, | ||
}; | ||
} | ||
else | ||
return this._spec.getElementRegion(this.driver.target, this.target); | ||
} | ||
async getContentSize(options = {}) { | ||
@@ -211,18 +228,3 @@ if (this._state.contentSize) | ||
if (!contentRegion || !this.driver.isAndroid) { | ||
const attrContentRegion = await this.getAttribute('contentSize') | ||
.then(data => { | ||
const contentSize = JSON.parse(data); | ||
return { | ||
x: contentSize.left, | ||
y: contentSize.top, | ||
width: contentSize.width, | ||
height: this.driver.isIOS | ||
? Math.max(contentSize.height, contentSize.scrollableOffset) | ||
: contentSize.height + contentSize.scrollableOffset, | ||
}; | ||
}) | ||
.catch(err => { | ||
this._logger.warn(`Unable to get the attribute 'contentSize' due to the following error: '${err.message}'`); | ||
return this._spec.getElementRegion(this.driver.target, this.target); | ||
}); | ||
const attrContentRegion = await this.getContentSizeFromAttribute(); | ||
this._logger.log('Extracted native content region using attribute', attrContentRegion); | ||
@@ -229,0 +231,0 @@ contentRegion = { |
{ | ||
"name": "@applitools/driver", | ||
"version": "1.10.6", | ||
"version": "1.10.7", | ||
"description": "Applitools universal framework wrapper", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -44,2 +44,8 @@ import type { Location, Size, Region } from '@applitools/utils'; | ||
getClientRegion(): Promise<Region>; | ||
getContentSizeFromAttribute(): Promise<{ | ||
x: any; | ||
y: any; | ||
width: any; | ||
height: any; | ||
}>; | ||
getContentSize(options?: { | ||
@@ -46,0 +52,0 @@ lazyLoad?: { |
3753
230914