Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/screenshoter

Package Overview
Dependencies
Maintainers
24
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/screenshoter - npm Package Compare versions

Comparing version 3.3.10 to 3.3.11

src/calculate-screenshot-region.js

6

CHANGELOG.md

@@ -7,2 +7,8 @@

## 3.3.11 - 2022/3/12
- disable scroll to 0,0 before taking stitched screenshot
- add better error handling when taking a stitched screenshot
- updated to @applitools/snippets@2.2.1 (from 2.2.0)
## 3.3.10 - 2022/2/16

@@ -9,0 +15,0 @@

19

package.json
{
"name": "@applitools/screenshoter",
"version": "3.3.10",
"version": "3.3.11",
"description": "Applitools universal screenshoter for web and native applications",

@@ -36,11 +36,11 @@ "keywords": [

"test": "yarn test:it && yarn test:e2e",
"test:unit": "mocha ./test/unit/*.spec.js --no-timeouts",
"test:it": "mocha ./test/it/*.spec.js --no-timeouts",
"test:e2e": "mocha ./test/e2e/**/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-1}",
"test:e2e:web": "mocha ./test/e2e/web/*.spec.js --no-timeouts -r @applitools/test-utils/mocha-hooks/docker --parallel --jobs ${MOCHA_JOBS:-15}",
"test:e2e:android": "mocha ./test/e2e/android*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-1}",
"test:e2e:ios": "mocha ./test/e2e/ios*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-1}",
"setup": "yarn docker:setup && yarn android:setup && yarn ios:setup && yarn appium:setup",
"test:e2e:android": "APPLITOOLS_TEST_REMOTE=sauce mocha ./test/e2e/android*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-2}",
"test:e2e:ios": "APPLITOOLS_TEST_REMOTE=sauce mocha ./test/e2e/ios*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-2}",
"setup:web": "yarn docker:setup",
"setup:android": "yarn android:setup && yarn appium:setup",
"setup:ios": "yarn ios:setup && yarn appium:setup",
"setup:android": "echo \"setup:android - do nothing\"",
"setup:ios": "echo \"setup:ios - do nothing\"",
"android:setup": "node ./scripts/android-emulator.js",

@@ -64,3 +64,3 @@ "android:shutdown": "adb -s emulator-5555 emu kill || true && adb -s emulator-5557 emu kill || true",

"dependencies": {
"@applitools/snippets": "2.1.15",
"@applitools/snippets": "2.2.1",
"@applitools/utils": "1.2.13",

@@ -70,6 +70,7 @@ "png-async": "0.9.4"

"devDependencies": {
"@applitools/driver": "1.4.16",
"@applitools/driver": "1.5.3",
"@applitools/scripts": "1.1.0",
"@applitools/sdk-release-kit": "0.13.11",
"@applitools/spec-driver-webdriverio": "1.2.7",
"@applitools/test-utils": "1.0.12",
"@applitools/test-utils": "1.1.5",
"appium": "^1.22.2",

@@ -76,0 +77,0 @@ "chromedriver": "^95.0.0",

@@ -87,2 +87,3 @@ const fs = require('fs')

transforms.crop = region
size = utils.geometry.size(transforms.crop)
return this

@@ -89,0 +90,0 @@ },

@@ -28,2 +28,3 @@ const utils = require('@applitools/utils')

if (scrollingMode === 'mixed') return shiftTo(offset, element)
if (scrollingMode === 'mixed+') return shiftTo(offset, element, {formerlyCssScrollingMode: true})
}

@@ -35,2 +36,3 @@

if (scrollingMode === 'mixed') return getShiftOffset(element)
if (scrollingMode === 'mixed+') return getShiftOffset(element)
}

@@ -106,5 +108,6 @@

async function shiftTo(offset, element = defaultElement) {
async function shiftTo(offset, element = defaultElement, {formerlyCssScrollingMode} = {}) {
try {
const scrollOffset = await element.scrollTo(offset)
if (utils.geometry.equals(scrollOffset, offset) && !formerlyCssScrollingMode) return scrollOffset

@@ -111,0 +114,0 @@ // there is a "bug" in iOS that will not move a root element if it already scrolled, so it should be translated all the way

@@ -53,3 +53,6 @@ const utils = require('@applitools/utils')

if (driver.isWeb && hideScrollbars) await target.scroller.hideScrollbars()
if (target.scroller) {
await target.scroller.preserveState()
if (driver.isWeb && hideScrollbars) await target.scroller.hideScrollbars()
}

@@ -67,6 +70,2 @@ try {

if (hooks && hooks.afterScreenshot) {
// imitate image-like state for the hook
if (window && fully && target.scroller) {
await target.scroller.moveTo({x: 0, y: 0}, await driver.mainContext.getScrollingElement())
}
await hooks.afterScreenshot({driver, scroller: target.scroller, screenshot})

@@ -79,2 +78,3 @@ }

await target.scroller.restoreScrollbars()
await target.scroller.restoreState()
}

@@ -129,3 +129,3 @@

// css stitching could be applied only to root element of its context
scrollingMode = scrollingMode === 'css' && !(await scrollingElement.isRoot()) ? 'mixed' : scrollingMode
scrollingMode = scrollingMode === 'css' && !(await scrollingElement.isRoot()) ? 'mixed+' : scrollingMode
return {

@@ -132,0 +132,0 @@ context: elementContext,

const utils = require('@applitools/utils')
const makeImage = require('./image')
const makeTakeViewportScreenshot = require('./take-viewport-screenshot')
const calculateScreenshotRegion = require('./calculate-screenshot-region')

@@ -24,4 +25,5 @@ async function takeStitchedScreenshot({

const initialOffset = region ? utils.geometry.location(region) : {x: 0, y: 0}
const actualOffset = await scroller.getInnerOffset()
const expectedRemainingOffset = utils.geometry.offsetNegative(initialOffset, actualOffset)
const preMoveOffset = await scroller.getInnerOffset()
const postMoveOffset = await scroller.moveTo(initialOffset)
const expectedRemainingOffset = utils.geometry.offsetNegative(initialOffset, postMoveOffset)

@@ -32,2 +34,13 @@ await utils.general.sleep(wait)

logger.verbose(
'preMoveOffset',
preMoveOffset,
'initialOffset',
initialOffset,
'postMoveOffset',
postMoveOffset,
'context.isMain',
context.isMain,
)
logger.verbose('Getting initial image...')

@@ -39,3 +52,3 @@ let image = await takeViewportScreenshot({name: 'initial', withStatusBar})

const targetRegion = region
? utils.geometry.intersect(utils.geometry.region(actualOffset, scrollerRegion), region)
? utils.geometry.intersect(utils.geometry.region(postMoveOffset, scrollerRegion), region)
: scrollerRegion

@@ -46,4 +59,5 @@

let cropRegion = driver.isNative ? targetRegion : await driver.getRegionInViewport(context, targetRegion)
if (utils.geometry.isEmpty(cropRegion)) throw new Error('Screenshot region is out of viewport')
logger.verbose('cropping...')
logger.verbose('cropping... cropRegion is', cropRegion)
image.crop(withStatusBar ? utils.geometry.offset(cropRegion, {x: 0, y: driver.statusBarHeight}) : cropRegion)

@@ -53,3 +67,3 @@ await image.debug({...debug, name: 'initial', suffix: 'region'})

const contentRegion = utils.geometry.region({x: 0, y: 0}, contentSize)
logger.verbose(`Scroller size: ${contentRegion}`)
logger.verbose('Scroller size:', contentRegion)

@@ -81,3 +95,3 @@ if (region) region = utils.geometry.intersect(region, contentRegion)

logger.verbose(`Move to ${requiredOffset}`)
logger.verbose('Move to', requiredOffset)
let actualOffset = await scroller.moveTo(requiredOffset)

@@ -103,3 +117,4 @@ // actual scroll position after scrolling might be not equal to required position due to

}
logger.verbose(`Actual offset is ${actualOffset}, remaining offset is ${remainingOffset}`)
logger.verbose('Actual offset is', actualOffset, ', remaining offset is', remainingOffset)
logger.verbose('cropPartRegion is', cropPartRegion)

@@ -136,3 +151,3 @@ await utils.general.sleep(wait)

image: stitchedImage,
region: utils.geometry.region({x: 0, y: 0}, stitchedImage.size),
region: calculateScreenshotRegion({stitchedImage, preMoveOffset, postMoveOffset}),
}

@@ -142,3 +157,3 @@ } else {

image: stitchedImage,
region: utils.geometry.region(cropRegion, stitchedImage.size),
region: calculateScreenshotRegion({cropRegion, stitchedImage, preMoveOffset, postMoveOffset}),
}

@@ -145,0 +160,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc