@applitools/screenshoter 3.3.4 → 3.3.5

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/package.json +22 -15
  3. package/.bongo/dry-run/package-lock.json +0 -73
  4. package/.bongo/dry-run/package.json +0 -5
  5. package/.bongo/dry-run.tgz +0 -0
  6. package/.eslintrc +0 -39
  7. package/test/e2e/android.spec.js +0 -334
  8. package/test/e2e/external.spec.js +0 -155
  9. package/test/e2e/ios.spec.js +0 -339
  10. package/test/e2e/web-ios.spec.js +0 -107
  11. package/test/e2e/web.spec.js +0 -334
  12. package/test/fixtures/android/app-fully-non-scrollable.png +0 -0
  13. package/test/fixtures/android/app-fully-recycler.png +0 -0
  14. package/test/fixtures/android/app-fully-scroll-statusbar.png +0 -0
  15. package/test/fixtures/android/app-fully-scroll.png +0 -0
  16. package/test/fixtures/android/app-statusbar.png +0 -0
  17. package/test/fixtures/android/app.png +0 -0
  18. package/test/fixtures/android/element.png +0 -0
  19. package/test/fixtures/android/region.png +0 -0
  20. package/test/fixtures/android/x-app-fully-collapsing.png +0 -0
  21. package/test/fixtures/android/x-app-fully-recycler.png +0 -0
  22. package/test/fixtures/android/x-element-fully.png +0 -0
  23. package/test/fixtures/external/agl.png +0 -0
  24. package/test/fixtures/image/house.cropped-rect.png +0 -0
  25. package/test/fixtures/image/house.cropped-region.png +0 -0
  26. package/test/fixtures/image/house.framed-higher-wider.png +0 -0
  27. package/test/fixtures/image/house.framed-higher.png +0 -0
  28. package/test/fixtures/image/house.framed-shorter-thinner.png +0 -0
  29. package/test/fixtures/image/house.framed-wider.png +0 -0
  30. package/test/fixtures/image/house.png +0 -0
  31. package/test/fixtures/image/house.rotated.png +0 -0
  32. package/test/fixtures/image/house.scaled.png +0 -0
  33. package/test/fixtures/image/house.stitched.png +0 -0
  34. package/test/fixtures/ios/app-fully-collapsing.png +0 -0
  35. package/test/fixtures/ios/app-fully-collection.png +0 -0
  36. package/test/fixtures/ios/app-fully-overlapped-statusbar.png +0 -0
  37. package/test/fixtures/ios/app-fully-overlapped.png +0 -0
  38. package/test/fixtures/ios/app-fully-scroll-statusbar.png +0 -0
  39. package/test/fixtures/ios/app-fully-scroll.png +0 -0
  40. package/test/fixtures/ios/app-fully-superview.png +0 -0
  41. package/test/fixtures/ios/app-fully-table.png +0 -0
  42. package/test/fixtures/ios/app-statusbar.png +0 -0
  43. package/test/fixtures/ios/app.png +0 -0
  44. package/test/fixtures/ios/element-fully.png +0 -0
  45. package/test/fixtures/ios/element.png +0 -0
  46. package/test/fixtures/ios/region.png +0 -0
  47. package/test/fixtures/ios/webview-fully.png +0 -0
  48. package/test/fixtures/ios/webview.png +0 -0
  49. package/test/fixtures/pattern/iPad_5th_landscape.png +0 -0
  50. package/test/fixtures/pattern/iPad_5th_portrait.png +0 -0
  51. package/test/fixtures/pattern/iPad_9th_landscape.png +0 -0
  52. package/test/fixtures/pattern/iPad_9th_portrait.png +0 -0
  53. package/test/fixtures/pattern/iPhone_11_landscape.png +0 -0
  54. package/test/fixtures/pattern/iPhone_11_portrait.png +0 -0
  55. package/test/fixtures/pattern/iPhone_13_landscape.png +0 -0
  56. package/test/fixtures/pattern/iPhone_13_portrait.png +0 -0
  57. package/test/fixtures/pattern/iPhone_SE_landscape.png +0 -0
  58. package/test/fixtures/pattern/iPhone_SE_portrait.png +0 -0
  59. package/test/fixtures/pattern/iPhone_XS_portrait_nomarker.png +0 -0
  60. package/test/fixtures/pattern/iPhone_XS_portrait_noviewport.png +0 -0
  61. package/test/fixtures/web/element-fully.png +0 -0
  62. package/test/fixtures/web/element.png +0 -0
  63. package/test/fixtures/web/frame-fully.png +0 -0
  64. package/test/fixtures/web/frame.png +0 -0
  65. package/test/fixtures/web/inner-element-fully.png +0 -0
  66. package/test/fixtures/web/inner-element.png +0 -0
  67. package/test/fixtures/web/inner-frame-fully.png +0 -0
  68. package/test/fixtures/web/inner-frame.png +0 -0
  69. package/test/fixtures/web/inner-region-fully.png +0 -0
  70. package/test/fixtures/web/inner-region.png +0 -0
  71. package/test/fixtures/web/page-fully.png +0 -0
  72. package/test/fixtures/web/page.png +0 -0
  73. package/test/fixtures/web/region-fully.png +0 -0
  74. package/test/fixtures/web/region.png +0 -0
  75. package/test/fixtures/web-ios/page-fully-landscape.png +0 -0
  76. package/test/fixtures/web-ios/page-fully.png +0 -0
  77. package/test/fixtures/web-ios/page-landscape.png +0 -0
  78. package/test/fixtures/web-ios/page.png +0 -0
  79. package/test/it/find-pattern.spec.js +0 -33
  80. package/test/it/image.spec.js +0 -146
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
  ## Unreleased
