@applitools/screenshoter 3.4.3 → 3.4.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/screenshoter",
3
- "version": "3.4.3",
3
+ "version": "3.4.6",
4
4
  "description": "Applitools universal screenshoter for web and native applications",
5
5
  "keywords": [
6
6
  "applitools",
@@ -70,17 +70,17 @@
70
70
  }
71
71
  },
72
72
  "dependencies": {
73
- "@applitools/logger": "1.1.12",
74
- "@applitools/snippets": "2.4.2",
75
- "@applitools/utils": "1.3.8",
73
+ "@applitools/logger": "1.1.13",
74
+ "@applitools/snippets": "2.4.3",
75
+ "@applitools/utils": "1.3.9",
76
76
  "jpeg-js": "0.4.4",
77
77
  "png-async": "0.9.4"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@applitools/bongo": "^2.1.5",
81
- "@applitools/driver": "^1.9.4",
81
+ "@applitools/driver": "^1.9.9",
82
82
  "@applitools/scripts": "1.1.0",
83
- "@applitools/spec-driver-webdriverio": "1.2.12",
83
+ "@applitools/spec-driver-webdriverio": "1.2.14",
84
84
  "@applitools/test-utils": "1.3.3",
85
85
  "appium": "^1.22.3",
86
86
  "chromedriver": "^101.0.0",
package/src/image.js CHANGED
@@ -372,7 +372,9 @@ async function copy(dstImage, srcImage, offset) {
372
372
  for (let chunk = 0; chunk < srcHeight; ++chunk) {
373
373
  const srcOffset = chunk * srcImage.width * 4
374
374
  const dstOffset = ((dstY + chunk) * dstImage.width + dstX) * 4
375
- dstImage.data.set(srcImage.data.subarray(srcOffset, srcOffset + chunkLength), dstOffset)
375
+ if (dstOffset >= 0) {
376
+ dstImage.data.set(srcImage.data.subarray(srcOffset, srcOffset + chunkLength), dstOffset)
377
+ }
376
378
  }
377
379
 
378
380
  return dstImage
@@ -53,11 +53,11 @@ async function takeStitchedScreenshot({
53
53
  : scrollerRegion
54
54
  logger.log('Target region calculated: ', targetRegion)
55
55
 
56
- const cropRegion = await driver.getRegionInViewport(context, targetRegion)
56
+ const cropRegion = utils.geometry.round(await driver.getRegionInViewport(context, targetRegion))
57
57
  logger.log('Crop region calculated: ', cropRegion)
58
58
  if (utils.geometry.isEmpty(cropRegion)) throw new Error('Screenshot region is out of viewport')
59
59
 
60
- image.crop(withStatusBar ? utils.geometry.offset(cropRegion, {x: 0, y: driver.statusBarHeight}) : cropRegion)
60
+ image.crop(withStatusBar ? utils.geometry.offset(cropRegion, {x: 0, y: driver.statusBarSize}) : cropRegion)
61
61
  await image.debug({...debug, name: 'initial', suffix: 'region'})
62
62
 
63
63
  const contentRegion = utils.geometry.region({x: 0, y: 0}, contentSize)
@@ -77,7 +77,7 @@ async function takeStitchedScreenshot({
77
77
  region.width += expectedRemainingOffset.x
78
78
  logger.verbose('region after compensation', region)
79
79
  }
80
- region = utils.geometry.round(region)
80
+ region = utils.geometry.floor(region)
81
81
 
82
82
  const [initialRegion, ...partRegions] = utils.geometry.divide(region, image.size, overlap)
83
83
  logger.verbose('Part regions', partRegions)
@@ -151,7 +151,7 @@ async function takeStitchedScreenshot({
151
151
  stitchedImage.frame(
152
152
  firstImage,
153
153
  lastImage,
154
- withStatusBar ? utils.geometry.offset(cropRegion, {x: 0, y: driver.statusBarHeight}) : cropRegion,
154
+ withStatusBar ? utils.geometry.offset(cropRegion, {x: 0, y: driver.statusBarSize}) : cropRegion,
155
155
  )
156
156
  await stitchedImage.debug({...debug, name: 'framed'})
157
157
 
@@ -99,7 +99,7 @@ function makeTakeMarkedScreenshot({driver, stabilization = {}, debug, logger}) {
99
99
  else image.scale(1 / driver.pixelRatio / driver.viewportScale)
100
100
 
101
101
  if (stabilization.rotate) image.rotate(stabilization.rotate)
102
- else if (driver.orientation === 'landscape' && image.width < image.height) image.rotate(-90)
102
+ else if (driver.orientation.startsWith('landscape') && image.width < image.height) image.rotate(-90)
103
103
 
104
104
  if (stabilization.crop) image.crop(stabilization.crop)
105
105
  else {
@@ -126,7 +126,7 @@ function makeTakeMarkedScreenshot({driver, stabilization = {}, debug, logger}) {
126
126
  const image = makeImage(await driver.takeScreenshot())
127
127
 
128
128
  if (stabilization.rotate) image.rotate(stabilization.rotate)
129
- else if (driver.orientation === 'landscape' && image.width < image.height) image.rotate(-90)
129
+ else if (driver.orientation.startsWith('landscape') && image.width < image.height) image.rotate(-90)
130
130
 
131
131
  await image.debug({...debug, name: 'marker'})
132
132
 
@@ -156,26 +156,24 @@ function makeTakeNativeScreenshot({driver, stabilization = {}, debug, logger}) {
156
156
  else image.scale(1 / driver.pixelRatio / driver.viewportScale)
157
157
 
158
158
  if (stabilization.rotate) image.rotate(stabilization.rotate)
159
- else if (driver.orientation === 'landscape' && image.width < image.height) image.rotate(-90)
159
+ else if (driver.orientation.startsWith('landscape') && image.width < image.height) image.rotate(-90)
160
160
 
161
161
  if (stabilization.crop) image.crop(stabilization.crop)
162
162
  else {
163
- const viewportSize = await driver.getViewportSize()
163
+ const viewportRegion = await driver.getViewportRegion()
164
+ const cropRegion = {...viewportRegion}
164
165
  if (withStatusBar) {
165
- image.crop({x: 0, y: 0, width: viewportSize.width, height: viewportSize.height + driver.statusBarHeight})
166
- } else if (driver.isAndroid && driver.orientation === 'landscape') {
167
- image.crop({
168
- top: driver.statusBarHeight,
169
- bottom: driver.orientation === 'landscape' ? 0 : driver.navigationBarHeight,
170
- left: driver.platformVersion >= 8 ? driver.navigationBarHeight : 0,
171
- right: driver.platformVersion < 8 ? driver.navigationBarHeight : 0,
172
- })
173
- } else {
174
- image.crop({x: 0, y: driver.statusBarHeight, width: viewportSize.width, height: viewportSize.height})
166
+ cropRegion.y = 0
167
+ cropRegion.height += driver.statusBarSize
175
168
  }
169
+ image.crop(cropRegion)
176
170
  }
177
171
 
178
- await image.debug({...debug, name, suffix: `viewport${withStatusBar ? '-with-statusbar' : ''}`})
172
+ await image.debug({
173
+ ...debug,
174
+ name,
175
+ suffix: `viewport${withStatusBar ? '-with-statusbar' : ''}`,
176
+ })
179
177
 
180
178
  return image
181
179
  }