From 89ddf24fd442889719c45987322b170f8068b7b8 Mon Sep 17 00:00:00 2001 From: Pankaj Yadav Date: Tue, 5 Sep 2023 16:31:43 +0530 Subject: [PATCH 1/6] Fix Status bar height and update test (#166) --- percy/providers/appAutomateProvider.js | 6 +++--- test/percy/providers/appAutomateProvider.test.mjs | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/percy/providers/appAutomateProvider.js b/percy/providers/appAutomateProvider.js index a547fb9..8e03c89 100644 --- a/percy/providers/appAutomateProvider.js +++ b/percy/providers/appAutomateProvider.js @@ -148,9 +148,9 @@ class AppAutomateProvider extends GenericProvider { JSON.parse(response.result).forEach(tileData => { tiles.push(new Tile({ - statBarHeight, - navBarHeight, - fullscreen, + statusBarHeight: statBarHeight, + navBarHeight: navBarHeight, + fullscreen: fullscreen, headerHeight: tileData.header_height, footerHeight: tileData.footer_height, sha: tileData.sha.split('-')[0] // drop build id diff --git a/test/percy/providers/appAutomateProvider.test.mjs b/test/percy/providers/appAutomateProvider.test.mjs index c7a3124..4a51322 100644 --- a/test/percy/providers/appAutomateProvider.test.mjs +++ b/test/percy/providers/appAutomateProvider.test.mjs @@ -153,7 +153,9 @@ describe('AppAutomateProvider', () => { args['options']['deviceHeight'] = screenSize['height']; appAutomate.metadata = { statusBarHeight: () => 100, navigationBarHeight: () => 200, scaleFactor: () => 1, screenSize: () => screenSize }; - await appAutomate.getTiles(true, false, null, null, null); + let tiles = await appAutomate.getTiles(true, false, null, null, null); + expect(tiles[0].statusBarHeight).toEqual(100); + expect(tiles[0].navBarHeight).toEqual(200); expect(browserstack_executorSpy).toHaveBeenCalledWith('percyScreenshot', args); }); }); From bd036ef6fb7403a874616bb29a68ce4a21b2d5b3 Mon Sep 17 00:00:00 2001 From: amit3200 Date: Tue, 5 Sep 2023 17:22:39 +0530 Subject: [PATCH 2/6] :bookmark: Release v2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c686fe4..18305fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@percy/appium-app", "description": "Appium client library for visual testing with Percy", - "version": "2.0.0-beta.2", + "version": "2.0.0", "license": "MIT", "author": "Perceptual Inc.", "repository": { From 23c0014c3150420dc683bf2346d411cec0209636 Mon Sep 17 00:00:00 2001 From: amit3200 Date: Tue, 5 Sep 2023 17:30:16 +0530 Subject: [PATCH 3/6] Updating latest tag --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 18305fe..5064617 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "publishConfig": { "access": "public", - "tag": "beta" + "tag": "latest" }, "scripts": { "lint": "eslint --ignore-path .gitignore .", From f63729443c4d115ba4ec26e7f51d8b4d6cd7adb2 Mon Sep 17 00:00:00 2001 From: Pankaj Yadav Date: Mon, 11 Sep 2023 14:46:13 +0530 Subject: [PATCH 4/6] update rspecs (#169) --- README.md | 3 +++ index.js | 6 ++++++ percy/providers/appAutomateProvider.js | 8 +++++++- test/percy/providers/appAutomateProvider.test.mjs | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 10f1311..541f83f 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,9 @@ percyScreenshot(driver, name[, { - `statusBarHeight`: In px if you want to override SDK - `navigationBarHeight`: In px if you want to override SDK - `fullPage`: true/false. [Experimental] only supported on App Automate driver sessions + - In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling: + - `topScrollviewOffset`: (**optional**) - [Experimental] offset from top of scrollview [ needs @percy/cli 1.20.2+ ]; int + - `bottomScrollviewOffset` (**optional**) - [Experimental] offset from bottom of scrollview [ needs @percy/cli 1.20.2+ ]; int - `screenLengths`: int [Experimental] max screen lengths for fullPage - `scrollableXpath` (**optional**) - [Experimental] scrollable element xpath for fullpage; string - `scrollableId` (**optional**) - [Experimental] scrollable element accessibility id for fullpage; string diff --git a/index.js b/index.js index 314bfad..a9c394b 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,8 @@ module.exports = async function percyScreenshot(driver, name, options = {}) { considerRegionAppiumElements, customConsiderRegions, scrollableXpath, + topScrollviewOffset, + bottomScrollviewOffset, scrollableId } = options; // allow working with or without standalone mode for wdio @@ -48,6 +50,8 @@ module.exports = async function percyScreenshot(driver, name, options = {}) { considerRegionAppiumElements = name.considerRegionAppiumElements; customConsiderRegions = name.customConsiderRegions; scrollableXpath = name.scrollableXpath; + topScrollviewOffset = name.topScrollviewOffset; + bottomScrollviewOffset = name.bottomScrollviewOffset; scrollableId = name.scrollableId; options = name; } @@ -92,6 +96,8 @@ module.exports = async function percyScreenshot(driver, name, options = {}) { considerRegionAppiumElements, customConsiderRegions, scrollableXpath, + topScrollviewOffset, + bottomScrollviewOffset, scrollableId }); log.debug(`[${name}] -> end`); diff --git a/percy/providers/appAutomateProvider.js b/percy/providers/appAutomateProvider.js index 8e03c89..5b7c098 100644 --- a/percy/providers/appAutomateProvider.js +++ b/percy/providers/appAutomateProvider.js @@ -31,6 +31,8 @@ class AppAutomateProvider extends GenericProvider { considerRegionAppiumElements, customConsiderRegions, scrollableXpath, + topScrollviewOffset, + bottomScrollviewOffset, scrollableId } = {}) { let response = null; @@ -56,6 +58,8 @@ class AppAutomateProvider extends GenericProvider { considerRegionAppiumElements, customConsiderRegions, scrollableXpath, + topScrollviewOffset, + bottomScrollviewOffset, scrollableId }); } catch (e) { @@ -102,7 +106,7 @@ class AppAutomateProvider extends GenericProvider { } // Override this for AA specific optimizations - async getTiles(fullscreen, fullPage, screenLengths, scrollableXpath, scrollableId) { + async getTiles(fullscreen, fullPage, screenLengths, scrollableXpath, topScrollviewOffset, bottomScrollviewOffset, scrollableId) { // Override AA optimizations if (this.isDisableRemoteUpload()) { if (fullPage === true) { @@ -131,6 +135,8 @@ class AppAutomateProvider extends GenericProvider { numOfTiles: screenLengths || 4, deviceHeight: (await this.metadata.screenSize()).height, scollableXpath: scrollableXpath || null, + topScrollviewOffset: topScrollviewOffset || 0, + bottomScrollviewOffset: bottomScrollviewOffset || 0, scrollableId: scrollableId || null, FORCE_FULL_PAGE: process.env.FORCE_FULL_PAGE === 'true' } diff --git a/test/percy/providers/appAutomateProvider.test.mjs b/test/percy/providers/appAutomateProvider.test.mjs index 4a51322..37c7633 100644 --- a/test/percy/providers/appAutomateProvider.test.mjs +++ b/test/percy/providers/appAutomateProvider.test.mjs @@ -151,6 +151,8 @@ describe('AppAutomateProvider', () => { height: 2000, }; args['options']['deviceHeight'] = screenSize['height']; + args['options']['topScrollviewOffset'] = 0; + args['options']['bottomScrollviewOffset'] = 0; appAutomate.metadata = { statusBarHeight: () => 100, navigationBarHeight: () => 200, scaleFactor: () => 1, screenSize: () => screenSize }; let tiles = await appAutomate.getTiles(true, false, null, null, null); @@ -216,6 +218,8 @@ describe('AppAutomateProvider', () => { }; args['projectId'] = 'percy-dev'; args['options']['deviceHeight'] = screenSize['height']; + args['options']['topScrollviewOffset'] = 0; + args['options']['bottomScrollviewOffset'] = 0; args['screenshotType'] = 'fullpage'; appAutomate.metadata = { statusBarHeight: () => 100, navigationBarHeight: () => 200, scaleFactor: () => 1, screenSize: () => screenSize }; From b033bb3966a2408fe78efa24b016a324ee368243 Mon Sep 17 00:00:00 2001 From: Pankaj Yadav Date: Mon, 11 Sep 2023 15:37:17 +0530 Subject: [PATCH 5/6] Version bump to 2.0.1 (#170) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5064617..aeb939a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@percy/appium-app", "description": "Appium client library for visual testing with Percy", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT", "author": "Perceptual Inc.", "repository": { From e36c9b2ab60ab28d28166b9eca5925f08cf7993b Mon Sep 17 00:00:00 2001 From: Pankaj Yadav Date: Wed, 20 Sep 2023 16:17:23 +0530 Subject: [PATCH 6/6] Update readme for options (#176) * Update readme for options * Update readme for options * Update readme for options * replace experminal to alpha --- README.md | 66 +++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 541f83f..af831f6 100644 --- a/README.md +++ b/README.md @@ -72,39 +72,33 @@ percyScreenshot(driver, name[, { - `driver` (**required**) - A appium driver instance [ can be skipped in case of webdriverio runner] - `name` (**required**) - The screenshot name; must be unique to each screenshot - `options object` (**optional**) - - `fullscreen`: if the app is currently in fullscreen - - `deviceName`: custom device name to override SDK fetched name - - `orientation`: "portrait"/"landscape" tell SDK which orientation app is in [ Note: This is only for tagging purpose, does not change the orientation of the device ] - - `statusBarHeight`: In px if you want to override SDK - - `navigationBarHeight`: In px if you want to override SDK - - `fullPage`: true/false. [Experimental] only supported on App Automate driver sessions - - In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling: - - `topScrollviewOffset`: (**optional**) - [Experimental] offset from top of scrollview [ needs @percy/cli 1.20.2+ ]; int - - `bottomScrollviewOffset` (**optional**) - [Experimental] offset from bottom of scrollview [ needs @percy/cli 1.20.2+ ]; int - - `screenLengths`: int [Experimental] max screen lengths for fullPage - - `scrollableXpath` (**optional**) - [Experimental] scrollable element xpath for fullpage; string - - `scrollableId` (**optional**) - [Experimental] scrollable element accessibility id for fullpage; string - - `ignoreRegionXpaths` (**optional**) - elements xpaths that user want to ignore in visual diff; list of string - - `ignoreRegionAccessibilityIds` (**optional**) - elements accessibility_ids that user want to ignore in visual diff; list of string - - `ignoreRegionAppiumElements` (**optional**) - appium elements that user want to ignore in visual diff; list of appium element object - - `customIgnoreRegions` (**optional**) - custom locations that user want to ignore in visual diff; list of ignore_region object + - `fullscreen`: If the app is currently in fullscreen; boolean + - `deviceName`: Custom device name to override SDK fetched name + - `orientation`: ["portrait"/"landscape"] - Tell SDK which orientation app is in [ Note: This is only for tagging purpose, does not change the orientation of the device ] + - `statusBarHeight`: In px if you want to override SDK; int + - `navigationBarHeight`: In px if you want to override SDK; int + - `fullPage`: [Alpha] Only supported on App Automate driver sessions [ needs @percy/cli 1.20.2+ ]; boolean + - `screenLengths`: [Alpha] Max screen lengths for fullPage; int + - In case scrollview is overlapping with other app elements. Offsets can be provided to reduce the area which needs to be considered for scrolling: + - `topScrollviewOffset`: [Alpha] Offset from top of scrollview; int + - `bottomScrollviewOffset`: [Alpha] Offset from bottom of scrollview; int + - `scrollableXpath` [Alpha] Scrollable element xpath for fullpage; string + - `scrollableId`: [Alpha] Scrollable element accessibility id for fullpage; string + - `ignoreRegionXpaths`: Elements xpaths that user want to ignore in visual diff; list of string + - `ignoreRegionAccessibilityIds`: Elements accessibility_ids that user want to ignore in visual diff; list of string + - `ignoreRegionAppiumElements`: Appium elements that user want to ignore in visual diff; list of appium element object + - `customIgnoreRegions`: Custom locations that user want to ignore in visual diff; list of ignore_region object - IgnoreRegion:- - Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff. - - Constructor: ``` constructor(top, bottom, left, right) ``` - - Parameters: - - `top` (int): Top coordinate of the ignore region. - `bottom` (int): Bottom coordinate of the ignore region. - `left` (int): Left coordinate of the ignore region. - `right` (int): Right coordinate of the ignore region. - - Raises:Error: If top, bottom, left, or right is less than 0 or top is greater than or equal to bottom or left is greater than or equal to right. - - valid: Ignore region should be within the boundaries of the screen. - + - `top` (int): Top coordinate of the ignore region. + - `bottom` (int): Bottom coordinate of the ignore region. + - `left` (int): Left coordinate of the ignore region. + - `right` (int): Right coordinate of the ignore region. ## Running with Hybrid Apps For a hybrid app, we need to switch to native context before taking screenshot. @@ -143,25 +137,21 @@ await percyScreenshotFlutter(driver, name[, { - `options` (**optional**) - There are various options supported by percy_screenshot to server further functionality. - `freezeAnimation` - Boolean value by default it falls back to `false`, you can pass `true` and percy will freeze image based animations. - `percyCSS` - Custom CSS to be added to DOM before the screenshot being taken. Note: This gets removed once the screenshot is taken. - - `ignoreRegionXpaths` - elements in the DOM can be ignored using xpath - - `ignoreRegionSelectors` - elements in the DOM can be ignored using selectors. - - `ignoreRegionAppiumElements` - elements can be ignored using appium_elements. - - `customIgnoreRegions` - elements can be ignored using custom boundaries + - `ignoreRegionXpaths` - Elements in the DOM can be ignored using xpath + - `ignoreRegionSelectors` - Elements in the DOM can be ignored using selectors. + - `ignoreRegionAppiumElements` - Elements can be ignored using appium_elements. + - `customIgnoreRegions` - Elements can be ignored using custom boundaries - IgnoreRegion:- - Description: This class represents a rectangular area on a screen that needs to be ignored for visual diff. - - Constructor: ``` init(self, top, bottom, left, right) ``` - Parameters: - `top` (int): Top coordinate of the ignore region. - `bottom` (int): Bottom coordinate of the ignore region. - `left` (int): Left coordinate of the ignore region. - `right` (int): Right coordinate of the ignore region. - - Raises:ValueError: If top, bottom, left, or right is less than 0 or top is greater than or equal to bottom or left is greater than or equal to right. - - valid: Ignore region should be within the boundaries of the screen. - + - `top` (int): Top coordinate of the ignore region. + - `bottom` (int): Bottom coordinate of the ignore region. + - `left` (int): Left coordinate of the ignore region. + - `right` (int): Right coordinate of the ignore region. ### Creating Percy on automate build Note: Automate Percy Token starts with `auto` keyword. The command can be triggered using `exec` keyword. ```sh-session