@applitools/screenshoter 3.3.1 → 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.
- package/CHANGELOG.md +22 -0
- package/package.json +23 -16
- package/src/find-image-pattern.js +2 -1
- package/src/image.js +15 -12
- package/src/scroll-into-viewport.js +16 -7
- package/src/take-viewport-screenshot.js +16 -38
- package/.bongo/dry-run/package-lock.json +0 -73
- package/.bongo/dry-run/package.json +0 -5
- package/.bongo/dry-run.tgz +0 -0
- package/.eslintrc +0 -39
- package/logs/screenshot_2021_12_16_19_06_06_332Z_full_app_failed_1639681566332.png +0 -0
- package/logs/screenshot_2021_12_16_19_15_59_935Z_full_app_failed_1639682159935.png +0 -0
- package/logs/screenshot_2021_12_16_19_33_20_679Z_full_app_failed_1639683200679.png +0 -0
- package/logs/screenshot_2021_12_16_19_37_22_120Z_ios_viewport_failed.png +0 -0
- package/logs/screenshot_2021_12_16_19_38_09_461Z_ios_full_page_failed.png +0 -0
- package/logs/screenshot_2021_12_16_19_59_45_182Z_ios_viewport_failed.png +0 -0
- package/test/e2e/android.spec.js +0 -292
- package/test/e2e/external.spec.js +0 -155
- package/test/e2e/ios.spec.js +0 -261
- package/test/e2e/web-ios.spec.js +0 -72
- package/test/e2e/web.spec.js +0 -334
- 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/app.png +0 -0
- package/test/fixtures/android/element.png +0 -0
- package/test/fixtures/android/region.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.cropped-rect.png +0 -0
- package/test/fixtures/image/house.cropped-region.png +0 -0
- package/test/fixtures/image/house.framed-higher-wider.png +0 -0
- package/test/fixtures/image/house.framed-higher.png +0 -0
- package/test/fixtures/image/house.framed-shorter-thinner.png +0 -0
- package/test/fixtures/image/house.framed-wider.png +0 -0
- package/test/fixtures/image/house.png +0 -0
- package/test/fixtures/image/house.rotated.png +0 -0
- package/test/fixtures/image/house.scaled.png +0 -0
- package/test/fixtures/image/house.stitched.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/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_nomarker.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait_noviewport.png +0 -0
- package/test/fixtures/web/element-fully.png +0 -0
- package/test/fixtures/web/element.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-frame-fully.png +0 -0
- package/test/fixtures/web/inner-frame.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/fixtures/web-ios/page.png +0 -0
- package/test/it/find-pattern.spec.js +0 -33
- package/test/it/image.spec.js +0 -146
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,28 @@
|
|
|
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
|
+
|
|
12
|
+
## 3.3.4 - 2021/12/23
|
|
13
|
+
|
|
14
|
+
- updated to @applitools/snippets@2.1.12 (from 2.1.11)
|
|
15
|
+
|
|
16
|
+
## 3.3.3 - 2021/12/22
|
|
17
|
+
|
|
18
|
+
- improve default rotation and scaling logic
|
|
19
|
+
- improve scroll into viewport algorithm
|
|
20
|
+
- fix lazy handling of image rotation
|
|
21
|
+
- updated to @applitools/snippets@2.1.11 (from 2.1.10)
|
|
22
|
+
- updated to @applitools/utils@1.2.5 (from 1.2.4)
|
|
23
|
+
|
|
24
|
+
## 3.3.2 - 2021/12/20
|
|
25
|
+
|
|
26
|
+
- add basic support of webview screenshots on ios
|
|
27
|
+
- updated to @applitools/snippets@2.1.10 (from 2.1.8)
|
|
28
|
+
|
|
7
29
|
## 3.3.1 - 2021/12/17
|
|
8
30
|
|
|
9
31
|
- no changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/screenshoter",
|
|
3
|
-
"version": "3.3.
|
|
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
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
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
|
|
37
|
-
"test:e2e": "mocha
|
|
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"
|
|
@@ -49,22 +55,23 @@
|
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
"dependencies": {
|
|
52
|
-
"@applitools/snippets": "2.1.
|
|
53
|
-
"@applitools/utils": "1.2.
|
|
58
|
+
"@applitools/snippets": "2.1.12",
|
|
59
|
+
"@applitools/utils": "1.2.11",
|
|
54
60
|
"png-async": "0.9.4"
|
|
55
61
|
},
|
|
56
62
|
"devDependencies": {
|
|
57
|
-
"@applitools/driver": "1.4.
|
|
58
|
-
"@applitools/sdk-release-kit": "0.13.
|
|
59
|
-
"@applitools/spec-driver-webdriverio": "1.2.
|
|
60
|
-
"@applitools/test-utils": "1.0.
|
|
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": "^
|
|
74
|
+
"mocha": "^9.2.0",
|
|
68
75
|
"pixelmatch": "^5.2.1",
|
|
69
76
|
"prettier": "1.19.0",
|
|
70
77
|
"webdriverio": "^7.16.7"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
function findImagePattern(image, pattern) {
|
|
2
2
|
for (let pixel = 0; pixel < image.width * image.height; ++pixel) {
|
|
3
3
|
if (isPattern(image, pixel, pattern)) {
|
|
4
|
-
|
|
4
|
+
const patterOffset = pattern.offset * pattern.pixelRatio
|
|
5
|
+
return {x: (pixel % image.width) - patterOffset, y: Math.floor(pixel / image.width) - patterOffset}
|
|
5
6
|
}
|
|
6
7
|
}
|
|
7
8
|
return null
|
package/src/image.js
CHANGED
|
@@ -38,7 +38,9 @@ function makeImage(data) {
|
|
|
38
38
|
return true
|
|
39
39
|
},
|
|
40
40
|
get size() {
|
|
41
|
-
return utils.geometry.round(
|
|
41
|
+
return utils.geometry.round(
|
|
42
|
+
utils.geometry.rotate(utils.geometry.scale(size, transforms.scale), transforms.rotate),
|
|
43
|
+
)
|
|
42
44
|
},
|
|
43
45
|
get transforms() {
|
|
44
46
|
return {...transforms}
|
|
@@ -51,6 +53,12 @@ function makeImage(data) {
|
|
|
51
53
|
},
|
|
52
54
|
scale(ratio) {
|
|
53
55
|
transforms.scale *= ratio
|
|
56
|
+
// size = utils.geometry.scale(size, ratio)
|
|
57
|
+
return this
|
|
58
|
+
},
|
|
59
|
+
rotate(degrees) {
|
|
60
|
+
transforms.rotate = (transforms.rotate + degrees) % 360
|
|
61
|
+
// size = utils.geometry.rotate(size, degrees)
|
|
54
62
|
return this
|
|
55
63
|
},
|
|
56
64
|
crop(region) {
|
|
@@ -64,17 +72,12 @@ function makeImage(data) {
|
|
|
64
72
|
} else {
|
|
65
73
|
region = utils.geometry.scale(region, 1 / transforms.scale)
|
|
66
74
|
}
|
|
67
|
-
region = utils.geometry.rotate(region, transforms.rotate)
|
|
68
|
-
|
|
75
|
+
region = utils.geometry.rotate(region, -transforms.rotate, utils.geometry.rotate(size, transforms.rotate))
|
|
76
|
+
region = transforms.crop
|
|
69
77
|
? utils.geometry.intersect(transforms.crop, utils.geometry.offset(region, transforms.crop))
|
|
70
78
|
: utils.geometry.intersect({x: 0, y: 0, ...size}, region)
|
|
71
|
-
|
|
72
|
-
size = utils.geometry.
|
|
73
|
-
|
|
74
|
-
return this
|
|
75
|
-
},
|
|
76
|
-
rotate(degree) {
|
|
77
|
-
transforms.rotate = (transforms.rotate + degree) % 360
|
|
79
|
+
transforms.crop = region
|
|
80
|
+
size = utils.geometry.size(transforms.crop)
|
|
78
81
|
return this
|
|
79
82
|
},
|
|
80
83
|
copy(srcImage, offset) {
|
|
@@ -204,9 +207,9 @@ async function transform(image, transforms) {
|
|
|
204
207
|
}
|
|
205
208
|
}, image)
|
|
206
209
|
|
|
207
|
-
image = transforms.rotate > 0 ? await rotate(image, transforms.rotate) : image
|
|
208
210
|
image = transforms.crop ? await extract(image, transforms.crop) : image
|
|
209
211
|
image = transforms.scale !== 1 ? await scale(image, transforms.scale) : image
|
|
212
|
+
image = transforms.rotate !== 0 ? await rotate(image, transforms.rotate) : image
|
|
210
213
|
return image
|
|
211
214
|
}
|
|
212
215
|
|
|
@@ -296,7 +299,7 @@ async function rotate(image, degrees) {
|
|
|
296
299
|
for (let srcY = 0, dstX = 0; srcY < image.height; ++srcY, ++dstX) {
|
|
297
300
|
for (let srcX = 0, dstY = image.width - 1; srcX < image.width; ++srcX, --dstY) {
|
|
298
301
|
const pixel = image.data.readUInt32BE((srcY * image.width + srcX) * 4)
|
|
299
|
-
dstImage.data.writeUInt32BE(pixel, (
|
|
302
|
+
dstImage.data.writeUInt32BE(pixel, (dstY * dstImage.width + dstX) * 4)
|
|
300
303
|
}
|
|
301
304
|
}
|
|
302
305
|
} else {
|
|
@@ -15,14 +15,23 @@ async function scrollIntoViewport({context, scroller, region, logger}) {
|
|
|
15
15
|
let remainingOffset = {x: elementContextRegion.x, y: elementContextRegion.y}
|
|
16
16
|
while (currentContext) {
|
|
17
17
|
const scrollingElement = await currentContext.getScrollingElement()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (!scrollingElement) {
|
|
19
|
+
currentContext = currentContext.parent
|
|
20
|
+
continue
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const scrollableRegion = await scrollingElement.getClientRegion()
|
|
24
|
+
const requiredOffset = {
|
|
25
|
+
x: Math.max(
|
|
26
|
+
remainingOffset.x - (scrollableRegion.x + Math.max(scrollableRegion.width - elementContextRegion.width, 0)),
|
|
27
|
+
0,
|
|
28
|
+
),
|
|
29
|
+
y: Math.max(
|
|
30
|
+
remainingOffset.y - (scrollableRegion.y + Math.max(scrollableRegion.height - elementContextRegion.height, 0)),
|
|
31
|
+
0,
|
|
32
|
+
),
|
|
33
|
+
}
|
|
34
|
+
const actualOffset = await scroller.moveTo(requiredOffset, scrollingElement)
|
|
26
35
|
|
|
27
36
|
remainingOffset = utils.geometry.offset(
|
|
28
37
|
utils.geometry.offsetNegative(remainingOffset, actualOffset),
|
|
@@ -7,6 +7,9 @@ function makeTakeViewportScreenshot(options) {
|
|
|
7
7
|
const {driver} = options
|
|
8
8
|
if (driver.isNative) {
|
|
9
9
|
return makeTakeNativeScreenshot(options)
|
|
10
|
+
} else if (driver.isIOS) {
|
|
11
|
+
// safari on ios takes screenshot with browser and os interfaces
|
|
12
|
+
return makeTakeMarkedScreenshot(options)
|
|
10
13
|
} else if (driver.browserName === 'Firefox') {
|
|
11
14
|
try {
|
|
12
15
|
const browserVersion = Number.parseInt(driver.browserVersion, 10)
|
|
@@ -15,28 +18,22 @@ function makeTakeViewportScreenshot(options) {
|
|
|
15
18
|
return makeTakeMainContextScreenshot(options)
|
|
16
19
|
}
|
|
17
20
|
} catch (ignored) {}
|
|
18
|
-
} else if (driver.browserName === 'Safari') {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return makeTakeMarkedScreenshot(options)
|
|
22
|
-
} else if (driver.browserVersion === '11') {
|
|
23
|
-
// safari 11 on macs takes full page screenshot
|
|
24
|
-
return makeTakeSafari11Screenshot(options)
|
|
25
|
-
}
|
|
21
|
+
} else if (driver.browserName === 'Safari' && driver.browserVersion === '11') {
|
|
22
|
+
// safari 11 on macs takes full page screenshot
|
|
23
|
+
return makeTakeSafari11Screenshot(options)
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
return makeTakeDefaultScreenshot(options)
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
function makeTakeDefaultScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
32
|
-
const calculateScaleRatio = makeCalculateScaleRatio({driver})
|
|
33
30
|
return async function takeScreenshot({name} = {}) {
|
|
34
31
|
logger.verbose('Taking screenshot...')
|
|
35
32
|
const image = makeImage(await driver.takeScreenshot())
|
|
36
33
|
await image.debug({...debug, name, suffix: 'original'})
|
|
37
34
|
|
|
38
35
|
if (stabilization.scale) image.scale(stabilization.scale)
|
|
39
|
-
else image.scale(
|
|
36
|
+
else image.scale(1 / driver.pixelRatio)
|
|
40
37
|
|
|
41
38
|
if (stabilization.rotate) image.crop(stabilization.rotate)
|
|
42
39
|
|
|
@@ -47,7 +44,6 @@ function makeTakeDefaultScreenshot({driver, stabilization = {}, debug, logger})
|
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
function makeTakeMainContextScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
50
|
-
const calculateScaleRatio = makeCalculateScaleRatio({driver})
|
|
51
47
|
return async function takeScreenshot({name} = {}) {
|
|
52
48
|
logger.verbose('Taking screenshot...')
|
|
53
49
|
const originalContext = driver.currentContext
|
|
@@ -57,7 +53,7 @@ function makeTakeMainContextScreenshot({driver, stabilization = {}, debug, logge
|
|
|
57
53
|
await image.debug({...debug, name, suffix: 'original'})
|
|
58
54
|
|
|
59
55
|
if (stabilization.scale) image.scale(stabilization.scale)
|
|
60
|
-
else image.scale(
|
|
56
|
+
else image.scale(1 / driver.pixelRatio)
|
|
61
57
|
|
|
62
58
|
if (stabilization.rotate) image.rotate(stabilization.rotate)
|
|
63
59
|
|
|
@@ -68,7 +64,6 @@ function makeTakeMainContextScreenshot({driver, stabilization = {}, debug, logge
|
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
function makeTakeSafari11Screenshot({driver, stabilization = {}, debug, logger}) {
|
|
71
|
-
const calculateScaleRatio = makeCalculateScaleRatio({driver})
|
|
72
67
|
let viewportSize
|
|
73
68
|
|
|
74
69
|
return async function takeScreenshot({name} = {}) {
|
|
@@ -77,7 +72,7 @@ function makeTakeSafari11Screenshot({driver, stabilization = {}, debug, logger})
|
|
|
77
72
|
await image.debug({...debug, name, suffix: 'original'})
|
|
78
73
|
|
|
79
74
|
if (stabilization.scale) image.scale(stabilization.scale)
|
|
80
|
-
else image.scale(
|
|
75
|
+
else image.scale(1 / driver.pixelRatio)
|
|
81
76
|
|
|
82
77
|
if (stabilization.rotate) image.rotate(stabilization.rotate)
|
|
83
78
|
|
|
@@ -93,7 +88,6 @@ function makeTakeSafari11Screenshot({driver, stabilization = {}, debug, logger})
|
|
|
93
88
|
}
|
|
94
89
|
|
|
95
90
|
function makeTakeMarkedScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
96
|
-
const calculateScaleRatio = makeCalculateScaleRatio({driver})
|
|
97
91
|
let viewportRegion
|
|
98
92
|
|
|
99
93
|
return async function takeScreenshot({name} = {}) {
|
|
@@ -102,9 +96,10 @@ function makeTakeMarkedScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
|
102
96
|
await image.debug({...debug, name, suffix: 'original'})
|
|
103
97
|
|
|
104
98
|
if (stabilization.scale) image.scale(stabilization.scale)
|
|
105
|
-
else image.scale(
|
|
99
|
+
else image.scale(1 / driver.pixelRatio)
|
|
106
100
|
|
|
107
101
|
if (stabilization.rotate) image.rotate(stabilization.rotate)
|
|
102
|
+
else if (driver.orientation === 'landscape' && image.width < image.height) image.rotate(-90)
|
|
108
103
|
|
|
109
104
|
if (stabilization.crop) image.crop(stabilization.crop)
|
|
110
105
|
else {
|
|
@@ -119,10 +114,13 @@ function makeTakeMarkedScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
|
119
114
|
|
|
120
115
|
async function getViewportRegion() {
|
|
121
116
|
const marker = await driver.mainContext.execute(snippets.addPageMarker)
|
|
117
|
+
await utils.general.sleep(100)
|
|
118
|
+
|
|
122
119
|
try {
|
|
123
120
|
const image = makeImage(await driver.takeScreenshot())
|
|
124
121
|
|
|
125
|
-
if (stabilization.rotate)
|
|
122
|
+
if (stabilization.rotate) image.rotate(stabilization.rotate)
|
|
123
|
+
else if (driver.orientation === 'landscape' && image.width < image.height) image.rotate(-90)
|
|
126
124
|
|
|
127
125
|
await image.debug({...debug, name: 'marker'})
|
|
128
126
|
|
|
@@ -148,6 +146,7 @@ function makeTakeNativeScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
|
148
146
|
else image.scale(1 / driver.pixelRatio)
|
|
149
147
|
|
|
150
148
|
if (stabilization.rotate) image.rotate(stabilization.rotate)
|
|
149
|
+
else if (driver.orientation === 'landscape' && image.width < image.height) image.rotate(-90)
|
|
151
150
|
|
|
152
151
|
if (stabilization.crop) image.crop(stabilization.crop)
|
|
153
152
|
else {
|
|
@@ -164,25 +163,4 @@ function makeTakeNativeScreenshot({driver, stabilization = {}, debug, logger}) {
|
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
function makeCalculateScaleRatio({driver}) {
|
|
168
|
-
let viewportWidth, contentWidth
|
|
169
|
-
const VIEWPORT_THRESHOLD = 1
|
|
170
|
-
const CONTENT_THRESHOLD = 10
|
|
171
|
-
return async function calculateScaleRatio(imageWidth) {
|
|
172
|
-
if (!viewportWidth) viewportWidth = await driver.getViewportSize().then(size => size.width)
|
|
173
|
-
if (!contentWidth) contentWidth = await driver.mainContext.getContentSize().then(size => size.width)
|
|
174
|
-
// If the image's width is the same as the viewport's width or the
|
|
175
|
-
// top level context's width, no scaling is necessary.
|
|
176
|
-
if (
|
|
177
|
-
(imageWidth >= viewportWidth - VIEWPORT_THRESHOLD && imageWidth <= viewportWidth + VIEWPORT_THRESHOLD) ||
|
|
178
|
-
(imageWidth >= contentWidth - CONTENT_THRESHOLD && imageWidth <= contentWidth + CONTENT_THRESHOLD)
|
|
179
|
-
) {
|
|
180
|
-
return 1
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const scaledImageWidth = Math.round(imageWidth / driver.pixelRatio)
|
|
184
|
-
return viewportWidth / scaledImageWidth / driver.pixelRatio
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
166
|
module.exports = makeTakeViewportScreenshot
|
|
@@ -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.0",
|
|
13
|
-
"resolved": "file:../dry-run.tgz",
|
|
14
|
-
"integrity": "sha512-zYK7fJkhpV4xrOXwkOo/WAjdH8m9vLaWZVaGAGv9iFWdVp/WkdoFfEfU0uo4TAiJeodkq90QWB5krBljy+CBKA==",
|
|
15
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@applitools/snippets": "2.1.8",
|
|
18
|
-
"@applitools/utils": "1.2.4",
|
|
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.8",
|
|
27
|
-
"resolved": "https://registry.npmjs.org/@applitools/snippets/-/snippets-2.1.8.tgz",
|
|
28
|
-
"integrity": "sha512-7CGFsbL9vAd6MBiGLVKHpKYywPXN499/fJMzEAVCLuGCY81CIc/PchqPFWrZZKZOY/IV21RJmE3MvqZAeXTIXA==",
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">=8.9.0"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"node_modules/@applitools/utils": {
|
|
34
|
-
"version": "1.2.4",
|
|
35
|
-
"resolved": "https://registry.npmjs.org/@applitools/utils/-/utils-1.2.4.tgz",
|
|
36
|
-
"integrity": "sha512-w7ma6FFGyqhdP6LEcuHFWOcH7EzBjnoAX3UfbFWcTHA3QXnXPX37Y2ENYRodfwkorP1cUKyUHwNXJB/BMIj/hg==",
|
|
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-zYK7fJkhpV4xrOXwkOo/WAjdH8m9vLaWZVaGAGv9iFWdVp/WkdoFfEfU0uo4TAiJeodkq90QWB5krBljy+CBKA==",
|
|
51
|
-
"requires": {
|
|
52
|
-
"@applitools/snippets": "2.1.8",
|
|
53
|
-
"@applitools/utils": "1.2.4",
|
|
54
|
-
"png-async": "0.9.4"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"@applitools/snippets": {
|
|
58
|
-
"version": "2.1.8",
|
|
59
|
-
"resolved": "https://registry.npmjs.org/@applitools/snippets/-/snippets-2.1.8.tgz",
|
|
60
|
-
"integrity": "sha512-7CGFsbL9vAd6MBiGLVKHpKYywPXN499/fJMzEAVCLuGCY81CIc/PchqPFWrZZKZOY/IV21RJmE3MvqZAeXTIXA=="
|
|
61
|
-
},
|
|
62
|
-
"@applitools/utils": {
|
|
63
|
-
"version": "1.2.4",
|
|
64
|
-
"resolved": "https://registry.npmjs.org/@applitools/utils/-/utils-1.2.4.tgz",
|
|
65
|
-
"integrity": "sha512-w7ma6FFGyqhdP6LEcuHFWOcH7EzBjnoAX3UfbFWcTHA3QXnXPX37Y2ENYRodfwkorP1cUKyUHwNXJB/BMIj/hg=="
|
|
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
|
-
}
|
package/.bongo/dry-run.tgz
DELETED
|
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
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|