@applitools/screenshoter 3.2.9 → 3.3.3
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 +19 -19
- package/.bongo/dry-run.tgz +0 -0
- package/CHANGELOG.md +23 -0
- package/docker-compose.yaml +29 -0
- package/index.js +2 -1
- package/package.json +6 -6
- package/src/find-image-pattern.js +11 -38
- package/src/image.js +116 -73
- package/src/scroll-into-viewport.js +16 -7
- package/src/take-screenshot.js +136 -160
- package/src/take-simple-screenshot.js +25 -0
- package/src/take-stitched-screenshot.js +32 -52
- package/src/take-viewport-screenshot.js +157 -16
- package/test/e2e/android.spec.js +84 -11
- package/test/e2e/external.spec.js +81 -10
- package/test/e2e/ios.spec.js +129 -13
- package/test/e2e/web-ios.spec.js +44 -11
- package/test/e2e/web.spec.js +20 -15
- 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/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-ios/page-fully-landscape.png +0 -0
- package/test/fixtures/web-ios/page-fully.png +0 -0
- package/test/fixtures/web-ios/page-landscape.png +0 -0
- package/test/it/find-pattern.spec.js +16 -11
- package/test/it/image.spec.js +42 -15
- package/logs/screenshot_2021_11_14_12_35_00_342Z_full_frame_failed.png +0 -0
- package/logs/screenshot_2021_11_14_12_38_00_715Z_frame_failed.png +0 -0
- package/logs/screenshot_2021_11_14_12_38_03_866Z_frame_failed.png +0 -0
- package/logs/screenshot_2021_11_14_13_02_56_464Z_full_app_failed_1636894976464.png +0 -0
- package/logs/screenshot_2021_11_14_13_04_27_904Z_full_app_failed_1636895067904.png +0 -0
- package/logs/screenshot_2021_11_14_13_06_13_662Z_full_app_failed_1636895173662.png +0 -0
- package/logs/screenshot_2021_11_14_13_06_23_745Z_full_app_failed_1636895183745.png +0 -0
- package/logs/screenshot_2021_11_14_13_18_31_571Z_full_app_failed_1636895911571.png +0 -0
- package/logs/screenshot_2021_11_14_13_25_54_557Z_viewport_failed_1636896354557.png +0 -0
- package/logs/screenshot_2021_11_14_13_29_32_326Z_viewport_failed_1636896572326.png +0 -0
- package/logs/screenshot_2021_11_14_13_34_22_483Z_viewport_failed_1636896862483.png +0 -0
- package/logs/screenshot_2021_11_14_13_37_25_734Z_viewport_failed_1636897045734.png +0 -0
- package/logs/screenshot_2021_11_14_13_42_25_024Z_viewport_failed_1636897345024.png +0 -0
- package/logs/screenshot_2021_11_14_13_57_24_366Z_full_app_failed_1636898244366.png +0 -0
- package/logs/screenshot_2021_11_14_14_20_42_951Z_full_app_failed_1636899642951.png +0 -0
- package/logs/screenshot_2021_11_14_14_31_07_853Z_full_app_failed_1636900267853.png +0 -0
- package/logs/screenshot_2021_11_14_14_32_07_195Z_full_app_failed_1636900327195.png +0 -0
- package/logs/screenshot_2021_11_14_14_42_16_716Z_full_app_failed_1636900936716.png +0 -0
- package/logs/screenshot_2021_11_14_14_47_37_646Z_full_app_failed_1636901257646.png +0 -0
- package/logs/screenshot_2021_11_14_14_54_18_522Z_full_app_failed_1636901658522.png +0 -0
- package/logs/screenshot_2021_11_14_14_55_36_756Z_full_app_failed_1636901736756.png +0 -0
- package/logs/screenshot_2021_11_14_15_00_26_000Z_full_app_failed_1636902026000.png +0 -0
- package/logs/screenshot_2021_11_14_15_04_13_598Z_full_app_failed_1636902253598.png +0 -0
- package/logs/screenshot_2021_11_14_15_07_37_914Z_full_app_failed_1636902457914.png +0 -0
- package/logs/screenshot_2021_11_14_15_12_20_039Z_full_app_failed_1636902740039.png +0 -0
- package/logs/screenshot_2021_11_14_15_15_44_401Z_full_app_failed_1636902944401.png +0 -0
- package/logs/screenshot_2021_11_14_15_26_23_318Z_viewport_failed_1636903583318.png +0 -0
- package/src/calculate-screenshot-regions.js +0 -31
- package/src/screenshoter.js +0 -159
- 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/e2e/ios.spec.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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
5
|
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
6
|
const makeImage = require('../../src/image')
|
|
6
|
-
const
|
|
7
|
+
const takeScreenshot = require('../../index')
|
|
7
8
|
|
|
8
9
|
const env = {
|
|
9
10
|
url: 'https://ondemand.saucelabs.com/wd/hub',
|
|
@@ -11,13 +12,22 @@ const env = {
|
|
|
11
12
|
name: 'iOS Screenshoter Test',
|
|
12
13
|
deviceName: 'iPhone 11 Pro Simulator',
|
|
13
14
|
platformName: 'iOS',
|
|
14
|
-
platformVersion: '
|
|
15
|
-
appiumVersion: '1.
|
|
15
|
+
platformVersion: '14.5',
|
|
16
|
+
appiumVersion: '1.21.0',
|
|
16
17
|
automationName: 'XCUITest',
|
|
17
|
-
app: 'https://applitools.jfrog.io/artifactory/Examples/IOSTestApp/1.
|
|
18
|
+
app: 'https://applitools.jfrog.io/artifactory/Examples/IOSTestApp/1.9/app/IOSTestApp.zip',
|
|
18
19
|
username: process.env.SAUCE_USERNAME,
|
|
19
20
|
accessKey: process.env.SAUCE_ACCESS_KEY,
|
|
20
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
|
+
// },
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
describe('screenshoter ios', () => {
|
|
@@ -77,6 +87,30 @@ describe('screenshoter ios', () => {
|
|
|
77
87
|
return fullApp({type: 'collection'})
|
|
78
88
|
})
|
|
79
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
|
+
|
|
80
114
|
it('take region screenshot', () => {
|
|
81
115
|
return region()
|
|
82
116
|
})
|
|
@@ -95,8 +129,12 @@ describe('screenshoter ios', () => {
|
|
|
95
129
|
|
|
96
130
|
async function app(options = {}) {
|
|
97
131
|
const expectedPath = `./test/fixtures/ios/app${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
132
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Empty table view'}
|
|
98
133
|
|
|
99
|
-
const
|
|
134
|
+
const button = await driver.element(buttonSelector)
|
|
135
|
+
await button.click()
|
|
136
|
+
|
|
137
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
100
138
|
try {
|
|
101
139
|
if (options.withStatusBar) await sanitizeStatusBar(screenshot.image)
|
|
102
140
|
const actual = await screenshot.image.toObject()
|
|
@@ -108,8 +146,19 @@ describe('screenshoter ios', () => {
|
|
|
108
146
|
}
|
|
109
147
|
}
|
|
110
148
|
async function fullApp({type, ...options} = {}) {
|
|
111
|
-
let buttonSelector, expectedPath
|
|
112
|
-
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') {
|
|
113
162
|
buttonSelector = {type: 'accessibility id', selector: 'Collection view'}
|
|
114
163
|
expectedPath = `./test/fixtures/ios/app-fully-collection${options.withStatusBar ? '-statusbar' : ''}.png`
|
|
115
164
|
} else if (type === 'table') {
|
|
@@ -123,13 +172,16 @@ describe('screenshoter ios', () => {
|
|
|
123
172
|
const button = await driver.element(buttonSelector)
|
|
124
173
|
await button.click()
|
|
125
174
|
|
|
126
|
-
|
|
175
|
+
await driver.init()
|
|
176
|
+
|
|
177
|
+
const screenshot = await takeScreenshot({
|
|
127
178
|
logger,
|
|
128
179
|
driver,
|
|
129
180
|
fully: true,
|
|
130
181
|
framed: true,
|
|
131
182
|
scrollingMode: 'scroll',
|
|
132
183
|
wait: 1500,
|
|
184
|
+
overlap: {top: 10, bottom: 50, ...overlap},
|
|
133
185
|
...options,
|
|
134
186
|
})
|
|
135
187
|
try {
|
|
@@ -142,8 +194,72 @@ describe('screenshoter ios', () => {
|
|
|
142
194
|
throw err
|
|
143
195
|
}
|
|
144
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
|
+
console.log(webview)
|
|
207
|
+
await driver.target.switchContext(webview)
|
|
208
|
+
|
|
209
|
+
await driver.init()
|
|
210
|
+
|
|
211
|
+
const screenshot = await takeScreenshot({logger, driver, wait: 1500, ...options})
|
|
212
|
+
try {
|
|
213
|
+
const actual = await screenshot.image.toObject()
|
|
214
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
215
|
+
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
216
|
+
} catch (err) {
|
|
217
|
+
await screenshot.image.debug({path: './logs', name: 'webview_failed', suffix: Date.now()})
|
|
218
|
+
throw err
|
|
219
|
+
} finally {
|
|
220
|
+
await driver.target.switchContext('NATIVE_APP')
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async function fullWebview(options) {
|
|
224
|
+
const expectedPath = `./test/fixtures/ios/webview-fully.png`
|
|
225
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Web view'}
|
|
226
|
+
|
|
227
|
+
const button = await driver.element(buttonSelector)
|
|
228
|
+
await button.click()
|
|
229
|
+
await driver.target.getContexts()
|
|
230
|
+
await utils.general.sleep(500)
|
|
231
|
+
const [, webview] = await driver.target.getContexts()
|
|
232
|
+
await driver.target.switchContext(webview)
|
|
233
|
+
|
|
234
|
+
await driver.init()
|
|
235
|
+
const screenshot = await takeScreenshot({
|
|
236
|
+
logger,
|
|
237
|
+
driver,
|
|
238
|
+
wait: 1500,
|
|
239
|
+
fully: true,
|
|
240
|
+
scrollingMode: 'scroll',
|
|
241
|
+
...options,
|
|
242
|
+
})
|
|
243
|
+
try {
|
|
244
|
+
const actual = await screenshot.image.toObject()
|
|
245
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
246
|
+
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
247
|
+
} catch (err) {
|
|
248
|
+
await screenshot.image.debug({path: './logs', name: 'full_webview_failed', suffix: Date.now()})
|
|
249
|
+
throw err
|
|
250
|
+
} finally {
|
|
251
|
+
await driver.target.switchContext('NATIVE_APP')
|
|
252
|
+
}
|
|
253
|
+
}
|
|
145
254
|
async function region(options) {
|
|
146
|
-
const
|
|
255
|
+
const expectedPath = `./test/fixtures/ios/region.png`
|
|
256
|
+
const buttonSelector = {type: 'accessibility id', selector: 'Empty table view'}
|
|
257
|
+
|
|
258
|
+
const button = await driver.element(buttonSelector)
|
|
259
|
+
await button.click()
|
|
260
|
+
|
|
261
|
+
await driver.init()
|
|
262
|
+
const screenshot = await takeScreenshot({
|
|
147
263
|
logger,
|
|
148
264
|
driver,
|
|
149
265
|
region: {x: 30, y: 500, height: 100, width: 200},
|
|
@@ -153,7 +269,7 @@ describe('screenshoter ios', () => {
|
|
|
153
269
|
})
|
|
154
270
|
try {
|
|
155
271
|
const actual = await screenshot.image.toObject()
|
|
156
|
-
const expected = await makeImage(
|
|
272
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
157
273
|
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
158
274
|
} catch (err) {
|
|
159
275
|
await screenshot.image.debug({path: './logs', name: 'region_failed'})
|
|
@@ -161,7 +277,7 @@ describe('screenshoter ios', () => {
|
|
|
161
277
|
}
|
|
162
278
|
}
|
|
163
279
|
async function fullRegion(options) {
|
|
164
|
-
const screenshot = await
|
|
280
|
+
const screenshot = await takeScreenshot({
|
|
165
281
|
logger,
|
|
166
282
|
driver,
|
|
167
283
|
region: {x: 30, y: 10, height: 700, width: 200},
|
|
@@ -179,7 +295,7 @@ describe('screenshoter ios', () => {
|
|
|
179
295
|
}
|
|
180
296
|
}
|
|
181
297
|
async function element(options) {
|
|
182
|
-
const screenshot = await
|
|
298
|
+
const screenshot = await takeScreenshot({
|
|
183
299
|
logger,
|
|
184
300
|
driver,
|
|
185
301
|
region: {type: 'accessibility id', selector: 'Table view'},
|
|
@@ -202,7 +318,7 @@ describe('screenshoter ios', () => {
|
|
|
202
318
|
})
|
|
203
319
|
await button.click()
|
|
204
320
|
|
|
205
|
-
const screenshot = await
|
|
321
|
+
const screenshot = await takeScreenshot({
|
|
206
322
|
logger,
|
|
207
323
|
driver,
|
|
208
324
|
region: {type: 'xpath', selector: '//XCUIElementTypeTable[1]'},
|
package/test/e2e/web-ios.spec.js
CHANGED
|
@@ -2,7 +2,7 @@ const assert = require('assert')
|
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
3
|
const {Driver} = require('@applitools/driver')
|
|
4
4
|
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
-
const
|
|
5
|
+
const takeScreenshot = require('../../index')
|
|
6
6
|
const makeImage = require('../../src/image')
|
|
7
7
|
|
|
8
8
|
const env = {
|
|
@@ -18,9 +18,20 @@ const env = {
|
|
|
18
18
|
username: process.env.SAUCE_USERNAME,
|
|
19
19
|
accessKey: process.env.SAUCE_ACCESS_KEY,
|
|
20
20
|
},
|
|
21
|
-
}
|
|
22
21
|
|
|
23
|
-
//
|
|
22
|
+
// url: 'http://0.0.0.0:4723/wd/hub',
|
|
23
|
+
// capabilities: {
|
|
24
|
+
// name: 'iOS Web Screenshoter Test',
|
|
25
|
+
// deviceName: 'iPhone 11 Pro',
|
|
26
|
+
// browserName: 'safari',
|
|
27
|
+
// platformName: 'iOS',
|
|
28
|
+
// platformVersion: '14.5',
|
|
29
|
+
// appiumVersion: '1.20.1',
|
|
30
|
+
// automationName: 'XCUITest',
|
|
31
|
+
// username: process.env.SAUCE_USERNAME,
|
|
32
|
+
// accessKey: process.env.SAUCE_ACCESS_KEY,
|
|
33
|
+
// },
|
|
34
|
+
}
|
|
24
35
|
|
|
25
36
|
describe('screenshoter web ios', () => {
|
|
26
37
|
const logger = {log: () => {}, warn: () => {}, error: () => {}, verbose: () => {}}
|
|
@@ -41,18 +52,33 @@ describe('screenshoter web ios', () => {
|
|
|
41
52
|
})
|
|
42
53
|
|
|
43
54
|
it('take viewport screenshot', () => {
|
|
44
|
-
return viewport()
|
|
55
|
+
return viewport({orientation: 'portrait'})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('take viewport screenshot with landscape orientation', () => {
|
|
59
|
+
return viewport({orientation: 'landscape'})
|
|
45
60
|
})
|
|
46
61
|
|
|
47
62
|
it('take full page screenshot', () => {
|
|
48
|
-
return fullPage()
|
|
63
|
+
return fullPage({orientation: 'portrait'})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('take full page screenshot with landscape orientation', () => {
|
|
67
|
+
return fullPage({orientation: 'landscape'})
|
|
49
68
|
})
|
|
50
69
|
|
|
51
|
-
async function viewport(options) {
|
|
52
|
-
const
|
|
70
|
+
async function viewport({orientation = 'portrait', ...options} = {}) {
|
|
71
|
+
const expectedPath = `./test/fixtures/web-ios/page${orientation === 'landscape' ? '-landscape' : ''}.png`
|
|
72
|
+
|
|
73
|
+
await driver.target.setOrientation(orientation.toUpperCase())
|
|
74
|
+
await driver.visit(await driver.getUrl())
|
|
75
|
+
|
|
76
|
+
await driver.init()
|
|
77
|
+
|
|
78
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
53
79
|
try {
|
|
54
80
|
const actual = await screenshot.image.toObject()
|
|
55
|
-
const expected = await makeImage(
|
|
81
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
56
82
|
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
57
83
|
} catch (err) {
|
|
58
84
|
await screenshot.image.debug({path: './logs', name: 'ios_viewport_failed'})
|
|
@@ -60,11 +86,18 @@ describe('screenshoter web ios', () => {
|
|
|
60
86
|
}
|
|
61
87
|
}
|
|
62
88
|
|
|
63
|
-
async function fullPage(options) {
|
|
64
|
-
const
|
|
89
|
+
async function fullPage({orientation = 'portrait', ...options} = {}) {
|
|
90
|
+
const expectedPath = `./test/fixtures/web-ios/page-fully${orientation === 'landscape' ? '-landscape' : ''}.png`
|
|
91
|
+
|
|
92
|
+
await driver.target.setOrientation(orientation.toUpperCase())
|
|
93
|
+
await driver.visit(await driver.getUrl())
|
|
94
|
+
|
|
95
|
+
await driver.init()
|
|
96
|
+
|
|
97
|
+
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
65
98
|
try {
|
|
66
99
|
const actual = await screenshot.image.toObject()
|
|
67
|
-
const expected = await makeImage(
|
|
100
|
+
const expected = await makeImage(expectedPath).toObject()
|
|
68
101
|
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
69
102
|
} catch (err) {
|
|
70
103
|
await screenshot.image.debug({path: './logs', name: 'ios_full_page_failed'})
|
package/test/e2e/web.spec.js
CHANGED
|
@@ -2,7 +2,7 @@ const assert = require('assert')
|
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
3
|
const {Driver} = require('@applitools/driver')
|
|
4
4
|
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
-
const
|
|
5
|
+
const takeScreenshot = require('../../index')
|
|
6
6
|
const makeImage = require('../../src/image')
|
|
7
7
|
|
|
8
8
|
const env = {
|
|
@@ -128,7 +128,7 @@ describe('screenshoter web', () => {
|
|
|
128
128
|
})
|
|
129
129
|
|
|
130
130
|
async function viewport(options) {
|
|
131
|
-
const screenshot = await
|
|
131
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
132
132
|
try {
|
|
133
133
|
const actual = await screenshot.image.toObject()
|
|
134
134
|
const expected = await makeImage('./test/fixtures/web/page.png').toObject()
|
|
@@ -139,7 +139,7 @@ describe('screenshoter web', () => {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
async function fullPage(options) {
|
|
142
|
-
const screenshot = await
|
|
142
|
+
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
143
143
|
try {
|
|
144
144
|
const actual = await screenshot.image.toObject()
|
|
145
145
|
const expected = await makeImage('./test/fixtures/web/page-fully.png').toObject()
|
|
@@ -150,7 +150,12 @@ describe('screenshoter web', () => {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
async function frame(options) {
|
|
153
|
-
const screenshot = await
|
|
153
|
+
const screenshot = await takeScreenshot({
|
|
154
|
+
logger,
|
|
155
|
+
driver,
|
|
156
|
+
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
157
|
+
...options,
|
|
158
|
+
})
|
|
154
159
|
try {
|
|
155
160
|
const actual = await screenshot.image.toObject()
|
|
156
161
|
const expected = await makeImage('./test/fixtures/web/frame.png').toObject()
|
|
@@ -161,7 +166,7 @@ describe('screenshoter web', () => {
|
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
168
|
async function fullFrame(options) {
|
|
164
|
-
const screenshot = await
|
|
169
|
+
const screenshot = await takeScreenshot({
|
|
165
170
|
logger,
|
|
166
171
|
driver,
|
|
167
172
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -179,7 +184,7 @@ describe('screenshoter web', () => {
|
|
|
179
184
|
}
|
|
180
185
|
async function region(options) {
|
|
181
186
|
const region = {x: 30, y: 500, height: 100, width: 200}
|
|
182
|
-
const screenshot = await
|
|
187
|
+
const screenshot = await takeScreenshot({logger, driver, region, ...options})
|
|
183
188
|
try {
|
|
184
189
|
const actual = await screenshot.image.toObject()
|
|
185
190
|
const expected = await makeImage('./test/fixtures/web/region.png').toObject()
|
|
@@ -191,7 +196,7 @@ describe('screenshoter web', () => {
|
|
|
191
196
|
}
|
|
192
197
|
async function fullRegion(options) {
|
|
193
198
|
const region = {x: 30, y: 500, height: 700, width: 200}
|
|
194
|
-
const screenshot = await
|
|
199
|
+
const screenshot = await takeScreenshot({logger, driver, region, fully: true, ...options})
|
|
195
200
|
try {
|
|
196
201
|
const actual = await screenshot.image.toObject()
|
|
197
202
|
const expected = await makeImage('./test/fixtures/web/region-fully.png').toObject()
|
|
@@ -202,7 +207,7 @@ describe('screenshoter web', () => {
|
|
|
202
207
|
}
|
|
203
208
|
}
|
|
204
209
|
async function element(options) {
|
|
205
|
-
const screenshot = await
|
|
210
|
+
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', ...options})
|
|
206
211
|
try {
|
|
207
212
|
const actual = await screenshot.image.toObject()
|
|
208
213
|
const expected = await makeImage('./test/fixtures/web/element.png').toObject()
|
|
@@ -213,7 +218,7 @@ describe('screenshoter web', () => {
|
|
|
213
218
|
}
|
|
214
219
|
}
|
|
215
220
|
async function fullElement(options) {
|
|
216
|
-
const screenshot = await
|
|
221
|
+
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', fully: true, ...options})
|
|
217
222
|
try {
|
|
218
223
|
const actual = await screenshot.image.toObject()
|
|
219
224
|
const expected = await makeImage('./test/fixtures/web/element-fully.png').toObject()
|
|
@@ -224,7 +229,7 @@ describe('screenshoter web', () => {
|
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
231
|
async function regionInFrame(options) {
|
|
227
|
-
const screenshot = await
|
|
232
|
+
const screenshot = await takeScreenshot({
|
|
228
233
|
logger,
|
|
229
234
|
driver,
|
|
230
235
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -241,7 +246,7 @@ describe('screenshoter web', () => {
|
|
|
241
246
|
}
|
|
242
247
|
}
|
|
243
248
|
async function fullRegionInFrame(options) {
|
|
244
|
-
const screenshot = await
|
|
249
|
+
const screenshot = await takeScreenshot({
|
|
245
250
|
logger,
|
|
246
251
|
driver,
|
|
247
252
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -259,7 +264,7 @@ describe('screenshoter web', () => {
|
|
|
259
264
|
}
|
|
260
265
|
}
|
|
261
266
|
async function elementInFrame(options) {
|
|
262
|
-
const screenshot = await
|
|
267
|
+
const screenshot = await takeScreenshot({
|
|
263
268
|
logger,
|
|
264
269
|
driver,
|
|
265
270
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -276,7 +281,7 @@ describe('screenshoter web', () => {
|
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
283
|
async function fullElementInFrame(options) {
|
|
279
|
-
const screenshot = await
|
|
284
|
+
const screenshot = await takeScreenshot({
|
|
280
285
|
logger,
|
|
281
286
|
driver,
|
|
282
287
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -294,7 +299,7 @@ describe('screenshoter web', () => {
|
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
async function frameInFrame(options) {
|
|
297
|
-
const screenshot = await
|
|
302
|
+
const screenshot = await takeScreenshot({
|
|
298
303
|
logger,
|
|
299
304
|
driver,
|
|
300
305
|
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
@@ -310,7 +315,7 @@ describe('screenshoter web', () => {
|
|
|
310
315
|
}
|
|
311
316
|
}
|
|
312
317
|
async function fullFrameInFrame(options) {
|
|
313
|
-
const screenshot = await
|
|
318
|
+
const screenshot = await takeScreenshot({
|
|
314
319
|
logger,
|
|
315
320
|
driver,
|
|
316
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
|
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
|
|
@@ -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
|
})
|