5
5
 
6
6
 
7
+ ## 3.3.5 - 2022/2/8
8
+
9
+ - add "files" field to the package.json to avoid unnecessary files to be published
10
+ - updated to @applitools/utils@1.2.11 (from 1.2.5)
11
+
7
12
  ## 3.3.4 - 2021/12/23
8
13
 
9
14
  - updated to @applitools/snippets@2.1.12 (from 2.1.11)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/screenshoter",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "description": "Applitools universal screenshoter for web and native applications",
5
5
  "keywords": [
6
6
  "applitools",
@@ -26,19 +26,25 @@
26
26
  "email": "team@applitools.com"
27
27
  },
28
28
  "main": "./index.js",
29
- "directories": {
30
- "lib": "./lib",
31
- "test": "./test"
32
- },
29
+ "files": [
30
+ "src",
31
+ "index.js"
32
+ ],
33
33
  "scripts": {
34
34
  "lint": "eslint . --ext .js",
35
- "test": "yarn test:it && yarn test:e2e",
36
- "test:it": "mocha --no-timeouts './test/it/*.spec.js'",
37
- "test:e2e": "mocha --no-timeouts './test/e2e/*.spec.js'",
35
+ "test": "yarn test:it && yarn test:e2e:ios",
36
+ "test:it": "mocha ./test/it/*.spec.js --no-timeouts",
37
+ "test:e2e": "mocha ./test/e2e/**/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-1}",
38
+ "test:e2e:android": "mocha ./test/e2e/android/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-1}",
39
+ "test:e2e:ios": "mocha ./test/e2e/ios/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-1}",
40
+ "setup": "mkdir -p ./logs && yarn ios:setup && yarn appium:setup",
41
+ "android:setup": "node ./scripts/android-emulator.js",
42
+ "ios:setup": "node ./scripts/ios-simulator.js",
43
+ "appium:setup": "appium --address 127.0.0.1 --port 4723 --base-path /wd/hub --log-level error:info --log ./logs/appium.log &",
38
44
  "docker:setup": "node ../scripts/scripts/generate-docker-compose-config.js && docker-compose up -d",
39
45
  "docker:teardown": "docker-compose down",
40
- "setup": "yarn docker:setup",
41
46
  "deps": "bongo deps",
47
+ "gh:publish": "gh workflow run publish.yml --ref $(git rev-parse --abbrev-ref HEAD) -f packages=screenshoter",
42
48
  "preversion": "bongo preversion",
43
49
  "version": "bongo version",
44
50
  "postversion": "bongo postversion --skip-release-notification"
@@ -50,21 +56,22 @@
50
56
  },
