@applitools/screenshoter 3.2.8 → 3.3.2
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.
- package/.bongo/dry-run/package-lock.json +49 -6
- package/.bongo/dry-run/package.json +5 -0
- package/.bongo/dry-run.tgz +0 -0
- package/CHANGELOG.md +19 -0
- package/index.js +2 -1
- package/package.json +7 -4
- package/src/find-image-pattern.js +11 -38
- package/src/image.js +107 -64
- package/src/take-screenshot.js +136 -160
- package/src/take-simple-screenshot.js +25 -0
- package/src/take-stitched-screenshot.js +34 -40
- package/src/take-viewport-screenshot.js +179 -16
- package/test/e2e/android.spec.js +120 -13
- package/test/e2e/external.spec.js +155 -0
- package/test/e2e/ios.spec.js +142 -12
- package/test/e2e/web-ios.spec.js +19 -6
- package/test/e2e/web.spec.js +33 -21
- package/test/fixtures/android/app-fully-non-scrollable.png +0 -0
- package/test/fixtures/android/app-fully-recycler.png +0 -0
- package/test/fixtures/android/app-fully-scroll-statusbar.png +0 -0
- package/test/fixtures/android/app-fully-scroll.png +0 -0
- package/test/fixtures/android/app-statusbar.png +0 -0
- package/test/fixtures/android/x-app-fully-collapsing.png +0 -0
- package/test/fixtures/android/x-app-fully-recycler.png +0 -0
- package/test/fixtures/android/x-element-fully.png +0 -0
- package/test/fixtures/external/agl.png +0 -0
- package/test/fixtures/image/{house.combined-higher-wider.png → house.framed-higher-wider.png} +0 -0
- package/test/fixtures/image/{house.combined-higher.png → house.framed-higher.png} +0 -0
- package/test/fixtures/image/house.framed-shorter-thinner.png +0 -0
- package/test/fixtures/image/{house.combined-wider.png → house.framed-wider.png} +0 -0
- package/test/fixtures/ios/app-fully-collapsing.png +0 -0
- package/test/fixtures/ios/app-fully-collection.png +0 -0
- package/test/fixtures/ios/app-fully-overlapped-statusbar.png +0 -0
- package/test/fixtures/ios/app-fully-overlapped.png +0 -0
- package/test/fixtures/ios/app-fully-scroll-statusbar.png +0 -0
- package/test/fixtures/ios/app-fully-scroll.png +0 -0
- package/test/fixtures/ios/app-fully-superview.png +0 -0
- package/test/fixtures/ios/app-fully-table.png +0 -0
- package/test/fixtures/ios/app-statusbar.png +0 -0
- package/test/fixtures/ios/app.png +0 -0
- package/test/fixtures/ios/element-fully.png +0 -0
- package/test/fixtures/ios/element.png +0 -0
- package/test/fixtures/ios/region.png +0 -0
- package/test/fixtures/ios/webview-fully.png +0 -0
- package/test/fixtures/ios/webview.png +0 -0
- package/test/fixtures/pattern/iPad_5th_landscape.png +0 -0
- package/test/fixtures/pattern/iPad_5th_portrait.png +0 -0
- package/test/fixtures/pattern/iPad_9th_landscape.png +0 -0
- package/test/fixtures/pattern/iPad_9th_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_11_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_11_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_13_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_13_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_SE_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_SE_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait_noviewport.png +0 -0
- package/test/fixtures/web/frame-fully.png +0 -0
- package/test/fixtures/web/frame.png +0 -0
- package/test/fixtures/web/inner-element-fully.png +0 -0
- package/test/fixtures/web/inner-element.png +0 -0
- package/test/fixtures/web/inner-region-fully.png +0 -0
- package/test/fixtures/web/inner-region.png +0 -0
- package/test/fixtures/web/page-fully.png +0 -0
- package/test/fixtures/web/page.png +0 -0
- package/test/fixtures/web/region-fully.png +0 -0
- package/test/fixtures/web/region.png +0 -0
- package/test/fixtures/web-ios/page-fully.png +0 -0
- package/test/it/find-pattern.spec.js +16 -11
- package/test/it/image.spec.js +42 -15
- package/docker-compose.yaml +0 -29
- package/src/calculate-screenshot-regions.js +0 -31
- package/src/screenshoter.js +0 -158
- package/test/fixtures/pattern/iPad_Air_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_5S_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XR_perfecto_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_Max_perfecto_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_X_perfecto_portrait.png +0 -0
- package/test/util/spec-driver.js +0 -288
package/test/e2e/ios.spec.js
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
|
+
const utils = require('@applitools/utils')
|
|
3
4
|
const {Driver} = require('@applitools/driver')
|
|
4
|
-
const spec = require('
|
|
5
|
+
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
6
|
const makeImage = require('../../src/image')
|
|
6
|
-
const
|
|
7
|
+
const takeScreenshot = require('../../index')
|
|
8
|
+
|
|
9
|
+
const env = {
|
|
10
|
+
url: 'https://ondemand.saucelabs.com/wd/hub',
|
|
11
|
+
capabilities: {
|
|
12
|
+
name: 'iOS Screenshoter Test',
|
|
13
|
+
deviceName: 'iPhone 11 Pro Simulator',
|
|
14
|
+
platformName: 'iOS',
|
|
15
|
+
platformVersion: '14.5',
|
|
16
|
+
appiumVersion: '1.21.0',
|
|
17
|
+
automationName: 'XCUITest',
|
|
18
|
+
app: 'https://applitools.jfrog.io/artifactory/Examples/IOSTestApp/1.9/app/IOSTestApp.zip',
|
|
19
|
+
username: process.env.SAUCE_USERNAME,
|
|
20
|
+
accessKey: process.env.SAUCE_ACCESS_KEY,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// url: 'http://0.0.0.0:4723/wd/hub',
|
|
24
|
+
// capabilities: {
|
|
25
|
+
// deviceName: 'iPhone 11 Pro',
|
|
26
|
+
// platformName: 'iOS',
|
|
27
|
+
// platformVersion: '14.5',
|
|
28
|
+
// automationName: 'XCUITest',
|
|
29
|
+
// app: 'https://applitools.jfrog.io/artifactory/Examples/IOSTestApp/1.9/app/IOSTestApp.zip',
|
|
30
|
+
// },
|
|
31
|
+
}
|
|
7
32
|
|
|
8
33
|
describe('screenshoter ios', () => {
|
|
9
34
|
const logger = {log: () => {}, warn: () => {}, error: () => {}, verbose: () => {}}
|
|
@@ -25,7 +50,7 @@ describe('screenshoter ios', () => {
|
|
|
25
50
|
}
|
|
26
51
|
|
|
27
52
|
before(async () => {
|
|
28
|
-
;[browser, destroyBrowser] = await spec.build(
|
|
53
|
+
;[browser, destroyBrowser] = await spec.build(env)
|
|
29
54
|
})
|
|
30
55
|
|
|
31
56
|
after(async () => {
|
|
@@ -62,6 +87,30 @@ describe('screenshoter ios', () => {
|
|
|
62
87
|
return fullApp({type: 'collection'})
|
|
63
88
|
})
|
|
64
89
|
|
|
90
|
+
it('take full app screenshot (table view with collapsing header)', () => {
|
|
91
|
+
return fullApp({type: 'collapsing'})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('take full app screenshot (collection view with overlapped status bar)', () => {
|
|
95
|
+
return fullApp({type: 'overlapped'})
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('take full app screenshot with status bar (collection view with overlapped status bar)', () => {
|
|
99
|
+
return fullApp({type: 'overlapped', withStatusBar: true})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('take full app screenshot (collection view with superview)', () => {
|
|
103
|
+
return fullApp({type: 'superview'})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('take webview screenshot', () => {
|
|
107
|
+
return webview()
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('take full webview screenshot', () => {
|
|
111
|
+
return fullWebview()
|
|
112
|
+
})
|
|
113
|
+
|
|
65
114
|
it('take region screenshot', () => {
|
|
66
115
|
return region()
|
|
67
116
|
})
|
|
@@ -80,8 +129,12 @@ describe('screenshoter ios', () => {
|
|
|
80
129
|
|
|
81
130
|
async function app(options = {}) {
|
|
82
131
|
const expectedPath = `./test/fixtures/ios/app${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
132
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Empty table view'}
|
|
83
133
|
|
|
84
|
-
const
|
|
134
|
+
const button = await driver.element(buttonSelector)
|
|
135
|
+
await button.click()
|
|
136
|
+
|
|
137
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
85
138
|
try {
|
|
86
139
|
if (options.withStatusBar) await sanitizeStatusBar(screenshot.image)
|
|
87
140
|
const actual = await screenshot.image.toObject()
|
|
@@ -93,8 +146,19 @@ describe('screenshoter ios', () => {
|
|
|
93
146
|
}
|
|
94
147
|
}
|
|
95
148
|
async function fullApp({type, ...options} = {}) {
|
|
96
|
-
let buttonSelector, expectedPath
|
|
97
|
-
if (type === '
|
|
149
|
+
let buttonSelector, expectedPath, overlap
|
|
150
|
+
if (type === 'superview') {
|
|
151
|
+
overlap = {top: 200}
|
|
152
|
+
buttonSelector = {type: 'accessibility id', selector: 'Bottom to superview'}
|
|
153
|
+
expectedPath = `./test/fixtures/ios/app-fully-superview${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
154
|
+
} else if (type === 'overlapped') {
|
|
155
|
+
overlap = {top: 200}
|
|
156
|
+
buttonSelector = {type: 'accessibility id', selector: 'Bottom to safe area'}
|
|
157
|
+
expectedPath = `./test/fixtures/ios/app-fully-overlapped${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
158
|
+
} else if (type === 'collapsing') {
|
|
159
|
+
buttonSelector = {type: 'accessibility id', selector: 'Table view with stretchable header'}
|
|
160
|
+
expectedPath = `./test/fixtures/ios/app-fully-collapsing${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
161
|
+
} else if (type === 'collection') {
|
|
98
162
|
buttonSelector = {type: 'accessibility id', selector: 'Collection view'}
|
|
99
163
|
expectedPath = `./test/fixtures/ios/app-fully-collection${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
100
164
|
} else if (type === 'table') {
|
|
@@ -108,13 +172,16 @@ describe('screenshoter ios', () => {
|
|
|
108
172
|
const button = await driver.element(buttonSelector)
|
|
109
173
|
await button.click()
|
|
110
174
|
|
|
111
|
-
|
|
175
|
+
await driver.init()
|
|
176
|
+
|
|
177
|
+
const screenshot = await takeScreenshot({
|
|
112
178
|
logger,
|
|
113
179
|
driver,
|
|
114
180
|
fully: true,
|
|
115
181
|
framed: true,
|
|
116
182
|
scrollingMode: 'scroll',
|
|
117
183
|
wait: 1500,
|
|
184
|
+
overlap: {top: 10, bottom: 50, ...overlap},
|
|
118
185
|
...options,
|
|
119
186
|
})
|
|
120
187
|
try {
|
|
@@ -127,8 +194,71 @@ describe('screenshoter ios', () => {
|
|
|
127
194
|
throw err
|
|
128
195
|
}
|
|
129
196
|
}
|
|
197
|
+
async function webview(options) {
|
|
198
|
+
const expectedPath = `./test/fixtures/ios/webview.png`
|
|
199
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Web view'}
|
|
200
|
+
|
|
201
|
+
const button = await driver.element(buttonSelector)
|
|
202
|
+
await button.click()
|
|
203
|
+
await driver.target.getContexts()
|
|
204
|
+
await utils.general.sleep(500)
|
|
205
|
+
const [, webview] = await driver.target.getContexts()
|
|
206
|
+
await driver.target.switchContext(webview)
|
|
207
|
+
|
|
208
|
+
await driver.init()
|
|
209
|
+
|
|
210
|
+
const screenshot = await takeScreenshot({logger, driver, wait: 1500, ...options})
|
|
211
|
+
try {
|
|
212
|
+
const actual = await screenshot.image.toObject()
|
|
213
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
214
|
+
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
215
|
+
} catch (err) {
|
|
216
|
+
await screenshot.image.debug({path: './logs', name: 'webview_failed', suffix: Date.now()})
|
|
217
|
+
throw err
|
|
218
|
+
} finally {
|
|
219
|
+
await driver.target.switchContext('NATIVE_APP')
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function fullWebview(options) {
|
|
223
|
+
const expectedPath = `./test/fixtures/ios/webview-fully.png`
|
|
224
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Web view'}
|
|
225
|
+
|
|
226
|
+
const button = await driver.element(buttonSelector)
|
|
227
|
+
await button.click()
|
|
228
|
+
await driver.target.getContexts()
|
|
229
|
+
await utils.general.sleep(500)
|
|
230
|
+
const [, webview] = await driver.target.getContexts()
|
|
231
|
+
await driver.target.switchContext(webview)
|
|
232
|
+
|
|
233
|
+
await driver.init()
|
|
234
|
+
const screenshot = await takeScreenshot({
|
|
235
|
+
logger,
|
|
236
|
+
driver,
|
|
237
|
+
wait: 1500,
|
|
238
|
+
fully: true,
|
|
239
|
+
scrollingMode: 'scroll',
|
|
240
|
+
...options,
|
|
241
|
+
})
|
|
242
|
+
try {
|
|
243
|
+
const actual = await screenshot.image.toObject()
|
|
244
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
245
|
+
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
246
|
+
} catch (err) {
|
|
247
|
+
await screenshot.image.debug({path: './logs', name: 'full_webview_failed', suffix: Date.now()})
|
|
248
|
+
throw err
|
|
249
|
+
} finally {
|
|
250
|
+
await driver.target.switchContext('NATIVE_APP')
|
|
251
|
+
}
|
|
252
|
+
}
|
|
130
253
|
async function region(options) {
|
|
131
|
-
const
|
|
254
|
+
const expectedPath = `./test/fixtures/ios/region.png`
|
|
255
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Empty table view'}
|
|
256
|
+
|
|
257
|
+
const button = await driver.element(buttonSelector)
|
|
258
|
+
await button.click()
|
|
259
|
+
|
|
260
|
+
await driver.init()
|
|
261
|
+
const screenshot = await takeScreenshot({
|
|
132
262
|
logger,
|
|
133
263
|
driver,
|
|
134
264
|
region: {x: 30, y: 500, height: 100, width: 200},
|
|
@@ -138,7 +268,7 @@ describe('screenshoter ios', () => {
|
|
|
138
268
|
})
|
|
139
269
|
try {
|
|
140
270
|
const actual = await screenshot.image.toObject()
|
|
141
|
-
const expected = await makeImage(
|
|
271
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
142
272
|
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
143
273
|
} catch (err) {
|
|
144
274
|
await screenshot.image.debug({path: './logs', name: 'region_failed'})
|
|
@@ -146,7 +276,7 @@ describe('screenshoter ios', () => {
|
|
|
146
276
|
}
|
|
147
277
|
}
|
|
148
278
|
async function fullRegion(options) {
|
|
149
|
-
const screenshot = await
|
|
279
|
+
const screenshot = await takeScreenshot({
|
|
150
280
|
logger,
|
|
151
281
|
driver,
|
|
152
282
|
region: {x: 30, y: 10, height: 700, width: 200},
|
|
@@ -164,7 +294,7 @@ describe('screenshoter ios', () => {
|
|
|
164
294
|
}
|
|
165
295
|
}
|
|
166
296
|
async function element(options) {
|
|
167
|
-
const screenshot = await
|
|
297
|
+
const screenshot = await takeScreenshot({
|
|
168
298
|
logger,
|
|
169
299
|
driver,
|
|
170
300
|
region: {type: 'accessibility id', selector: 'Table view'},
|
|
@@ -187,7 +317,7 @@ describe('screenshoter ios', () => {
|
|
|
187
317
|
})
|
|
188
318
|
await button.click()
|
|
189
319
|
|
|
190
|
-
const screenshot = await
|
|
320
|
+
const screenshot = await takeScreenshot({
|
|
191
321
|
logger,
|
|
192
322
|
driver,
|
|
193
323
|
region: {type: 'xpath', selector: '//XCUIElementTypeTable[1]'},
|
package/test/e2e/web-ios.spec.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
3
|
const {Driver} = require('@applitools/driver')
|
|
4
|
-
const spec = require('
|
|
5
|
-
const
|
|
4
|
+
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
+
const takeScreenshot = require('../../index')
|
|
6
6
|
const makeImage = require('../../src/image')
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const env = {
|
|
9
|
+
url: 'https://ondemand.saucelabs.com/wd/hub',
|
|
10
|
+
capabilities: {
|
|
11
|
+
name: 'iOS Web Screenshoter Test',
|
|
12
|
+
deviceName: 'iPhone 11 Pro Simulator',
|
|
13
|
+
browserName: 'safari',
|
|
14
|
+
platformName: 'iOS',
|
|
15
|
+
platformVersion: '14.5',
|
|
16
|
+
appiumVersion: '1.20.1',
|
|
17
|
+
automationName: 'XCUITest',
|
|
18
|
+
username: process.env.SAUCE_USERNAME,
|
|
19
|
+
accessKey: process.env.SAUCE_ACCESS_KEY,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
9
22
|
|
|
10
23
|
describe('screenshoter web ios', () => {
|
|
11
24
|
const logger = {log: () => {}, warn: () => {}, error: () => {}, verbose: () => {}}
|
|
12
25
|
let driver, browser, destroyBrowser
|
|
13
26
|
|
|
14
27
|
before(async () => {
|
|
15
|
-
;[browser, destroyBrowser] = await spec.build(
|
|
28
|
+
;[browser, destroyBrowser] = await spec.build(env)
|
|
16
29
|
})
|
|
17
30
|
|
|
18
31
|
after(async () => {
|
|
@@ -34,7 +47,7 @@ describe('screenshoter web ios', () => {
|
|
|
34
47
|
})
|
|
35
48
|
|
|
36
49
|
async function viewport(options) {
|
|
37
|
-
const screenshot = await
|
|
50
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
38
51
|
try {
|
|
39
52
|
const actual = await screenshot.image.toObject()
|
|
40
53
|
const expected = await makeImage('./test/fixtures/web-ios/page.png').toObject()
|
|
@@ -46,7 +59,7 @@ describe('screenshoter web ios', () => {
|
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
async function fullPage(options) {
|
|
49
|
-
const screenshot = await
|
|
62
|
+
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
50
63
|
try {
|
|
51
64
|
const actual = await screenshot.image.toObject()
|
|
52
65
|
const expected = await makeImage('./test/fixtures/web-ios/page-fully.png').toObject()
|
package/test/e2e/web.spec.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
3
|
const {Driver} = require('@applitools/driver')
|
|
4
|
-
const spec = require('
|
|
5
|
-
const
|
|
4
|
+
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
+
const takeScreenshot = require('../../index')
|
|
6
6
|
const makeImage = require('../../src/image')
|
|
7
7
|
|
|
8
|
+
const env = {
|
|
9
|
+
url: 'http://localhost:4444/wd/hub',
|
|
10
|
+
capabilities: {
|
|
11
|
+
browserName: 'chrome',
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
// TODO add overflowed regions tests
|
|
9
16
|
|
|
10
17
|
describe('screenshoter web', () => {
|
|
@@ -12,7 +19,7 @@ describe('screenshoter web', () => {
|
|
|
12
19
|
let driver, browser, destroyBrowser
|
|
13
20
|
|
|
14
21
|
before(async () => {
|
|
15
|
-
;[browser, destroyBrowser] = await spec.build(
|
|
22
|
+
;[browser, destroyBrowser] = await spec.build(env)
|
|
16
23
|
})
|
|
17
24
|
|
|
18
25
|
after(async () => {
|
|
@@ -37,10 +44,10 @@ describe('screenshoter web', () => {
|
|
|
37
44
|
})
|
|
38
45
|
|
|
39
46
|
it('take frame screenshot with "scroll" scrolling', () => {
|
|
40
|
-
frame({scrollingMode: 'scroll'})
|
|
47
|
+
return frame({scrollingMode: 'scroll'})
|
|
41
48
|
})
|
|
42
49
|
it('take frame screenshot with "css" scrolling', () => {
|
|
43
|
-
frame({scrollingMode: 'css'})
|
|
50
|
+
return frame({scrollingMode: 'css'})
|
|
44
51
|
})
|
|
45
52
|
|
|
46
53
|
it('take full frame screenshot with "scroll" scrolling', () => {
|
|
@@ -51,10 +58,10 @@ describe('screenshoter web', () => {
|
|
|
51
58
|
})
|
|
52
59
|
|
|
53
60
|
it('take region screenshot with "scroll" scrolling', () => {
|
|
54
|
-
region({scrollingMode: 'scroll'})
|
|
61
|
+
return region({scrollingMode: 'scroll'})
|
|
55
62
|
})
|
|
56
63
|
it('take region screenshot with "css" scrolling', () => {
|
|
57
|
-
region({scrollingMode: 'css'})
|
|
64
|
+
return region({scrollingMode: 'css'})
|
|
58
65
|
})
|
|
59
66
|
|
|
60
67
|
it('take full region screenshot with "scroll" scrolling', () => {
|
|
@@ -121,7 +128,7 @@ describe('screenshoter web', () => {
|
|
|
121
128
|
})
|
|
122
129
|
|
|
123
130
|
async function viewport(options) {
|
|
124
|
-
const screenshot = await
|
|
131
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
125
132
|
try {
|
|
126
133
|
const actual = await screenshot.image.toObject()
|
|
127
134
|
const expected = await makeImage('./test/fixtures/web/page.png').toObject()
|
|
@@ -132,7 +139,7 @@ describe('screenshoter web', () => {
|
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
141
|
async function fullPage(options) {
|
|
135
|
-
const screenshot = await
|
|
142
|
+
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
136
143
|
try {
|
|
137
144
|
const actual = await screenshot.image.toObject()
|
|
138
145
|
const expected = await makeImage('./test/fixtures/web/page-fully.png').toObject()
|
|
@@ -143,7 +150,12 @@ describe('screenshoter web', () => {
|
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
async function frame(options) {
|
|
146
|
-
const screenshot = await
|
|
153
|
+
const screenshot = await takeScreenshot({
|
|
154
|
+
logger,
|
|
155
|
+
driver,
|
|
156
|
+
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
157
|
+
...options,
|
|
158
|
+
})
|
|
147
159
|
try {
|
|
148
160
|
const actual = await screenshot.image.toObject()
|
|
149
161
|
const expected = await makeImage('./test/fixtures/web/frame.png').toObject()
|
|
@@ -154,7 +166,7 @@ describe('screenshoter web', () => {
|
|
|
154
166
|
}
|
|
155
167
|
}
|
|
156
168
|
async function fullFrame(options) {
|
|
157
|
-
const screenshot = await
|
|
169
|
+
const screenshot = await takeScreenshot({
|
|
158
170
|
logger,
|
|
159
171
|
driver,
|
|
160
172
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -172,7 +184,7 @@ describe('screenshoter web', () => {
|
|
|
172
184
|
}
|
|
173
185
|
async function region(options) {
|
|
174
186
|
const region = {x: 30, y: 500, height: 100, width: 200}
|
|
175
|
-
const screenshot = await
|
|
187
|
+
const screenshot = await takeScreenshot({logger, driver, region, ...options})
|
|
176
188
|
try {
|
|
177
189
|
const actual = await screenshot.image.toObject()
|
|
178
190
|
const expected = await makeImage('./test/fixtures/web/region.png').toObject()
|
|
@@ -184,7 +196,7 @@ describe('screenshoter web', () => {
|
|
|
184
196
|
}
|
|
185
197
|
async function fullRegion(options) {
|
|
186
198
|
const region = {x: 30, y: 500, height: 700, width: 200}
|
|
187
|
-
const screenshot = await
|
|
199
|
+
const screenshot = await takeScreenshot({logger, driver, region, fully: true, ...options})
|
|
188
200
|
try {
|
|
189
201
|
const actual = await screenshot.image.toObject()
|
|
190
202
|
const expected = await makeImage('./test/fixtures/web/region-fully.png').toObject()
|
|
@@ -195,7 +207,7 @@ describe('screenshoter web', () => {
|
|
|
195
207
|
}
|
|
196
208
|
}
|
|
197
209
|
async function element(options) {
|
|
198
|
-
const screenshot = await
|
|
210
|
+
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', ...options})
|
|
199
211
|
try {
|
|
200
212
|
const actual = await screenshot.image.toObject()
|
|
201
213
|
const expected = await makeImage('./test/fixtures/web/element.png').toObject()
|
|
@@ -206,7 +218,7 @@ describe('screenshoter web', () => {
|
|
|
206
218
|
}
|
|
207
219
|
}
|
|
208
220
|
async function fullElement(options) {
|
|
209
|
-
const screenshot = await
|
|
221
|
+
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', fully: true, ...options})
|
|
210
222
|
try {
|
|
211
223
|
const actual = await screenshot.image.toObject()
|
|
212
224
|
const expected = await makeImage('./test/fixtures/web/element-fully.png').toObject()
|
|
@@ -217,7 +229,7 @@ describe('screenshoter web', () => {
|
|
|
217
229
|
}
|
|
218
230
|
}
|
|
219
231
|
async function regionInFrame(options) {
|
|
220
|
-
const screenshot = await
|
|
232
|
+
const screenshot = await takeScreenshot({
|
|
221
233
|
logger,
|
|
222
234
|
driver,
|
|
223
235
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -234,7 +246,7 @@ describe('screenshoter web', () => {
|
|
|
234
246
|
}
|
|
235
247
|
}
|
|
236
248
|
async function fullRegionInFrame(options) {
|
|
237
|
-
const screenshot = await
|
|
249
|
+
const screenshot = await takeScreenshot({
|
|
238
250
|
logger,
|
|
239
251
|
driver,
|
|
240
252
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -252,7 +264,7 @@ describe('screenshoter web', () => {
|
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
async function elementInFrame(options) {
|
|
255
|
-
const screenshot = await
|
|
267
|
+
const screenshot = await takeScreenshot({
|
|
256
268
|
logger,
|
|
257
269
|
driver,
|
|
258
270
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -269,7 +281,7 @@ describe('screenshoter web', () => {
|
|
|
269
281
|
}
|
|
270
282
|
}
|
|
271
283
|
async function fullElementInFrame(options) {
|
|
272
|
-
const screenshot = await
|
|
284
|
+
const screenshot = await takeScreenshot({
|
|
273
285
|
logger,
|
|
274
286
|
driver,
|
|
275
287
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -287,7 +299,7 @@ describe('screenshoter web', () => {
|
|
|
287
299
|
}
|
|
288
300
|
}
|
|
289
301
|
async function frameInFrame(options) {
|
|
290
|
-
const screenshot = await
|
|
302
|
+
const screenshot = await takeScreenshot({
|
|
291
303
|
logger,
|
|
292
304
|
driver,
|
|
293
305
|
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
@@ -303,7 +315,7 @@ describe('screenshoter web', () => {
|
|
|
303
315
|
}
|
|
304
316
|
}
|
|
305
317
|
async function fullFrameInFrame(options) {
|
|
306
|
-
const screenshot = await
|
|
318
|
+
const screenshot = await takeScreenshot({
|
|
307
319
|
logger,
|
|
308
320
|
driver,
|
|
309
321
|
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/fixtures/image/{house.combined-higher-wider.png → house.framed-higher-wider.png}
RENAMED
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4,23 +4,28 @@ const findPattern = require('../../src/find-image-pattern')
|
|
|
4
4
|
|
|
5
5
|
describe('pattern', () => {
|
|
6
6
|
const fixtures = [
|
|
7
|
-
{name: '
|
|
8
|
-
{name: '
|
|
9
|
-
{name: '
|
|
10
|
-
{name: '
|
|
11
|
-
{name: '
|
|
12
|
-
{name: '
|
|
13
|
-
{name: '
|
|
7
|
+
{name: 'iPhone_SE_portrait', position: {x: 0, y: 140}, offset: 0, pixelRatio: 2},
|
|
8
|
+
{name: 'iPhone_SE_landscape', position: {x: 0, y: 100}, offset: 0, pixelRatio: 2},
|
|
9
|
+
{name: 'iPhone_11_portrait', position: {x: 0, y: 282}, offset: 0, pixelRatio: 3},
|
|
10
|
+
{name: 'iPhone_11_landscape', position: {x: 132, y: 150}, offset: 0, pixelRatio: 3},
|
|
11
|
+
{name: 'iPhone_13_portrait', position: {x: 0, y: 141}, offset: 0, pixelRatio: 3},
|
|
12
|
+
{name: 'iPhone_13_landscape', position: {x: 141, y: 144}, offset: 0, pixelRatio: 3},
|
|
13
|
+
{name: 'iPad_5th_portrait', position: {x: 0, y: 140}, offset: 0, pixelRatio: 2},
|
|
14
|
+
{name: 'iPad_5th_landscape', position: {x: 0, y: 140}, offset: 0, pixelRatio: 2},
|
|
15
|
+
{name: 'iPad_9th_portrait', position: {x: 0, y: 136}, offset: 0, pixelRatio: 2},
|
|
16
|
+
{name: 'iPad_9th_landscape', position: {x: 640, y: 136}, offset: 1, pixelRatio: 2},
|
|
17
|
+
{name: 'iPhone_XS_portrait_noviewport', position: {x: 0, y: 282}, offset: 0, pixelRatio: 3},
|
|
14
18
|
{name: 'iPhone_XS_portrait_nomarker', position: null, pixelRatio: 3},
|
|
15
19
|
]
|
|
16
20
|
|
|
17
|
-
fixtures.forEach(({name, position, pixelRatio}) => {
|
|
21
|
+
fixtures.forEach(({name, position, offset, pixelRatio}) => {
|
|
18
22
|
it(name, async () => {
|
|
19
23
|
const image = await makeImage(`./test/fixtures/pattern/${name}.png`)
|
|
20
24
|
const result = findPattern(await image.toObject(), {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
pixelRatio,
|
|
26
|
+
mask: [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1],
|
|
27
|
+
offset,
|
|
28
|
+
size: 1,
|
|
24
29
|
})
|
|
25
30
|
assert.deepStrictEqual(result, position)
|
|
26
31
|
})
|