@applitools/screenshoter
Advanced tools
Comparing version 3.5.1 to 3.5.2
{ | ||
"name": "@applitools/screenshoter", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "Applitools universal screenshoter for web and native applications", | ||
@@ -75,6 +75,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@applitools/image": "1.0.1", | ||
"@applitools/logger": "1.1.16", | ||
"@applitools/image": "1.0.2", | ||
"@applitools/logger": "1.1.20", | ||
"@applitools/snippets": "2.4.5", | ||
"@applitools/utils": "1.3.10", | ||
"@applitools/utils": "1.3.12", | ||
"jpeg-js": "0.4.4", | ||
@@ -85,5 +85,5 @@ "png-async": "0.9.4" | ||
"@applitools/bongo": "^2.2.0", | ||
"@applitools/driver": "^1.9.25", | ||
"@applitools/driver": "^1.9.28", | ||
"@applitools/scripts": "^1.1.0", | ||
"@applitools/spec-driver-webdriverio": "^1.2.19", | ||
"@applitools/spec-driver-webdriverio": "^1.2.20", | ||
"@applitools/test-utils": "^1.5.1", | ||
@@ -90,0 +90,0 @@ "appium": "^1.22.3", |
@@ -40,2 +40,3 @@ const utils = require('@applitools/utils') | ||
} | ||
let returnRegion, scrollingElement | ||
@@ -45,19 +46,20 @@ if (fully) { | ||
// if element is scrollable, then take screenshot of the full element content, otherwise take screenshot of full element | ||
const region = isScrollable ? null : await element.getRegion() | ||
const scrollingElement = isScrollable ? element : await elementContext.getScrollingElement() | ||
returnRegion = isScrollable ? null : await element.getRegion() | ||
scrollingElement = isScrollable ? element : await elementContext.getScrollingElement() | ||
// css stitching could be applied only to root element of its context | ||
scrollingMode = scrollingMode === 'css' && !(await scrollingElement.isRoot()) ? 'mixed+' : scrollingMode | ||
return { | ||
context: elementContext, | ||
region, | ||
scroller: makeScroller({element: scrollingElement, scrollingMode, logger}), | ||
} | ||
} else { | ||
const scrollingElement = await context.getScrollingElement() | ||
return { | ||
context: elementContext, | ||
region: await element.getRegion(), | ||
scroller: makeScroller({element: scrollingElement, scrollingMode, logger}), | ||
} | ||
scrollingElement = await context.getScrollingElement() | ||
returnRegion = await element.getRegion() | ||
} | ||
const scroller = makeScroller({element: scrollingElement, scrollingMode, logger}) | ||
if (returnRegion && !element.driver.isNative && !(await scrollingElement.isRoot())) { | ||
const scrollerOffset = await scroller.getScrollOffset() | ||
returnRegion = utils.geometry.offset(returnRegion, scrollerOffset) | ||
} | ||
return { | ||
context: elementContext, | ||
region: returnRegion, | ||
scroller, | ||
} | ||
} | ||
@@ -64,0 +66,0 @@ } else if (!context.isMain) { |
@@ -67,53 +67,54 @@ const {makeLogger} = require('@applitools/logger') | ||
try { | ||
// TODO: identify spot in this function to call to takeScreenshot in the nml-client | ||
// if running on native mobile and the user has enabled NML | ||
if (!window && !driver.isNative) await scrollIntoViewport({...target, logger}) | ||
if (!window && !driver.isNative) await scrollIntoViewport({...target, logger}) | ||
if (fully && !target.region && target.scroller) await target.scroller.moveTo({x: 0, y: 0}) | ||
if (fully && !target.region && target.scroller) await target.scroller.moveTo({x: 0, y: 0}) | ||
const screenshot = | ||
fully && target.scroller | ||
? await takeStitchedScreenshot({ | ||
...target, | ||
withStatusBar, | ||
overlap, | ||
framed, | ||
wait, | ||
stabilization, | ||
debug, | ||
logger, | ||
lazyLoad, | ||
}) | ||
: await takeSimpleScreenshot({...target, withStatusBar, wait, stabilization, debug, logger}) | ||
const screenshot = | ||
fully && target.scroller | ||
? await takeStitchedScreenshot({ | ||
...target, | ||
withStatusBar, | ||
overlap, | ||
framed, | ||
wait, | ||
stabilization, | ||
debug, | ||
logger, | ||
lazyLoad, | ||
}) | ||
: await takeSimpleScreenshot({...target, withStatusBar, wait, stabilization, debug, logger}) | ||
screenshot.image.scale(driver.viewportScale) | ||
screenshot.image.scale(driver.viewportScale) | ||
const caltulatedRegions = await extractCoodinatesForSelectorsAndElements({regionsToCalculate, screenshot, context}) | ||
const calculatedRegions = await extractCoodinatesForSelectorsAndElements({regionsToCalculate, screenshot, context}) | ||
if (hooks && hooks.afterScreenshot) { | ||
await hooks.afterScreenshot({driver, scroller: target.scroller, screenshot}) | ||
} | ||
if (hooks && hooks.afterScreenshot) { | ||
await hooks.afterScreenshot({driver, scroller: target.scroller, screenshot}) | ||
} | ||
return {screenshot, caltulatedRegions} | ||
} finally { | ||
if (target.scroller) { | ||
await target.scroller.restoreScrollbars() | ||
await target.scroller.restoreState() | ||
} | ||
return { | ||
...screenshot, | ||
scrollingElement: target.scroller && target.scroller.element, | ||
calculatedRegions, | ||
async restoreState() { | ||
if (target.scroller) { | ||
await target.scroller.restoreScrollbars() | ||
await target.scroller.restoreState() | ||
} | ||
// if there was active element and we have blurred it, then restore focus | ||
if (activeElement) await context.focusElement(activeElement) | ||
// if there was active element and we have blurred it, then restore focus | ||
if (activeElement) await context.focusElement(activeElement) | ||
// traverse from target context to the main context to restore scrollbars and context states | ||
for (const prevContext of context.path.reverse()) { | ||
const scrollingElement = await prevContext.getScrollingElement() | ||
if (scrollingElement) { | ||
if (driver.isWeb && hideScrollbars) await scrollingElement.restoreScrollbars() | ||
await scrollingElement.restoreState() | ||
// traverse from target context to the main context to restore scrollbars and context states | ||
for (const prevContext of context.path.reverse()) { | ||
const scrollingElement = await prevContext.getScrollingElement() | ||
if (scrollingElement) { | ||
if (driver.isWeb && hideScrollbars) await scrollingElement.restoreScrollbars() | ||
await scrollingElement.restoreState() | ||
} | ||
} | ||
} | ||
// restore focus on original active context | ||
await activeContext.focus() | ||
// restore focus on original active context | ||
await activeContext.focus() | ||
}, | ||
} | ||
@@ -120,0 +121,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51748
750
+ Added@applitools/image@1.0.2(transitive)
+ Added@applitools/logger@1.1.20(transitive)
+ Added@applitools/types@1.5.13(transitive)
+ Added@applitools/utils@1.3.12(transitive)
- Removed@applitools/image@1.0.1(transitive)
- Removed@applitools/logger@1.1.16(transitive)
- Removed@applitools/utils@1.3.10(transitive)
Updated@applitools/image@1.0.2
Updated@applitools/logger@1.1.20
Updated@applitools/utils@1.3.12