51
57
  "dependencies": {
52
58
  "@applitools/snippets": "2.1.12",
53
- "@applitools/utils": "1.2.5",
59
+ "@applitools/utils": "1.2.11",
54
60
  "png-async": "0.9.4"
55
61
  },
56
62
  "devDependencies": {
57
- "@applitools/driver": "1.4.7",
58
- "@applitools/sdk-release-kit": "0.13.4",
59
- "@applitools/spec-driver-webdriverio": "1.2.5",
60
- "@applitools/test-utils": "1.0.10",
63
+ "@applitools/driver": "1.4.10",
64
+ "@applitools/sdk-release-kit": "0.13.11",
65
+ "@applitools/spec-driver-webdriverio": "1.2.6",
66
+ "@applitools/test-utils": "1.0.11",
67
+ "appium": "^1.22.2",
61
68
  "chromedriver": "^95.0.0",
62
69
  "eslint": "^7.9.0",
63
70
  "eslint-plugin-mocha-no-only": "^1.1.1",
64
71
  "eslint-plugin-node": "^11.1.0",
65
72
  "eslint-plugin-prettier": "^3.1.4",
66
73
  "husky": "^4.3.8",
67
- "mocha": "^8.2.1",
74
+ "mocha": "^9.2.0",
68
75
  "pixelmatch": "^5.2.1",
69
76
  "prettier": "1.19.0",
70
77
  "webdriverio": "^7.16.7"
@@ -1,73 +0,0 @@
1
- {
2
- "name": "dry-run",
3
- "lockfileVersion": 2,
4
- "requires": true,
5
- "packages": {
6
- "": {
7
- "dependencies": {
8
- "@applitools/screenshoter": "file:../dry-run.tgz"
9
- }
10
- },
11
- "node_modules/@applitools/screenshoter": {
12
- "version": "3.3.3",
13
- "resolved": "file:../dry-run.tgz",
14
- "integrity": "sha512-Z9adhafLkHH0o9oRHyA8QeKWTBNejGVnwX3MzkRI0K6pCS+tdoxwpxzsoJRIhj8WiZn4AWpOgafRh7Uu+QXB1g==",
15
- "license": "SEE LICENSE IN LICENSE",
16
- "dependencies": {
17
- "@applitools/snippets": "2.1.12",
18
- "@applitools/utils": "1.2.5",
19
- "png-async": "0.9.4"
20
- },
21
- "engines": {
22
- "node": ">= 8.9.0"
23
- }
24
- },
25
- "node_modules/@applitools/snippets": {
26
- "version": "2.1.12",
27
- "resolved": "https://registry.npmjs.org/@applitools/snippets/-/snippets-2.1.12.tgz",
28
- "integrity": "sha512-XFj9ZMJ8VNNzAuCdGqgmC+SEZY61jRahAiZ/W1dgyJJrEIWmkEm/8USq/3n1mJbbyDV8VhT6+aSikqoanzPETQ==",
29
- "engines": {
30
- "node": ">=8.9.0"
31
- }
32
- },
33
- "node_modules/@applitools/utils": {
34
- "version": "1.2.5",
35
- "resolved": "https://registry.npmjs.org/@applitools/utils/-/utils-1.2.5.tgz",
36
- "integrity": "sha512-nETSgqGeCk5yqjFaQ7x1KURf+t5IxsY2RoeFB5w1+6lHprmHdEithMcN0tiJWeqi14QBJdUkXCzCJrMW5RcDFg==",
37
- "engines": {
38
- "node": ">= 8.9.0"
39
- }
40
- },
41
- "node_modules/png-async": {
42
- "version": "0.9.4",
43
- "resolved": "https://registry.npmjs.org/png-async/-/png-async-0.9.4.tgz",
44
- "integrity": "sha512-B//AXX9TkneKfgtOpT1mdUnnhk2BImGD+a98vImsMU8uo1dBeHyW/kM2erWZ/CsYteTPU/xKG+t6T62heHkC3A=="
45
- }
46
- },
47
- "dependencies": {
48
- "@applitools/screenshoter": {
49
- "version": "file:../dry-run.tgz",
50
- "integrity": "sha512-Z9adhafLkHH0o9oRHyA8QeKWTBNejGVnwX3MzkRI0K6pCS+tdoxwpxzsoJRIhj8WiZn4AWpOgafRh7Uu+QXB1g==",
51
- "requires": {
52
- "@applitools/snippets": "2.1.12",
53
- "@applitools/utils": "1.2.5",
54
- "png-async": "0.9.4"
55
- }
56
- },
57
- "@applitools/snippets": {
58
- "version": "2.1.12",
59
- "resolved": "https://registry.npmjs.org/@applitools/snippets/-/snippets-2.1.12.tgz",
60
- "integrity": "sha512-XFj9ZMJ8VNNzAuCdGqgmC+SEZY61jRahAiZ/W1dgyJJrEIWmkEm/8USq/3n1mJbbyDV8VhT6+aSikqoanzPETQ=="
61
- },
62
- "@applitools/utils": {
63
- "version": "1.2.5",
64
- "resolved": "https://registry.npmjs.org/@applitools/utils/-/utils-1.2.5.tgz",
65
- "integrity": "sha512-nETSgqGeCk5yqjFaQ7x1KURf+t5IxsY2RoeFB5w1+6lHprmHdEithMcN0tiJWeqi14QBJdUkXCzCJrMW5RcDFg=="
66
- },
67
- "png-async": {
68
- "version": "0.9.4",
69
- "resolved": "https://registry.npmjs.org/png-async/-/png-async-0.9.4.tgz",
70
- "integrity": "sha512-B//AXX9TkneKfgtOpT1mdUnnhk2BImGD+a98vImsMU8uo1dBeHyW/kM2erWZ/CsYteTPU/xKG+t6T62heHkC3A=="
71
- }
72
- }
73
- }
@@ -1,5 +0,0 @@
1
- {
2
- "dependencies": {
3
- "@applitools/screenshoter": "file:../dry-run.tgz"
4
- }
5
- }
Binary file
package/.eslintrc DELETED
@@ -1,39 +0,0 @@
1
- {
2
- "env": {
3
- "commonjs": true,
4
- "es6": true,
5
- "node": true,
6
- "mocha": true
7
- },
8
- "parserOptions": {
9
- "ecmaVersion": 2018,
10
- "sourceType": "module"
11
- },
12
- "extends": ["plugin:node/recommended"],
13
- "plugins": ["prettier", "mocha-no-only", "node"],
14
- "ignorePatterns": [
15
- "node_modules/",
16
- "dist/",
17
- "screenshots/",
18
- "applitools.config.js",
19
- "logs",
20
- "tmp/",
21
- "**/test/coverage/generic/"
22
- ],
23
- "rules": {
24
- "prettier/prettier": ["error", {"allowParens": "avoid", "printWidth": 120}],
25
- "no-process-exit": "off",
26
- "no-const-assign": "error",
27
- "no-this-before-super": "error",
28
- "no-undef": "warn",
29
- "no-unreachable": "warn",
30
- "no-unused-vars": [
31
- 1,
32
- {"varsIgnorePattern": "^_", "args": "all", "argsIgnorePattern": "^_"}
33
- ],
34
- "constructor-super": "warn",
35
- "valid-typeof": "warn",
36
- "mocha-no-only/mocha-no-only": "error",
37
- "node/no-unpublished-require": ["off"]
38
- }
39
- }
@@ -1,334 +0,0 @@
1
- const assert = require('assert')
2
- const pixelmatch = require('pixelmatch')
3
- const {Driver} = require('@applitools/driver')
4
- const spec = require('@applitools/spec-driver-webdriverio')
5
- const makeImage = require('../../src/image')
6
- const takeScreenshot = require('../../index')
7
-
8
- const env = {
9
- android: {
10
- url: 'https://ondemand.saucelabs.com/wd/hub',
11
- capabilities: {
12
- name: 'Android Screenshoter Test',
13
- browserName: '',
14
- platformName: 'Android',
15
- platformVersion: '7.0',
16
- appiumVersion: '1.20.2',
17
- deviceName: 'Samsung Galaxy S8 FHD GoogleAPI Emulator',
18
- automationName: 'uiautomator2',
19
- app: 'https://applitools.jfrog.io/artifactory/Examples/android/1.3/app-debug.apk',
20
- username: process.env.SAUCE_USERNAME,
21
- accessKey: process.env.SAUCE_ACCESS_KEY,
22
- },
23
-
24
- // url: 'http://0.0.0.0:4723/wd/hub',
25
- // capabilities: {
26
- // deviceName: 'Google Pixel 3a XL',
27
- // platformName: 'Android',
28
- // platformVersion: '10.0',
29
- // automationName: 'uiautomator2',
30
- // nativeWebScreenshot: true,
31
- // avd: 'Pixel_3a_XL',
32
- // app: 'https://applitools.jfrog.io/artifactory/Examples/android/1.3/app-debug.apk',
33
- // },
34
- },
35
- androidx: {
36
- url: 'https://ondemand.saucelabs.com/wd/hub',
37
- capabilities: {
38
- name: 'AndroidX Screenshoter Test',
39
- browserName: '',
40
- platformName: 'Android',
41
- platformVersion: '10.0',
42
- appiumVersion: '1.20.2',
43
- deviceName: 'Google Pixel 3a XL GoogleAPI Emulator',
44
- automationName: 'uiautomator2',
45
- app: 'https://applitools.jfrog.io/artifactory/Examples/androidx/1.3.1/app_androidx.apk',
46
- username: process.env.SAUCE_USERNAME,
47
- accessKey: process.env.SAUCE_ACCESS_KEY,
48
- },
49
-
50
- // url: 'http://0.0.0.0:4723/wd/hub',
51
- // capabilities: {
52
- // deviceName: 'Google Pixel 3a XL',
53
- // platformName: 'Android',
54
- // platformVersion: '10.0',
55
- // automationName: 'uiautomator2',
56
- // avd: 'Pixel_3a_XL',
57
- // app: 'https://applitools.jfrog.io/artifactory/Examples/androidx/1.3.3/app_androidx.apk',
58
- // },
59
- },
60
- }
61
-
62
- describe('screenshoter', () => {
63
- const logger = {log: () => {}, warn: () => {}, error: () => {}, verbose: () => {}}
64
- let driver, browser, destroyBrowser
65
-
66
- async function sanitizeStatusBar(image) {
67
- const patchImage = makeImage({
68
- width: 85,
69
- height: 18,
70
- data: Buffer.alloc(85 * 18 * 4, Buffer.from([0, 0xed, 0xed, 0xff])),
71
- })
72
- await image.copy(patchImage, {x: 270, y: 4})
73
- }
74
-
75
- describe('android app', () => {
76
- before(async () => {
77
- ;[browser, destroyBrowser] = await spec.build(env.android)
78
- })
79
-
80
- after(async () => {
81
- await destroyBrowser()
82
- })
83
-
84
- beforeEach(async () => {
85
- await browser.closeApp()
86
- await browser.launchApp()
87
- driver = await new Driver({driver: browser, spec, logger}).init()
88
- })
89
-
90
- it('take viewport screenshot', () => {
91
- return app()
92
- })
93
-
94
- it('take viewport screenshot with status bar', () => {
95
- return app({withStatusBar: true})
96
- })
97
-
98
- it('take full app screenshot (scroll view)', () => {
99
- return fullApp({type: 'scroll'})
100
- })
101
-
102
- it('take full app screenshot with status bar (scroll view)', () => {
103
- return fullApp({type: 'scroll', withStatusBar: true})
104
- })
105
-
106
- it('take full app screenshot (recycler view)', () => {
107
- return fullApp({type: 'recycler'})
108
- })
109
-
110
- it('take full app screenshot (non-scrollable)', () => {
111
- return fullApp({type: 'non-scrollable'})
112
- })
113
-
114
- it.skip('take webview screenshot', () => {
115
- return webview()
116
- })
117
-
118
- it('take region screenshot', () => {
119
- return region()
120
- })
121
-
122
- it.skip('take full region screenshot', () => {
123
- return fullRegion()
124
- })
125
-
126
- it('take element screenshot', () => {
127
- return element()
128
- })
129
- })
130
-
131
- describe('androidx app', () => {
132
- before(async () => {
133
- ;[browser, destroyBrowser] = await spec.build(env.androidx)
134
- })
135
-
136
- after(async () => {
137
- await destroyBrowser()
138
- })
139
-
140
- beforeEach(async () => {
141
- await browser.closeApp()
142
- await browser.launchApp()
143
- driver = await new Driver({driver: browser, spec, logger}).init()
144
- })
145
-
146
- it('take full app screenshot (recycler view)', () => {
147
- return fullApp({type: 'recycler', x: true})
148
- })
149
-
150
- it('take full app screenshot (collapsing layout)', () => {
151
- return fullApp({type: 'collapsing', x: true})
152
- })
153
-
154
- it.skip('take full app screenshot (pager)', () => {
155
- return fullApp({type: 'pager', x: true})
156
- })
157
-
158
- it.skip('take full app screenshot (overlapped status bar)', () => {
159
- return fullApp({type: 'overlapped', x: true})
160
- })
161
-
162
- it('take full element screenshot', () => {
163
- return fullElement()
164
- })
165
- })
166
-
167
- async function app(options = {}) {
168
- const expectedPath = `./test/fixtures/android/app${options.withStatusBar ? '-statusbar' : ''}.png`
169
-
170
- const screenshot = await takeScreenshot({logger, driver, wait: 1500, ...options})
171
- try {
172
- if (options.withStatusBar) await sanitizeStatusBar(screenshot.image)
173
- const actual = await screenshot.image.toObject()
174
- const expected = await makeImage(expectedPath).toObject()
175
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
176
- } catch (err) {
177
- await screenshot.image.debug({path: './logs', name: 'viewport_failed', suffix: Date.now()})
178
- throw err
179
- }
180
- }
181
- async function fullApp({type, x, ...options} = {}) {
182
- let buttonSelector, expectedPath, scrollingElementSelector
183
- if (type === 'pager') {
184
- buttonSelector = {type: 'id', selector: 'btn_view_pager_2_activity'}
185
- expectedPath = `./test/fixtures/android/x-app-fully-pager${options.withStatusBar ? '-statusbar' : ''}.png`
186
- } else if (type === 'overlapped') {
187
- buttonSelector = {type: 'id', selector: 'btn_recycler_view_under_status_bar_activity'}
188
- expectedPath = `./test/fixtures/android/x-app-fully-overlapped${options.withStatusBar ? '-statusbar' : ''}.png`
189
- } else if (type === 'collapsing') {
190
- buttonSelector = {type: 'id', selector: 'btn_recycler_view_nested_collapsing'}
191
- scrollingElementSelector = {type: 'id', selector: 'recyclerView'}
192
- expectedPath = `./test/fixtures/android/x-app-fully-collapsing${options.withStatusBar ? '-statusbar' : ''}.png`
193
- } else if (type === 'recycler') {
194
- if (x) {
195
- buttonSelector = {type: 'id', selector: 'btn_recycler_view_activity'}
196
- expectedPath = `./test/fixtures/android/x-app-fully-recycler${options.withStatusBar ? '-statusbar' : ''}.png`
197
- } else {
198
- buttonSelector = {type: 'id', selector: 'btn_recycler_view'}
199
- expectedPath = `./test/fixtures/android/app-fully-recycler${options.withStatusBar ? '-statusbar' : ''}.png`
200
- }
201
- } else if (type === 'non-scrollable') {
202
- buttonSelector = {type: 'id', selector: 'btn_activity_as_dialog'}
203
- expectedPath = `./test/fixtures/android/app-fully-non-scrollable${options.withStatusBar ? '-statusbar' : ''}.png`
204
- } else {
205
- buttonSelector = {type: 'id', selector: 'btn_scroll_view_footer_header'}
206
- expectedPath = `./test/fixtures/android/app-fully-scroll${options.withStatusBar ? '-statusbar' : ''}.png`
207
- }
208
-
209
- const button = await driver.element(buttonSelector)
210
- await button.click()
211
-
212
- await driver.init()
213
-
214
- if (scrollingElementSelector) {
215
- await driver.currentContext.setScrollingElement(scrollingElementSelector)
216
- }
217
-
218
- const screenshot = await takeScreenshot({
219
- logger,
220
- driver,
221
- fully: true,
222
- framed: true,
223
- scrollingMode: 'scroll',
224
- wait: 1500,
225
- ...options,
226
- })
227
- try {
228
- if (options.withStatusBar) await sanitizeStatusBar(screenshot.image)
229
- const actual = await screenshot.image.toObject()
230
- const expected = await makeImage(expectedPath).toObject()
231
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
232
- } catch (err) {
233
- await screenshot.image.debug({path: './logs', name: 'full_app_failed', suffix: Date.now()})
234
- throw err
235
- }
236
- }
237
- async function webview(options) {
238
- const expectedPath = `./test/fixtures/android/webview.png`
239
- const buttonSelector = {type: 'id', selector: 'btn_web_view'}
240
-
241
- const button = await driver.element(buttonSelector)
242
- await button.click()
243
- await driver.target.switchContext('WEBVIEW')
244
-
245
- await driver.init()
246
-
247
- const screenshot = await takeScreenshot({logger, driver, wait: 1500, ...options})
248
- try {
249
- const actual = await screenshot.image.toObject()
250
- const expected = await makeImage(expectedPath).toObject()
251
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
252
- } catch (err) {
253
- await screenshot.image.debug({path: './logs', name: 'webview_failed', suffix: Date.now()})
254
- throw err
255
- }
256
- }
257
- async function region(options) {
258
- const screenshot = await takeScreenshot({
259
- logger,
260
- driver,
261
- region: {x: 30, y: 500, height: 100, width: 200},
262
- scrollingMode: 'scroll',
263
- ...options,
264
- })
265
- try {
266
- const actual = await screenshot.image.toObject()
267
- const expected = await makeImage('./test/fixtures/android/region.png').toObject()
268
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
269
- } catch (err) {
270
- await screenshot.image.debug({path: './logs', name: 'region_failed', suffix: Date.now()})
271
- throw err
272
- }
273
- }
274
- async function fullRegion(options) {
275
- const screenshot = await takeScreenshot({
276
- logger,
277
- driver,
278
- region: {x: 30, y: 10, height: 700, width: 200},
279
- fully: true,
280
- scrollingMode: 'scroll',
281
- ...options,
282
- })
283
- try {
284
- const actual = await screenshot.image.toObject()
285
- const expected = await makeImage('./test/fixtures/android/region-fully.png').toObject()
286
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
287
- } catch (err) {
288
- await screenshot.image.debug({path: './logs', name: 'full_region_failed', suffix: Date.now()})
289
- throw err
290
- }
291
- }
292
- async function element(options) {
293
- const screenshot = await takeScreenshot({
294
- logger,
295
- driver,
296
- region: {type: 'id', selector: 'btn_recycler_view'},
297
- scrollingMode: 'scroll',
298
- ...options,
299
- })
300
- try {
301
- const actual = await screenshot.image.toObject()
302
- const expected = await makeImage('./test/fixtures/android/element.png').toObject()
303
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
304
- } catch (err) {
305
- await screenshot.image.debug({path: './logs', name: 'element_failed', suffix: Date.now()})
306
- throw err
307
- }
308
- }
309
- async function fullElement(options) {
310
- const button = await driver.element({
311
- type: 'id',
312
- selector: 'btn_recycler_view_in_scroll_view_activity',
313
- })
314
- await button.click()
315
-
316
- const screenshot = await takeScreenshot({
317
- logger,
318
- driver,
319
- region: {type: 'id', selector: 'recyclerView'},
320
- fully: true,
321
- scrollingMode: 'scroll',
322
- wait: 1500,
323
- ...options,
324
- })
325
- try {
326
- const actual = await screenshot.image.toObject()
327
- const expected = await makeImage('./test/fixtures/android/x-element-fully.png').toObject()
328
- assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
329
- } catch (err) {
330
- await screenshot.image.debug({path: './logs', name: 'full_element_failed', suffix: Date.now()})
331
- throw err
332
- }
333
- }
334
- })