webdriverio 8.16.17 → 8.16.19

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.
@@ -21,7 +21,7 @@
21
21
  * ```js
22
22
  * // print all image sources
23
23
  * for await (const img of $$('img')) {
24
- * console.log(await img.getAttribute('src))
24
+ * console.log(await img.getAttribute('src'))
25
25
  * }
26
26
  * ```
27
27
  *
@@ -21,7 +21,7 @@
21
21
  * ```js
22
22
  * // print all image sources
23
23
  * for await (const img of $$('img')) {
24
- * console.log(await img.getAttribute('src))
24
+ * console.log(await img.getAttribute('src'))
25
25
  * }
26
26
  * ```
27
27
  *
@@ -38,59 +38,59 @@ export async function scrollIntoView(options = { block: 'start', inline: 'neares
38
38
  if (browser.isMobile) {
39
39
  return scrollIntoViewWeb.call(this, options);
40
40
  }
41
- /**
42
- * by default the WebDriver action scrolls the element just into the
43
- * viewport. In order to stay complaint with `Element.scrollIntoView()`
44
- * we need to adjust the values a bit.
45
- */
46
- const elemRect = await browser.getElementRect(this.elementId);
47
- const viewport = await browser.getWindowSize();
48
- let [scrollX, scrollY] = await browser.execute(() => [
49
- window.scrollX, window.scrollY
50
- ]);
51
- // handle elements outside of the viewport
52
- scrollX = elemRect.x <= viewport.width ? elemRect.x : viewport.width / 2;
53
- scrollY = elemRect.y <= viewport.height ? elemRect.y : viewport.height / 2;
54
- const deltaByOption = {
55
- start: { y: elemRect.y - elemRect.height, x: elemRect.x - elemRect.width },
56
- center: { y: elemRect.y - Math.round((viewport.height - elemRect.height) / 2), x: elemRect.x - Math.round((viewport.width - elemRect.width) / 2) },
57
- end: { y: elemRect.y - (viewport.height - elemRect.height), x: elemRect.x - (viewport.width - elemRect.width) }
58
- };
59
- let [deltaX, deltaY] = [deltaByOption.start.x, deltaByOption.start.y];
60
- if (options === true) {
61
- options = { block: 'start', inline: 'nearest' };
62
- }
63
- if (options === false) {
64
- options = { block: 'end', inline: 'nearest' };
65
- }
66
- if (options && typeof options === 'object') {
67
- const { block, inline } = options;
68
- if (block === 'nearest') {
69
- const nearestYDistance = Math.min(...Object.values(deltaByOption).map(delta => delta.y));
70
- deltaY = Object.values(deltaByOption).find(delta => delta.y === nearestYDistance).y;
71
- }
72
- else if (block) {
73
- deltaY = deltaByOption[block].y;
41
+ try {
42
+ /**
43
+ * by default the WebDriver action scrolls the element just into the
44
+ * viewport. In order to stay complaint with `Element.scrollIntoView()`
45
+ * we need to adjust the values a bit.
46
+ */
47
+ const elemRect = await browser.getElementRect(this.elementId);
48
+ const viewport = await browser.getWindowSize();
49
+ let [scrollX, scrollY] = await browser.execute(() => [
50
+ window.scrollX, window.scrollY
51
+ ]);
52
+ // handle elements outside of the viewport
53
+ scrollX = elemRect.x <= viewport.width ? elemRect.x : viewport.width / 2;
54
+ scrollY = elemRect.y <= viewport.height ? elemRect.y : viewport.height / 2;
55
+ const deltaByOption = {
56
+ start: { y: elemRect.y - elemRect.height, x: elemRect.x - elemRect.width },
57
+ center: { y: elemRect.y - Math.round((viewport.height - elemRect.height) / 2), x: elemRect.x - Math.round((viewport.width - elemRect.width) / 2) },
58
+ end: { y: elemRect.y - (viewport.height - elemRect.height), x: elemRect.x - (viewport.width - elemRect.width) }
59
+ };
60
+ let [deltaX, deltaY] = [deltaByOption.start.x, deltaByOption.start.y];
61
+ if (options === true) {
62
+ options = { block: 'start', inline: 'nearest' };
74
63
  }
75
- if (inline === 'nearest') {
76
- const nearestXDistance = Math.min(...Object.values(deltaByOption).map(delta => delta.x));
77
- deltaX = Object.values(deltaByOption).find(delta => delta.x === nearestXDistance).x;
64
+ if (options === false) {
65
+ options = { block: 'end', inline: 'nearest' };
78
66
  }
79
- else if (inline) {
80
- deltaX = deltaByOption[inline].x;
67
+ if (options && typeof options === 'object') {
68
+ const { block, inline } = options;
69
+ if (block === 'nearest') {
70
+ const nearestYDistance = Math.min(...Object.values(deltaByOption).map(delta => delta.y));
71
+ deltaY = Object.values(deltaByOption).find(delta => delta.y === nearestYDistance).y;
72
+ }
73
+ else if (block) {
74
+ deltaY = deltaByOption[block].y;
75
+ }
76
+ if (inline === 'nearest') {
77
+ const nearestXDistance = Math.min(...Object.values(deltaByOption).map(delta => delta.x));
78
+ deltaX = Object.values(deltaByOption).find(delta => delta.x === nearestXDistance).x;
79
+ }
80
+ else if (inline) {
81
+ deltaX = deltaByOption[inline].x;
82
+ }
81
83
  }
82
- }
83
- // take into account the current scroll position
84
- deltaX = Math.round(deltaX - scrollX);
85
- deltaY = Math.round(deltaY - scrollY);
86
- try {
87
- return await browser.action('wheel')
84
+ // take into account the current scroll position
85
+ deltaX = Math.round(deltaX - scrollX);
86
+ deltaY = Math.round(deltaY - scrollY);
87
+ await browser.action('wheel')
88
88
  .scroll({ duration: 0, x: deltaX, deltaY, origin: this })
89
89
  .perform();
90
90
  }
91
91
  catch (err) {
92
92
  log.warn(`Failed to execute "scrollIntoView" using WebDriver Actions API: ${err.message}!\n` +
93
93
  'Re-attempting using `Element.scrollIntoView` via Web API.');
94
- return scrollIntoViewWeb.call(this, options);
94
+ await scrollIntoViewWeb.call(this, options);
95
95
  }
96
96
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webdriverio",
3
3
  "description": "Next-gen browser and mobile automation test framework for Node.js",
4
- "version": "8.16.17",
4
+ "version": "8.16.19",
5
5
  "homepage": "https://webdriver.io",
6
6
  "author": "Christian Bromann <mail@bromann.dev>",
7
7
  "license": "MIT",
@@ -78,7 +78,7 @@
78
78
  "aria-query": "^5.0.0",
79
79
  "css-shorthand-properties": "^1.1.1",
80
80
  "css-value": "^0.0.1",
81
- "devtools-protocol": "^0.0.1188743",
81
+ "devtools-protocol": "^0.0.1203626",
82
82
  "grapheme-splitter": "^1.0.2",
83
83
  "import-meta-resolve": "^3.0.0",
84
84
  "is-plain-obj": "^4.1.0",
@@ -100,5 +100,5 @@
100
100
  "optional": true
101
101
  }
102
102
  },
103
- "gitHead": "5bb4539c96e11a7ece83630b30c0a54903b55c0e"
103
+ "gitHead": "d05091c0a00cbe739f68ad8fd1fdcf577855002a"
104
104
  }