@applitools/driver
Advanced tools
Comparing version 1.9.3 to 1.9.4
@@ -281,2 +281,3 @@ "use strict"; | ||
async getTouchPadding() { | ||
var _a, _b; | ||
if (this._state.touchPadding == null) { | ||
@@ -288,8 +289,13 @@ if (this.driver.isWeb) | ||
else if (this.driver.isAndroid) { | ||
const touchPadding = await this.getAttribute('contentSize') | ||
.then(data => JSON.parse(data).touchPadding) | ||
.catch(err => { | ||
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`); | ||
}); | ||
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding : 21; | ||
if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android') { | ||
this._state.touchPadding = await ((_b = this.driver.helper) === null || _b === void 0 ? void 0 : _b.getTouchPadding()); | ||
} | ||
else { | ||
const touchPadding = await this.getAttribute('contentSize') | ||
.then(data => JSON.parse(data).touchPadding) | ||
.catch(err => { | ||
this._logger.warn(`Unable to get the attribute 'contentSize' when looking up 'touchPadding' due to the following error: '${err.message}'`); | ||
}); | ||
this._state.touchPadding = touchPadding !== null && touchPadding !== void 0 ? touchPadding : 20; | ||
} | ||
this._logger.log('Touch padding set:', this._state.touchPadding); | ||
@@ -360,2 +366,3 @@ } | ||
return this.withRefresh(async () => { | ||
var _a; | ||
offset = utils.geometry.round({ x: Math.max(offset.x, 0), y: Math.max(offset.y, 0) }); | ||
@@ -380,2 +387,7 @@ if (this.driver.isWeb) { | ||
const requiredOffset = { x: Math.min(offset.x, maxOffset.x), y: Math.min(offset.y, maxOffset.y) }; | ||
if (((_a = this.driver.helper) === null || _a === void 0 ? void 0 : _a.name) === 'android' && utils.geometry.equals(requiredOffset, { x: 0, y: 0 })) { | ||
await this.driver.helper.scrollToTop(this); | ||
this._state.scrollOffset = requiredOffset; | ||
return this._state.scrollOffset; | ||
} | ||
let effectiveRegion = scrollableRegion; | ||
@@ -386,8 +398,9 @@ let remainingOffset = utils.geometry.equals(requiredOffset, { x: 0, y: 0 }) | ||
if (this.driver.isAndroid) { | ||
remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio); | ||
effectiveRegion = utils.geometry.scale(effectiveRegion, this.driver.pixelRatio); | ||
remainingOffset = utils.geometry.round(utils.geometry.scale(remainingOffset, this.driver.pixelRatio)); | ||
effectiveRegion = utils.geometry.round(utils.geometry.scale(effectiveRegion, this.driver.pixelRatio)); | ||
} | ||
const actions = []; | ||
const isPager = await this.isPager(); | ||
const touchPadding = await this.getTouchPadding(); | ||
const isPager = await this.isPager(); | ||
// horizontal scrolling | ||
const xPadding = Math.max(Math.floor(effectiveRegion.width * 0.07), touchPadding); | ||
@@ -432,2 +445,3 @@ const yTrack = Math.floor(effectiveRegion.y + effectiveRegion.height / 2); // center | ||
} | ||
// vertical scrolling | ||
const yPadding = Math.max(Math.floor(effectiveRegion.height * 0.07), touchPadding); | ||
@@ -434,0 +448,0 @@ const xTrack = Math.floor(effectiveRegion.x + 5); // a little bit off left border |
@@ -10,2 +10,3 @@ "use strict"; | ||
this._logger = options.logger; | ||
this.name = this._legacy ? 'android-legacy' : 'android'; | ||
} | ||
@@ -68,3 +69,32 @@ static async make(options) { | ||
} | ||
async scrollToTop(element) { | ||
if (this._legacy) | ||
return null; | ||
const elementId = await this._getElementId(element); | ||
if (!elementId) | ||
return null; | ||
await this._element.type(`moveToTop;${elementId};0;0`); | ||
await this._element.click(); | ||
await this._element.type(''); | ||
} | ||
async scrollBy(element, offset) { | ||
if (this._legacy) | ||
return null; | ||
const elementId = await this._getElementId(element); | ||
if (!elementId) | ||
return null; | ||
await this._element.type(`scroll;${elementId};${offset.y};0;0`); | ||
await this._element.click(); | ||
await this._element.type(''); | ||
} | ||
async getTouchPadding() { | ||
if (this._legacy) | ||
return null; | ||
await this._element.type(`getTouchPadding;0;0;0;0`); | ||
await this._element.click(); | ||
const touchPaddingString = await this._element.getText(); | ||
await this._element.type(''); | ||
return Number(touchPaddingString); | ||
} | ||
} | ||
exports.HelperAndroid = HelperAndroid; |
@@ -10,2 +10,3 @@ "use strict"; | ||
this._logger = options.logger; | ||
this.name = 'ios'; | ||
} | ||
@@ -12,0 +13,0 @@ static async make(options) { |
{ | ||
"name": "@applitools/driver", | ||
"version": "1.9.3", | ||
"version": "1.9.4", | ||
"description": "Applitools universal framework wrapper", | ||
@@ -79,6 +79,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@applitools/logger": "1.1.11", | ||
"@applitools/snippets": "2.4.1", | ||
"@applitools/types": "1.5.2", | ||
"@applitools/utils": "1.3.7" | ||
"@applitools/logger": "1.1.12", | ||
"@applitools/snippets": "2.4.2", | ||
"@applitools/types": "1.5.3", | ||
"@applitools/utils": "1.3.8" | ||
}, | ||
@@ -85,0 +85,0 @@ "devDependencies": { |
@@ -15,2 +15,3 @@ import type * as types from '@applitools/types'; | ||
private _logger; | ||
readonly name: 'android' | 'android-legacy'; | ||
constructor(options: { | ||
@@ -25,2 +26,5 @@ spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>; | ||
getRegion(element: Element<TDriver, TContext, TElement, TSelector>): Promise<types.Region>; | ||
scrollToTop(element: Element<TDriver, TContext, TElement, TSelector>): Promise<void>; | ||
scrollBy(element: Element<TDriver, TContext, TElement, TSelector>, offset: types.Location): Promise<void>; | ||
getTouchPadding(): Promise<number>; | ||
} |
@@ -15,2 +15,3 @@ import type * as types from '@applitools/types'; | ||
private _logger; | ||
readonly name: 'ios'; | ||
constructor(options: { | ||
@@ -17,0 +18,0 @@ driver: Driver<TDriver, TContext, TElement, TSelector>; |
207077
3249
+ Added@applitools/logger@1.1.12(transitive)
+ Added@applitools/snippets@2.4.2(transitive)
+ Added@applitools/types@1.5.3(transitive)
+ Added@applitools/utils@1.3.8(transitive)
- Removed@applitools/logger@1.1.11(transitive)
- Removed@applitools/snippets@2.4.1(transitive)
- Removed@applitools/types@1.5.2(transitive)
- Removed@applitools/utils@1.3.7(transitive)
Updated@applitools/logger@1.1.12
Updated@applitools/snippets@2.4.2
Updated@applitools/types@1.5.3
Updated@applitools/utils@1.3.8