@applitools/screenshoter 3.5.5 → 3.6.1

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.5.5",
3
+ "version": "3.6.1",
4
4
  "description": "Applitools universal screenshoter for web and native applications",
5
5
  "keywords": [
6
6
  "applitools",
@@ -48,8 +48,8 @@
48
48
  "test:it": "mocha ./test/it/*.spec.js --no-timeouts",
49
49
  "test:e2e": "yarn test:e2e:web && yarn && yarn test:e2e:android && yarn test:e2e:ios",
50
50
  "test:e2e:web": "mocha ./test/e2e/web/*.spec.js --no-timeouts -r @applitools/test-utils/mocha-hooks/docker",
51
- "test:e2e:android": "APPLITOOLS_TEST_REMOTE=sauce mocha ./test/e2e/android*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-2}",
52
- "test:e2e:ios": "APPLITOOLS_TEST_REMOTE=sauce mocha ./test/e2e/ios*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-2}",
51
+ "test:e2e:android": "APPLITOOLS_TEST_REMOTE=sauce mocha ./test/e2e/android*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-3}",
52
+ "test:e2e:ios": "APPLITOOLS_TEST_REMOTE=sauce mocha ./test/e2e/ios*/*.spec.js --no-timeouts --parallel --jobs ${MOCHA_JOBS:-4}",
53
53
  "setup": "yarn setup:web",
54
54
  "setup:web": "yarn docker:setup",
55
55
  "setup:android": "echo \"setup:android - do nothing\"",
@@ -73,7 +73,7 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@applitools/image": "1.0.2",
76
- "@applitools/logger": "1.1.23",
76
+ "@applitools/logger": "1.1.25",
77
77
  "@applitools/snippets": "2.4.5",
78
78
  "@applitools/utils": "1.3.12",
79
79
  "jpeg-js": "0.4.4",
@@ -81,9 +81,9 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@applitools/bongo": "^2.2.0",
84
- "@applitools/driver": "^1.9.34",
85
- "@applitools/scripts": "^1.1.0",
86
- "@applitools/spec-driver-webdriverio": "^1.2.25",
84
+ "@applitools/driver": "^1.10.4",
85
+ "@applitools/scripts": "^1.2.0",
86
+ "@applitools/spec-driver-webdriverio": "^1.3.1",
87
87
  "@applitools/test-utils": "^1.5.1",
88
88
  "appium": "^1.22.3",
89
89
  "chromedriver": "^101.0.0",
@@ -23,13 +23,20 @@ async function takeScreenshot({
23
23
  debug,
24
24
  logger,
25
25
  lazyLoad,
26
+ webview,
26
27
  }) {
27
28
  debug =
28
29
  debug ||
29
30
  (process.env.APPLITOOLS_DEBUG_SCREENSHOTS_DIR ? {path: process.env.APPLITOOLS_DEBUG_SCREENSHOTS_DIR} : debug)
30
31
  logger = logger ? logger.extend({label: 'screenshoter'}) : makeLogger({label: 'screenshoter'})
32
+
31
33
  // screenshot of a window/app was requested (fully or viewport)
32
34
  const window = !region && (!frames || frames.length === 0)
35
+
36
+ // switch worlds as needed
37
+ if (webview && driver.isNative) await driver.switchWorld(typeof webview === 'string' ? {id: webview} : null)
38
+ if (window && !webview && driver.isWebView) await driver.switchWorld({goHome: true})
39
+
33
40
  // framed screenshots could be taken only when screenshot of window/app fully was requested
34
41
  framed = framed && fully && window
35
42
  // screenshots with status bar could be taken only when screenshot of app or framed app fully was requested
@@ -115,6 +122,9 @@ async function takeScreenshot({
115
122
 
116
123
  // restore focus on original active context
117
124
  await activeContext.focus()
125
+
126
+ // return driver to previous app world if switched
127
+ await driver.switchWorld({restoreState: true})
118
128
  },
119
129
  }
120
130
  }
@@ -7,7 +7,7 @@ function makeTakeViewportScreenshot(options) {
7
7
  const {driver} = options
8
8
  if (driver.isNative) {
9
9
  return makeTakeNativeScreenshot(options)
10
- } else if (driver.isIOS) {
10
+ } else if ((!driver.isEmulation && driver.isIOS) || driver.isWebView) {
11
11
  // safari on ios takes screenshot with browser and os interfaces
12
12
  return makeTakeMarkedScreenshot(options)
13
13
  } else if (driver.browserName === 'Firefox') {
@@ -28,7 +28,7 @@ function makeTakeViewportScreenshot(options) {
28
28
 
29
29
  function makeTakeDefaultScreenshot({driver, stabilization = {}, debug, logger}) {
30
30
  return async function takeScreenshot({name} = {}) {
31
- logger.verbose('Taking screenshot...')
31
+ logger.verbose('Taking screenshot (default)...')
32
32
  const image = makeImage(await driver.takeScreenshot())
33
33
  await image.debug({...debug, name, suffix: 'original'})
34
34
 
@@ -45,7 +45,7 @@ function makeTakeDefaultScreenshot({driver, stabilization = {}, debug, logger})
45
45
 
46
46
  function makeTakeMainContextScreenshot({driver, stabilization = {}, debug, logger}) {
47
47
  return async function takeScreenshot({name} = {}) {
48
- logger.verbose('Taking screenshot...')
48
+ logger.verbose('Taking screenshot (with forced main context)...')
49
49
  const originalContext = driver.currentContext
50
50
  await driver.mainContext.focus()
51
51
  const image = makeImage(await driver.takeScreenshot())
@@ -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.startsWith('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.startsWith('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