@applitools/driver
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -7,6 +7,6 @@ { | ||
"version": "file:../dry-run.tgz", | ||
"integrity": "sha512-L6QdrdfYt83pLxx2I95vV9H5phxk9LGc4ZUwVeEJFwJPOy5mZImqRtf+5jWXLEfOCPIft88wB6kl3fHMZhLWFg==", | ||
"integrity": "sha512-zP61GG1Y0dMNnYoY0okAsgbhj7feytzyQvr/D4RqhnYuCqeLXUjasGRqW2rPQGdXJSbJtYc5YgUvKAnYJ3EDeA==", | ||
"requires": { | ||
"@applitools/snippets": "2.1.4", | ||
"@applitools/types": "1.0.6", | ||
"@applitools/types": "1.0.8", | ||
"@applitools/utils": "1.2.2" | ||
@@ -21,5 +21,5 @@ } | ||
"@applitools/types": { | ||
"version": "1.0.6", | ||
"resolved": "https://registry.npmjs.org/@applitools/types/-/types-1.0.6.tgz", | ||
"integrity": "sha512-g0dC0+l8lPVsdblloVSX26rFTt6t3RAZnf5G0hZtjPDjT89oICtPytGRNmSqG7Sm1+DhywmEwtL+07ZzWE9uXw==" | ||
"version": "1.0.8", | ||
"resolved": "https://registry.npmjs.org/@applitools/types/-/types-1.0.8.tgz", | ||
"integrity": "sha512-JypIIWukLRHe0lg5gB1anW1OHNOeZFVDujvHfETvgbXw4HZC4Q1DcStH9yBzJtJiNPY9s15nPuhZ3CmTEUddsA==" | ||
}, | ||
@@ -26,0 +26,0 @@ "@applitools/utils": { |
@@ -6,2 +6,9 @@ # Change Log | ||
## 1.1.3 - 2021/8/13 | ||
- add `statusBarHeight` getter to the driver | ||
- handle base64 screenshots with line breaks | ||
- handle iOS issue with returning actual scroll position after scrolling | ||
- updated to @applitools/types@1.0.8 (from 1.0.6) | ||
## 1.1.2 - 2021/8/8 | ||
@@ -8,0 +15,0 @@ |
@@ -87,2 +87,10 @@ "use strict"; | ||
} | ||
get statusBarHeight() { | ||
var _a; | ||
return (_a = this._driverInfo.statusBarHeight) !== null && _a !== void 0 ? _a : (this.isNative ? 0 : undefined); | ||
} | ||
get navigationBarHeight() { | ||
var _a; | ||
return (_a = this._driverInfo.navigationBarHeight) !== null && _a !== void 0 ? _a : (this.isNative ? 0 : undefined); | ||
} | ||
get isNative() { | ||
@@ -124,2 +132,15 @@ var _a, _b; | ||
} | ||
else { | ||
if (this.isAndroid) { | ||
this._driverInfo.statusBarHeight = this._driverInfo.statusBarHeight / this.pixelRatio; | ||
this._driverInfo.navigationBarHeight = this._driverInfo.navigationBarHeight / this.pixelRatio; | ||
} | ||
if (!this._driverInfo.viewportSize) { | ||
const displaySize = await this.getDisplaySize(); | ||
this._driverInfo.viewportSize = { | ||
width: displaySize.width, | ||
height: displaySize.height - this._driverInfo.statusBarHeight, | ||
}; | ||
} | ||
} | ||
this._logger.log('Driver initialized', this._driverInfo); | ||
@@ -286,9 +307,6 @@ return this; | ||
async normalizeRegion(region) { | ||
if (!this._driverInfo.viewportRegion || !this.isNative) | ||
if (this.isWeb || !utils.types.has(this._driverInfo, ['viewportSize', 'statusBarHeight'])) | ||
return region; | ||
const viewportRegion = this.isIOS | ||
? utils.geometry.scale(this._driverInfo.viewportRegion, 1 / this.pixelRatio) | ||
: this._driverInfo.viewportRegion; | ||
const offsetRegion = utils.geometry.offsetNegative(region, utils.geometry.location(viewportRegion)); | ||
return this.isAndroid ? utils.geometry.scale(offsetRegion, 1 / this.pixelRatio) : offsetRegion; | ||
const scaledRegion = this.isAndroid ? utils.geometry.scale(region, 1 / this.pixelRatio) : region; | ||
return utils.geometry.offsetNegative(scaledRegion, { x: 0, y: this.statusBarHeight }); | ||
} | ||
@@ -309,3 +327,4 @@ async getRegionInViewport(context, region) { | ||
async takeScreenshot() { | ||
return this._spec.takeScreenshot(this.target); | ||
const data = await this._spec.takeScreenshot(this.target); | ||
return utils.types.isString(data) ? data.replace(/[\r\n]+/g, '') : data; | ||
} | ||
@@ -317,7 +336,7 @@ async getViewportSize() { | ||
this._logger.log('Extracting viewport size from native driver'); | ||
if ((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.viewportRegion) { | ||
size = utils.geometry.scale(utils.geometry.size(this._driverInfo.viewportRegion), 1 / this.pixelRatio); | ||
if ((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.viewportSize) { | ||
size = this._driverInfo.viewportSize; | ||
} | ||
else { | ||
size = await this._spec.getWindowSize(this.target); | ||
size = await this.getDisplaySize(); | ||
if (size.height > size.width) { | ||
@@ -378,3 +397,3 @@ const orientation = await this.getOrientation(); | ||
const size = await this._spec.getWindowSize(this.target); | ||
return utils.geometry.scale(size, 1 / this.pixelRatio); | ||
return this.isAndroid ? utils.geometry.scale(size, 1 / this.pixelRatio) : size; | ||
} | ||
@@ -381,0 +400,0 @@ async getOrientation() { |
@@ -287,3 +287,7 @@ "use strict"; | ||
if (this.driver.isWeb) { | ||
return this.context.execute(snippets.scrollTo, [this, offset]); | ||
let actualOffset = await this.context.execute(snippets.scrollTo, [this, offset]); | ||
// iOS has an issue when scroll offset is read immediately after it is been set it will always return the exact value that was set | ||
if (this.driver.isIOS) | ||
actualOffset = await this.getScrollOffset(); | ||
return actualOffset; | ||
} | ||
@@ -290,0 +294,0 @@ else { |
{ | ||
"name": "@applitools/driver", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Applitools universal framework wrapper", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
"@applitools/snippets": "2.1.4", | ||
"@applitools/types": "1.0.6", | ||
"@applitools/types": "1.0.8", | ||
"@applitools/utils": "1.2.2" | ||
@@ -51,0 +51,0 @@ }, |
@@ -76,2 +76,8 @@ import type * as types from '@applitools/types' | ||
} | ||
get statusBarHeight() { | ||
return this._driverInfo.statusBarHeight ?? (this.isNative ? 0 : undefined) | ||
} | ||
get navigationBarHeight() { | ||
return this._driverInfo.navigationBarHeight ?? (this.isNative ? 0 : undefined) | ||
} | ||
get isNative(): boolean { | ||
@@ -120,2 +126,15 @@ return this._driverInfo?.isNative ?? false | ||
} | ||
} else { | ||
if (this.isAndroid) { | ||
this._driverInfo.statusBarHeight = this._driverInfo.statusBarHeight / this.pixelRatio | ||
this._driverInfo.navigationBarHeight = this._driverInfo.navigationBarHeight / this.pixelRatio | ||
} | ||
if (!this._driverInfo.viewportSize) { | ||
const displaySize = await this.getDisplaySize() | ||
this._driverInfo.viewportSize = { | ||
width: displaySize.width, | ||
height: displaySize.height - this._driverInfo.statusBarHeight, | ||
} | ||
} | ||
} | ||
@@ -298,10 +317,5 @@ | ||
async normalizeRegion(region: types.Region): Promise<types.Region> { | ||
if (!this._driverInfo.viewportRegion || !this.isNative) return region | ||
const viewportRegion = this.isIOS | ||
? utils.geometry.scale(this._driverInfo.viewportRegion, 1 / this.pixelRatio) | ||
: this._driverInfo.viewportRegion | ||
const offsetRegion = utils.geometry.offsetNegative(region, utils.geometry.location(viewportRegion)) | ||
return this.isAndroid ? utils.geometry.scale(offsetRegion, 1 / this.pixelRatio) : offsetRegion | ||
if (this.isWeb || !utils.types.has(this._driverInfo, ['viewportSize', 'statusBarHeight'])) return region | ||
const scaledRegion = this.isAndroid ? utils.geometry.scale(region, 1 / this.pixelRatio) : region | ||
return utils.geometry.offsetNegative(scaledRegion, {x: 0, y: this.statusBarHeight}) | ||
} | ||
@@ -330,3 +344,4 @@ | ||
async takeScreenshot(): Promise<Buffer | string> { | ||
return this._spec.takeScreenshot(this.target) | ||
const data = await this._spec.takeScreenshot(this.target) | ||
return utils.types.isString(data) ? data.replace(/[\r\n]+/g, '') : data | ||
} | ||
@@ -338,6 +353,6 @@ | ||
this._logger.log('Extracting viewport size from native driver') | ||
if (this._driverInfo?.viewportRegion) { | ||
size = utils.geometry.scale(utils.geometry.size(this._driverInfo.viewportRegion), 1 / this.pixelRatio) | ||
if (this._driverInfo?.viewportSize) { | ||
size = this._driverInfo.viewportSize | ||
} else { | ||
size = await this._spec.getWindowSize(this.target) | ||
size = await this.getDisplaySize() | ||
if (size.height > size.width) { | ||
@@ -401,3 +416,3 @@ const orientation = await this.getOrientation() | ||
const size = await this._spec.getWindowSize(this.target) | ||
return utils.geometry.scale(size, 1 / this.pixelRatio) | ||
return this.isAndroid ? utils.geometry.scale(size, 1 / this.pixelRatio) : size | ||
} | ||
@@ -404,0 +419,0 @@ |
@@ -302,3 +302,6 @@ import type * as types from '@applitools/types' | ||
if (this.driver.isWeb) { | ||
return this.context.execute(snippets.scrollTo, [this, offset]) | ||
let actualOffset = await this.context.execute(snippets.scrollTo, [this, offset]) | ||
// iOS has an issue when scroll offset is read immediately after it is been set it will always return the exact value that was set | ||
if (this.driver.isIOS) actualOffset = await this.getScrollOffset() | ||
return actualOffset | ||
} else { | ||
@@ -305,0 +308,0 @@ const currentScrollOffset = await this.getScrollOffset() |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
225728
4052
1
+ Added@applitools/types@1.0.8(transitive)
- Removed@applitools/types@1.0.6(transitive)
Updated@applitools/types@1.0.8