webdriverio 7.21.0 → 8.0.0-alpha.239

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.
Files changed (211) hide show
  1. package/build/cjs/index.d.ts +3 -0
  2. package/build/cjs/index.d.ts.map +1 -0
  3. package/build/cjs/index.js +13 -0
  4. package/build/cjs/package.json +3 -0
  5. package/build/commands/browser/$$.js +6 -9
  6. package/build/commands/browser/$.js +8 -11
  7. package/build/commands/browser/action.d.ts +128 -0
  8. package/build/commands/browser/action.d.ts.map +1 -0
  9. package/build/commands/browser/action.js +13 -0
  10. package/build/commands/browser/actions.d.ts +29 -0
  11. package/build/commands/browser/actions.d.ts.map +1 -0
  12. package/build/commands/browser/actions.js +30 -0
  13. package/build/commands/browser/call.js +1 -4
  14. package/build/commands/browser/custom$$.js +7 -10
  15. package/build/commands/browser/custom$.js +5 -8
  16. package/build/commands/browser/debug.js +8 -14
  17. package/build/commands/browser/deleteCookies.js +1 -4
  18. package/build/commands/browser/execute.js +3 -6
  19. package/build/commands/browser/executeAsync.js +3 -6
  20. package/build/commands/browser/getCookies.js +1 -4
  21. package/build/commands/browser/getPuppeteer.d.ts +1 -1
  22. package/build/commands/browser/getPuppeteer.d.ts.map +1 -1
  23. package/build/commands/browser/getPuppeteer.js +14 -21
  24. package/build/commands/browser/getWindowSize.js +3 -6
  25. package/build/commands/browser/keys.d.ts +20 -10
  26. package/build/commands/browser/keys.d.ts.map +1 -1
  27. package/build/commands/browser/keys.js +29 -24
  28. package/build/commands/browser/mock.d.ts +1 -1
  29. package/build/commands/browser/mock.d.ts.map +1 -1
  30. package/build/commands/browser/mock.js +12 -19
  31. package/build/commands/browser/mockClearAll.js +5 -11
  32. package/build/commands/browser/mockRestoreAll.js +5 -11
  33. package/build/commands/browser/newWindow.js +5 -11
  34. package/build/commands/browser/pause.js +1 -4
  35. package/build/commands/browser/react$$.d.ts.map +1 -1
  36. package/build/commands/browser/react$$.js +12 -16
  37. package/build/commands/browser/react$.d.ts.map +1 -1
  38. package/build/commands/browser/react$.js +10 -14
  39. package/build/commands/browser/reloadSession.js +5 -12
  40. package/build/commands/browser/savePDF.js +7 -13
  41. package/build/commands/browser/saveRecordingScreen.js +6 -12
  42. package/build/commands/browser/saveScreenshot.js +6 -12
  43. package/build/commands/browser/scroll.d.ts +25 -0
  44. package/build/commands/browser/scroll.d.ts.map +1 -0
  45. package/build/commands/browser/scroll.js +41 -0
  46. package/build/commands/browser/setCookies.js +1 -4
  47. package/build/commands/browser/setTimeout.js +1 -4
  48. package/build/commands/browser/setWindowSize.js +3 -6
  49. package/build/commands/browser/switchWindow.js +1 -4
  50. package/build/commands/browser/throttle.js +3 -6
  51. package/build/commands/browser/touchAction.d.ts +1 -1
  52. package/build/commands/browser/touchAction.d.ts.map +1 -1
  53. package/build/commands/browser/touchAction.js +3 -6
  54. package/build/commands/browser/uploadFile.d.ts +1 -1
  55. package/build/commands/browser/uploadFile.d.ts.map +1 -1
  56. package/build/commands/browser/uploadFile.js +10 -15
  57. package/build/commands/browser/url.js +3 -6
  58. package/build/commands/browser/waitUntil.js +3 -9
  59. package/build/commands/browser.d.ts +39 -33
  60. package/build/commands/browser.d.ts.map +1 -1
  61. package/build/commands/browser.js +42 -43
  62. package/build/commands/constant.d.ts +1 -1
  63. package/build/commands/constant.d.ts.map +1 -1
  64. package/build/commands/constant.js +6 -12
  65. package/build/commands/element/$$.d.ts +1 -1
  66. package/build/commands/element/$$.d.ts.map +1 -1
  67. package/build/commands/element/$$.js +2 -7
  68. package/build/commands/element/$.d.ts +1 -1
  69. package/build/commands/element/$.d.ts.map +1 -1
  70. package/build/commands/element/$.js +2 -7
  71. package/build/commands/element/addValue.d.ts +10 -14
  72. package/build/commands/element/addValue.d.ts.map +1 -1
  73. package/build/commands/element/addValue.js +23 -27
  74. package/build/commands/element/clearValue.d.ts +1 -1
  75. package/build/commands/element/clearValue.js +2 -5
  76. package/build/commands/element/click.d.ts +1 -1
  77. package/build/commands/element/click.d.ts.map +1 -1
  78. package/build/commands/element/click.js +19 -34
  79. package/build/commands/element/custom$$.js +9 -11
  80. package/build/commands/element/custom$.js +8 -10
  81. package/build/commands/element/doubleClick.d.ts.map +1 -1
  82. package/build/commands/element/doubleClick.js +11 -17
  83. package/build/commands/element/dragAndDrop.d.ts.map +1 -1
  84. package/build/commands/element/dragAndDrop.js +13 -19
  85. package/build/commands/element/getAttribute.js +1 -4
  86. package/build/commands/element/getCSSProperty.d.ts +1 -1
  87. package/build/commands/element/getCSSProperty.d.ts.map +1 -1
  88. package/build/commands/element/getCSSProperty.js +7 -13
  89. package/build/commands/element/getComputedLabel.js +1 -4
  90. package/build/commands/element/getComputedRole.js +1 -4
  91. package/build/commands/element/getHTML.js +7 -13
  92. package/build/commands/element/getLocation.js +3 -5
  93. package/build/commands/element/getProperty.d.ts +8 -8
  94. package/build/commands/element/getProperty.d.ts.map +1 -1
  95. package/build/commands/element/getProperty.js +5 -11
  96. package/build/commands/element/getSize.js +3 -5
  97. package/build/commands/element/getTagName.js +1 -4
  98. package/build/commands/element/getText.js +1 -4
  99. package/build/commands/element/getValue.js +1 -4
  100. package/build/commands/element/isClickable.js +7 -13
  101. package/build/commands/element/isDisplayed.js +9 -16
  102. package/build/commands/element/isDisplayedInViewport.js +7 -13
  103. package/build/commands/element/isEnabled.js +1 -4
  104. package/build/commands/element/isEqual.d.ts.map +1 -1
  105. package/build/commands/element/isEqual.js +9 -9
  106. package/build/commands/element/isExisting.js +1 -4
  107. package/build/commands/element/isFocused.js +7 -13
  108. package/build/commands/element/isSelected.js +1 -4
  109. package/build/commands/element/moveTo.d.ts.map +1 -1
  110. package/build/commands/element/moveTo.js +8 -13
  111. package/build/commands/element/nextElement.js +2 -5
  112. package/build/commands/element/parentElement.js +2 -5
  113. package/build/commands/element/previousElement.js +2 -5
  114. package/build/commands/element/react$$.d.ts.map +1 -1
  115. package/build/commands/element/react$$.js +13 -16
  116. package/build/commands/element/react$.d.ts.map +1 -1
  117. package/build/commands/element/react$.js +12 -14
  118. package/build/commands/element/saveScreenshot.js +6 -12
  119. package/build/commands/element/scrollIntoView.d.ts +3 -2
  120. package/build/commands/element/scrollIntoView.d.ts.map +1 -1
  121. package/build/commands/element/scrollIntoView.js +32 -12
  122. package/build/commands/element/selectByAttribute.js +3 -6
  123. package/build/commands/element/selectByIndex.js +3 -6
  124. package/build/commands/element/selectByVisibleText.js +3 -6
  125. package/build/commands/element/setValue.d.ts +13 -14
  126. package/build/commands/element/setValue.d.ts.map +1 -1
  127. package/build/commands/element/setValue.js +14 -17
  128. package/build/commands/element/shadow$$.d.ts +1 -1
  129. package/build/commands/element/shadow$$.d.ts.map +1 -1
  130. package/build/commands/element/shadow$$.js +3 -6
  131. package/build/commands/element/shadow$.js +3 -6
  132. package/build/commands/element/touchAction.js +3 -6
  133. package/build/commands/element/waitForClickable.js +1 -4
  134. package/build/commands/element/waitForDisplayed.js +1 -4
  135. package/build/commands/element/waitForEnabled.js +1 -4
  136. package/build/commands/element/waitForExist.js +1 -4
  137. package/build/commands/element/waitUntil.d.ts +1 -1
  138. package/build/commands/element/waitUntil.d.ts.map +1 -1
  139. package/build/commands/element/waitUntil.js +2 -7
  140. package/build/commands/element.d.ts +48 -48
  141. package/build/commands/element.d.ts.map +1 -1
  142. package/build/commands/element.js +57 -62
  143. package/build/constants.d.ts +66 -0
  144. package/build/constants.d.ts.map +1 -1
  145. package/build/constants.js +91 -12
  146. package/build/index.d.ts +64 -5
  147. package/build/index.d.ts.map +1 -1
  148. package/build/index.js +47 -85
  149. package/build/middlewares.d.ts +1 -1
  150. package/build/middlewares.js +11 -19
  151. package/build/multiremote.js +12 -20
  152. package/build/protocol-stub.d.ts.map +1 -1
  153. package/build/protocol-stub.js +4 -6
  154. package/build/scripts/getHTML.js +1 -4
  155. package/build/scripts/getProperty.d.ts +8 -8
  156. package/build/scripts/getProperty.d.ts.map +1 -1
  157. package/build/scripts/getProperty.js +1 -4
  158. package/build/scripts/isElementClickable.js +1 -4
  159. package/build/scripts/isElementDisplayed.js +1 -4
  160. package/build/scripts/isElementInViewport.js +1 -4
  161. package/build/scripts/isFocused.js +1 -4
  162. package/build/scripts/newWindow.js +1 -4
  163. package/build/scripts/resq.js +3 -9
  164. package/build/scripts/shadowFnFactory.js +2 -6
  165. package/build/types.d.ts +1 -5
  166. package/build/types.d.ts.map +1 -1
  167. package/build/types.js +1 -2
  168. package/build/utils/SevereServiceError.js +1 -4
  169. package/build/utils/Timer.d.ts.map +1 -1
  170. package/build/utils/Timer.js +1 -25
  171. package/build/utils/actions/base.d.ts +32 -0
  172. package/build/utils/actions/base.d.ts.map +1 -0
  173. package/build/utils/actions/base.js +78 -0
  174. package/build/utils/actions/index.d.ts +6 -0
  175. package/build/utils/actions/index.d.ts.map +1 -0
  176. package/build/utils/actions/index.js +5 -0
  177. package/build/utils/actions/key.d.ts +15 -0
  178. package/build/utils/actions/key.d.ts.map +1 -0
  179. package/build/utils/actions/key.js +22 -0
  180. package/build/utils/actions/pointer.d.ts +62 -0
  181. package/build/utils/actions/pointer.d.ts.map +1 -0
  182. package/build/utils/actions/pointer.js +76 -0
  183. package/build/utils/actions/wheel.d.ts +36 -0
  184. package/build/utils/actions/wheel.d.ts.map +1 -0
  185. package/build/utils/actions/wheel.js +20 -0
  186. package/build/utils/detectBackend.d.ts +1 -1
  187. package/build/utils/detectBackend.d.ts.map +1 -1
  188. package/build/utils/detectBackend.js +3 -7
  189. package/build/utils/findStrategy.js +11 -19
  190. package/build/utils/getElementObject.d.ts.map +1 -1
  191. package/build/utils/getElementObject.js +42 -31
  192. package/build/utils/implicitWait.js +3 -9
  193. package/build/utils/index.d.ts +2 -6
  194. package/build/utils/index.d.ts.map +1 -1
  195. package/build/utils/index.js +92 -142
  196. package/build/utils/interception/devtools.d.ts +1 -1
  197. package/build/utils/interception/devtools.d.ts.map +1 -1
  198. package/build/utils/interception/devtools.js +17 -23
  199. package/build/utils/interception/index.d.ts +2 -2
  200. package/build/utils/interception/index.d.ts.map +1 -1
  201. package/build/utils/interception/index.js +5 -11
  202. package/build/utils/interception/types.d.ts +1 -1
  203. package/build/utils/interception/types.d.ts.map +1 -1
  204. package/build/utils/interception/types.js +1 -2
  205. package/build/utils/interception/webdriver.d.ts +1 -1
  206. package/build/utils/interception/webdriver.d.ts.map +1 -1
  207. package/build/utils/interception/webdriver.js +5 -11
  208. package/build/utils/refetchElement.js +3 -9
  209. package/package.json +22 -11
  210. package/async.d.ts +0 -24
  211. package/sync.d.ts +0 -24
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { getBrowserObject } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Returns browser window size.
@@ -19,12 +17,11 @@ const utils_1 = require("../../utils");
19
17
  * @type window
20
18
  *
21
19
  */
22
- async function getWindowSize() {
23
- const browser = (0, utils_1.getBrowserObject)(this);
20
+ export default async function getWindowSize() {
21
+ const browser = getBrowserObject(this);
24
22
  if (!browser.isW3C) {
25
23
  return browser._getWindowSize();
26
24
  }
27
25
  const { width, height } = await browser.getWindowRect();
28
26
  return { width, height };
29
27
  }
30
- exports.default = getWindowSize;
@@ -1,22 +1,32 @@
1
1
  /**
2
2
  *
3
- * Send a sequence of key strokes to the active element. You can also use characters like
4
- * "Left arrow" or "Back space". WebdriverIO will take care of translating them into unicode
5
- * characters. You’ll find all supported characters [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
6
- * To do that, the value has to correspond to a key from the table.
3
+ * Send a sequence of key strokes to the "active" element. You can make an input element active by just clicking
4
+ * on it. To use characters like "Left arrow" or "Back space", import the `Key` object from the WebdriverIO package.
7
5
  *
8
- * Modifier like Ctrl, Shift, Alt and Meta will stay pressed so you need to trigger them again to release them.
9
- * Modifiying a click however requires you to use the WebDriver Actions API through the [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
6
+ * Modifier like `Control`, `Shift`, `Alt` and `Command` will stay pressed so you need to trigger them again to release
7
+ * them. Modifiying a click however requires you to use the WebDriver Actions API through the
8
+ * [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
9
+ *
10
+ * :::info
11
+ *
12
+ * Control keys differ based on the operating system the browser is running on, e.g. MacOS: `Command` and Windows: `Control`.
13
+ * WebdriverIO provides a cross browser modifier control key called `Ctrl` (see example below).
14
+ *
15
+ * :::
10
16
  *
11
17
  * <example>
12
18
  :keys.js
19
+ import { Key } from 'webdriverio'
20
+
13
21
  it('copies text out of active element', async () => {
22
+ await $('#username').setValue('anonymous')
23
+
14
24
  // copies text from an input element
15
- const input = await $('#username')
16
- await input.setValue('anonymous')
25
+ await browser.keys([Key.Ctrl, 'a', 'c])
17
26
 
18
- await browser.keys(['Meta', 'a'])
19
- await browser.keys(['Meta', 'c'])
27
+ // inserts text from clipboard into input element
28
+ await $('#username').click() // make input active element
29
+ await browser.keys([Key.Ctrl, 'v'])
20
30
  });
21
31
  * </example>
22
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/keys.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CACxB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,iBAoC3B"}
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/keys.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CACxB,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,iBAiC3B"}
@@ -1,25 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { checkUnicode } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
- * Send a sequence of key strokes to the active element. You can also use characters like
7
- * "Left arrow" or "Back space". WebdriverIO will take care of translating them into unicode
8
- * characters. You’ll find all supported characters [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
9
- * To do that, the value has to correspond to a key from the table.
4
+ * Send a sequence of key strokes to the "active" element. You can make an input element active by just clicking
5
+ * on it. To use characters like "Left arrow" or "Back space", import the `Key` object from the WebdriverIO package.
10
6
  *
11
- * Modifier like Ctrl, Shift, Alt and Meta will stay pressed so you need to trigger them again to release them.
12
- * Modifiying a click however requires you to use the WebDriver Actions API through the [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
7
+ * Modifier like `Control`, `Shift`, `Alt` and `Command` will stay pressed so you need to trigger them again to release
8
+ * them. Modifiying a click however requires you to use the WebDriver Actions API through the
9
+ * [performActions](https://webdriver.io/docs/api/webdriver#performactions) method.
10
+ *
11
+ * :::info
12
+ *
13
+ * Control keys differ based on the operating system the browser is running on, e.g. MacOS: `Command` and Windows: `Control`.
14
+ * WebdriverIO provides a cross browser modifier control key called `Ctrl` (see example below).
15
+ *
16
+ * :::
13
17
  *
14
18
  * <example>
15
19
  :keys.js
20
+ import { Key } from 'webdriverio'
21
+
16
22
  it('copies text out of active element', async () => {
23
+ await $('#username').setValue('anonymous')
24
+
17
25
  // copies text from an input element
18
- const input = await $('#username')
19
- await input.setValue('anonymous')
26
+ await browser.keys([Key.Ctrl, 'a', 'c])
20
27
 
21
- await browser.keys(['Meta', 'a'])
22
- await browser.keys(['Meta', 'c'])
28
+ // inserts text from clipboard into input element
29
+ await $('#username').click() // make input active element
30
+ await browser.keys([Key.Ctrl, 'v'])
23
31
  });
24
32
  * </example>
25
33
  *
@@ -27,18 +35,19 @@ const utils_1 = require("../../utils");
27
35
  * @see https://w3c.github.io/webdriver/#dispatching-actions
28
36
  *
29
37
  */
30
- function keys(value) {
38
+ export default function keys(value) {
31
39
  let keySequence = [];
40
+ const platformName = this.capabilities.platformName;
32
41
  /**
33
42
  * replace key with corresponding unicode character
34
43
  */
35
44
  if (typeof value === 'string') {
36
- keySequence = (0, utils_1.checkUnicode)(value, this.isDevTools);
45
+ keySequence = checkUnicode(value, this.isDevTools, platformName);
37
46
  }
38
47
  else if (Array.isArray(value)) {
39
48
  const charArray = value;
40
49
  for (const charSet of charArray) {
41
- keySequence = keySequence.concat((0, utils_1.checkUnicode)(charSet, this.isDevTools));
50
+ keySequence = keySequence.concat(checkUnicode(charSet, this.isDevTools, platformName));
42
51
  }
43
52
  }
44
53
  else {
@@ -53,12 +62,8 @@ function keys(value) {
53
62
  /**
54
63
  * W3C way of handle it key actions
55
64
  */
56
- const keyDownActions = keySequence.map((value) => ({ type: 'keyDown', value }));
57
- const keyUpActions = keySequence.map((value) => ({ type: 'keyUp', value }));
58
- return this.performActions([{
59
- type: 'key',
60
- id: 'keyboard',
61
- actions: [...keyDownActions, ...keyUpActions]
62
- }]).then(() => this.releaseActions());
65
+ const keyAction = this.action('key');
66
+ keySequence.forEach((value) => keyAction.down(value));
67
+ keySequence.forEach((value) => keyAction.up(value));
68
+ return keyAction.perform();
63
69
  }
64
- exports.default = keys;
@@ -1,4 +1,4 @@
1
- import type Interception from '../../utils/interception/index';
1
+ import type Interception from '../../utils/interception/index.js';
2
2
  import type { Mock } from '../../types';
3
3
  import type { MockFilterOptions } from '../../utils/interception/types';
4
4
  export declare const SESSION_MOCKS: Record<string, Set<Interception>>;
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAI9D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAM,CAAA;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,wBAA8B,IAAI,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,aAAa,CAAC,EAAE,iBAAiB,iBA6DpC"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,mCAAmC,CAAA;AAIjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAM,CAAA;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,wBAA8B,IAAI,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,aAAa,CAAC,EAAE,iBAAiB,iBA6DpC"}
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SESSION_MOCKS = void 0;
7
- const devtools_1 = __importDefault(require("../../utils/interception/devtools"));
8
- const webdriver_1 = __importDefault(require("../../utils/interception/webdriver"));
9
- const utils_1 = require("../../utils");
10
- exports.SESSION_MOCKS = {};
1
+ import DevtoolsNetworkInterception from '../../utils/interception/devtools.js';
2
+ import WebDriverNetworkInterception from '../../utils/interception/webdriver.js';
3
+ import { getBrowserObject } from '../../utils/index.js';
4
+ export const SESSION_MOCKS = {};
11
5
  /**
12
6
  * Mock the response of a request. You can define a mock based on a matching
13
7
  * glob and corresponding header and status code. Calling the mock method
@@ -113,23 +107,23 @@ exports.SESSION_MOCKS = {};
113
107
  * @type utility
114
108
  *
115
109
  */
116
- async function mock(url, filterOptions) {
117
- const NetworkInterception = this.isSauce ? webdriver_1.default : devtools_1.default;
110
+ export default async function mock(url, filterOptions) {
111
+ const NetworkInterception = this.isSauce ? WebDriverNetworkInterception : DevtoolsNetworkInterception;
118
112
  if (!this.isSauce) {
119
113
  await this.getPuppeteer();
120
114
  }
121
115
  if (!this.puppeteer) {
122
116
  throw new Error('No Puppeteer connection could be established which is required to use this command');
123
117
  }
124
- const browser = (0, utils_1.getBrowserObject)(this);
118
+ const browser = getBrowserObject(this);
125
119
  const handle = await browser.getWindowHandle();
126
- if (!exports.SESSION_MOCKS[handle]) {
127
- exports.SESSION_MOCKS[handle] = new Set();
120
+ if (!SESSION_MOCKS[handle]) {
121
+ SESSION_MOCKS[handle] = new Set();
128
122
  }
129
123
  /**
130
124
  * enable network Mocking if not already
131
125
  */
132
- if (exports.SESSION_MOCKS[handle].size === 0 && !this.isSauce) {
126
+ if (SESSION_MOCKS[handle].size === 0 && !this.isSauce) {
133
127
  const pages = await this.puppeteer.pages();
134
128
  /**
135
129
  * get active page
@@ -152,13 +146,12 @@ async function mock(url, filterOptions) {
152
146
  patterns: [{ requestStage: 'Request' }, { requestStage: 'Response' }]
153
147
  });
154
148
  client.on('Fetch.requestPaused', NetworkInterception
155
- .handleRequestInterception(client, exports.SESSION_MOCKS[handle]));
149
+ .handleRequestInterception(client, SESSION_MOCKS[handle]));
156
150
  }
157
151
  const networkInterception = new NetworkInterception(url, filterOptions, browser);
158
- exports.SESSION_MOCKS[handle].add(networkInterception);
152
+ SESSION_MOCKS[handle].add(networkInterception);
159
153
  if (this.isSauce) {
160
154
  await networkInterception.init();
161
155
  }
162
156
  return networkInterception;
163
157
  }
164
- exports.default = mock;
@@ -1,11 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const logger_1 = __importDefault(require("@wdio/logger"));
7
- const mock_1 = require("./mock");
8
- const log = (0, logger_1.default)('webdriverio:mockClearAll');
1
+ import logger from '@wdio/logger';
2
+ import { SESSION_MOCKS } from './mock.js';
3
+ const log = logger('webdriverio:mockClearAll');
9
4
  /**
10
5
  * Resets all information stored in all registered mocks of the session.
11
6
  *
@@ -32,12 +27,11 @@ const log = (0, logger_1.default)('webdriverio:mockClearAll');
32
27
  *
33
28
  * @alias browser.mockClearAll
34
29
  */
35
- async function mockClearAll() {
36
- for (const [handle, mocks] of Object.entries(mock_1.SESSION_MOCKS)) {
30
+ export default async function mockClearAll() {
31
+ for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
37
32
  log.trace(`Clearing mocks for ${handle}`);
38
33
  for (const mock of mocks) {
39
34
  mock.clear();
40
35
  }
41
36
  }
42
37
  }
43
- exports.default = mockClearAll;
@@ -1,11 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const logger_1 = __importDefault(require("@wdio/logger"));
7
- const mock_1 = require("./mock");
8
- const log = (0, logger_1.default)('webdriverio:mockRestoreAll');
1
+ import logger from '@wdio/logger';
2
+ import { SESSION_MOCKS } from './mock.js';
3
+ const log = logger('webdriverio:mockRestoreAll');
9
4
  /**
10
5
  * Restores all mock information and behavior stored in all registered
11
6
  * mocks of the session.
@@ -30,12 +25,11 @@ const log = (0, logger_1.default)('webdriverio:mockRestoreAll');
30
25
  *
31
26
  * @alias browser.mockRestoreAll
32
27
  */
33
- async function mockRestoreAll() {
34
- for (const [handle, mocks] of Object.entries(mock_1.SESSION_MOCKS)) {
28
+ export default async function mockRestoreAll() {
29
+ for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
35
30
  log.trace(`Clearing mocks for ${handle}`);
36
31
  for (const mock of mocks) {
37
32
  mock.restore();
38
33
  }
39
34
  }
40
35
  }
41
- exports.default = mockRestoreAll;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("@wdio/utils");
7
- const newWindow_1 = __importDefault(require("../../scripts/newWindow"));
1
+ import { sleep } from '@wdio/utils';
2
+ import newWindowHelper from '../../scripts/newWindow.js';
8
3
  const WAIT_FOR_NEW_HANDLE_TIMEOUT = 3000;
9
4
  /**
10
5
  *
@@ -44,7 +39,7 @@ const WAIT_FOR_NEW_HANDLE_TIMEOUT = 3000;
44
39
  * @alias browser.newWindow
45
40
  * @type window
46
41
  */
47
- async function newWindow(url, { windowName = '', windowFeatures = '' } = {}) {
42
+ export default async function newWindow(url, { windowName = '', windowFeatures = '' } = {}) {
48
43
  /**
49
44
  * parameter check
50
45
  */
@@ -58,7 +53,7 @@ async function newWindow(url, { windowName = '', windowFeatures = '' } = {}) {
58
53
  throw new Error('newWindow command is not supported on mobile platforms');
59
54
  }
60
55
  const tabsBefore = await this.getWindowHandles();
61
- await this.execute(newWindow_1.default, url, windowName, windowFeatures);
56
+ await this.execute(newWindowHelper, url, windowName, windowFeatures);
62
57
  /**
63
58
  * if tests are run in DevTools there might be a delay until
64
59
  * a new window handle got registered, this little procedure
@@ -71,7 +66,7 @@ async function newWindow(url, { windowName = '', windowFeatures = '' } = {}) {
71
66
  if (tabsAfter.length > tabsBefore.length) {
72
67
  break;
73
68
  }
74
- await (0, utils_1.sleep)(100);
69
+ await sleep(100);
75
70
  }
76
71
  const newTab = tabsAfter.pop();
77
72
  if (!newTab) {
@@ -80,4 +75,3 @@ async function newWindow(url, { windowName = '', windowFeatures = '' } = {}) {
80
75
  await this.switchToWindow(newTab);
81
76
  return newTab;
82
77
  }
83
- exports.default = newWindow;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Pauses execution for a specific amount of time. It is recommended to not use this command to wait for an
@@ -21,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
19
  * @type utility
22
20
  *
23
21
  */
24
- function pause(milliseconds = 1000) {
22
+ export default function pause(milliseconds = 1000) {
25
23
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
26
24
  }
27
- exports.default = pause;
@@ -1 +1 @@
1
- {"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$$.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAIrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,yBAUxD"}
1
+ {"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$$.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAKrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,yBAUxD"}
@@ -1,13 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const utils_1 = require("../../utils");
8
- const getElementObject_1 = require("../../utils/getElementObject");
9
- const resq_1 = require("../../scripts/resq");
10
- const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
1
+ import fs from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { enhanceElementsArray } from '../../utils/index.js';
4
+ import { getElements } from '../../utils/getElementObject.js';
5
+ import { waitToLoadReact, react$$ as react$$Script } from '../../scripts/resq.js';
6
+ const require = createRequire(import.meta.url);
7
+ const resqScript = await fs.readFile(require.resolve('resq'));
11
8
  /**
12
9
  *
13
10
  * The `react$$` command is a useful command to query multiple React Components
@@ -41,11 +38,10 @@ const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
41
38
  * @return {ElementArray}
42
39
  *
43
40
  */
44
- async function react$$(selector, { props = {}, state = {} } = {}) {
41
+ export default async function react$$(selector, { props = {}, state = {} } = {}) {
45
42
  await this.executeScript(resqScript.toString(), []);
46
- await this.execute(resq_1.waitToLoadReact);
47
- const res = await this.execute(resq_1.react$$, selector, props, state);
48
- const elements = await getElementObject_1.getElements.call(this, selector, res, true);
49
- return (0, utils_1.enhanceElementsArray)(elements, this, selector, 'react$$', [props, state]);
43
+ await this.execute(waitToLoadReact);
44
+ const res = await this.execute(react$$Script, selector, props, state);
45
+ const elements = await getElements.call(this, selector, res, true);
46
+ return enhanceElementsArray(elements, this, selector, 'react$$', [props, state]);
50
47
  }
51
- exports.default = react$$;
@@ -1 +1 @@
1
- {"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,gCASxD"}
1
+ {"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/react$.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,gCASxD"}
@@ -1,12 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const getElementObject_1 = require("../../utils/getElementObject");
8
- const resq_1 = require("../../scripts/resq");
9
- const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
1
+ import fs from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { getElement } from '../../utils/getElementObject.js';
4
+ import { waitToLoadReact, react$ as react$Script } from '../../scripts/resq.js';
5
+ const require = createRequire(import.meta.url);
6
+ const resqScript = await fs.readFile(require.resolve('resq'));
10
7
  /**
11
8
  *
12
9
  * The `react$` command is a useful command to query React Components by their
@@ -50,10 +47,9 @@ const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
50
47
  * @return {Element}
51
48
  *
52
49
  */
53
- async function react$(selector, { props = {}, state = {} } = {}) {
50
+ export default async function react$(selector, { props = {}, state = {} } = {}) {
54
51
  await this.executeScript(resqScript.toString(), []);
55
- await this.execute(resq_1.waitToLoadReact);
56
- const res = await this.execute(resq_1.react$, selector, props, state);
57
- return getElementObject_1.getElement.call(this, selector, res, true);
52
+ await this.execute(waitToLoadReact);
53
+ const res = await this.execute(react$Script, selector, props, state);
54
+ return getElement.call(this, selector, res, true);
58
55
  }
59
- exports.default = react$;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const logger_1 = __importDefault(require("@wdio/logger"));
7
- const log = (0, logger_1.default)('webdriverio');
1
+ import logger from '@wdio/logger';
2
+ const log = logger('webdriverio');
8
3
  /**
9
4
  *
10
5
  * Creates a new Selenium session with your current capabilities. This is useful if you
@@ -26,8 +21,7 @@ const log = (0, logger_1.default)('webdriverio');
26
21
  * @type utility
27
22
  *
28
23
  */
29
- async function reloadSession() {
30
- var _a;
24
+ export default async function reloadSession() {
31
25
  const oldSessionId = this.sessionId;
32
26
  /**
33
27
  * end current running session, if session already gone suppress exceptions
@@ -43,11 +37,11 @@ async function reloadSession() {
43
37
  */
44
38
  log.warn(`Suppressing error closing the session: ${err.stack}`);
45
39
  }
46
- if ((_a = this.puppeteer) === null || _a === void 0 ? void 0 : _a.isConnected()) {
40
+ if (this.puppeteer?.isConnected()) {
47
41
  this.puppeteer.disconnect();
48
42
  log.debug('Disconnected puppeteer session');
49
43
  }
50
- const ProtocolDriver = require(this.options.automationProtocol).default;
44
+ const ProtocolDriver = (await import(this.options.automationProtocol)).default;
51
45
  await ProtocolDriver.reloadSession(this);
52
46
  const options = this.options;
53
47
  if (Array.isArray(options.onReload) && options.onReload.length) {
@@ -55,4 +49,3 @@ async function reloadSession() {
55
49
  }
56
50
  return this.sessionId;
57
51
  }
58
- exports.default = reloadSession;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const utils_1 = require("../../utils");
1
+ import fs from 'node:fs';
2
+ import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
8
3
  /**
9
4
  *
10
5
  * Prints the page of the current browsing context to a PDF file on your OS.
@@ -34,18 +29,17 @@ const utils_1 = require("../../utils");
34
29
  * @type utility
35
30
  *
36
31
  */
37
- async function savePDF(filepath, options) {
32
+ export default async function savePDF(filepath, options) {
38
33
  /**
39
34
  * type check
40
35
  */
41
36
  if (typeof filepath != 'string' || !filepath.endsWith('.pdf')) {
42
37
  throw new Error('savePDF expects a filepath of type string and ".pdf" file ending');
43
38
  }
44
- const absoluteFilepath = (0, utils_1.getAbsoluteFilepath)(filepath);
45
- (0, utils_1.assertDirectoryExists)(absoluteFilepath);
46
- const pdf = await this.printPage(options === null || options === void 0 ? void 0 : options.orientation, options === null || options === void 0 ? void 0 : options.scale, options === null || options === void 0 ? void 0 : options.background, options === null || options === void 0 ? void 0 : options.width, options === null || options === void 0 ? void 0 : options.height, options === null || options === void 0 ? void 0 : options.top, options === null || options === void 0 ? void 0 : options.bottom, options === null || options === void 0 ? void 0 : options.left, options === null || options === void 0 ? void 0 : options.right, options === null || options === void 0 ? void 0 : options.shrinkToFit, options === null || options === void 0 ? void 0 : options.pageRanges);
39
+ const absoluteFilepath = getAbsoluteFilepath(filepath);
40
+ assertDirectoryExists(absoluteFilepath);
41
+ const pdf = await this.printPage(options?.orientation, options?.scale, options?.background, options?.width, options?.height, options?.top, options?.bottom, options?.left, options?.right, options?.shrinkToFit, options?.pageRanges);
47
42
  const page = Buffer.from(pdf, 'base64');
48
- fs_1.default.writeFileSync(absoluteFilepath, page);
43
+ fs.writeFileSync(absoluteFilepath, page);
49
44
  return page;
50
45
  }
51
- exports.default = savePDF;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const utils_1 = require("../../utils");
1
+ import fs from 'node:fs';
2
+ import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
8
3
  /**
9
4
  *
10
5
  * Save a video started by [`startRecordingScreen`](/docs/api/appium#startrecordingscreen) command to file.
@@ -30,18 +25,17 @@ const utils_1 = require("../../utils");
30
25
  * @type utility
31
26
  *
32
27
  */
33
- async function saveRecordingScreen(filepath) {
28
+ export default async function saveRecordingScreen(filepath) {
34
29
  /**
35
30
  * type check
36
31
  */
37
32
  if (typeof filepath !== 'string') {
38
33
  throw new Error('saveRecordingScreen expects a filepath');
39
34
  }
40
- const absoluteFilepath = (0, utils_1.getAbsoluteFilepath)(filepath);
41
- (0, utils_1.assertDirectoryExists)(absoluteFilepath);
35
+ const absoluteFilepath = getAbsoluteFilepath(filepath);
36
+ assertDirectoryExists(absoluteFilepath);
42
37
  const videoBuffer = await this.stopRecordingScreen();
43
38
  const video = Buffer.from(videoBuffer, 'base64');
44
- fs_1.default.writeFileSync(absoluteFilepath, video);
39
+ fs.writeFileSync(absoluteFilepath, video);
45
40
  return video;
46
41
  }
47
- exports.default = saveRecordingScreen;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const utils_1 = require("../../utils");
1
+ import fs from 'node:fs';
2
+ import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
8
3
  /**
9
4
  *
10
5
  * Save a screenshot of the current browsing context to a PNG file on your OS. Be aware that
@@ -24,18 +19,17 @@ const utils_1 = require("../../utils");
24
19
  * @type utility
25
20
  *
26
21
  */
27
- async function saveScreenshot(filepath) {
22
+ export default async function saveScreenshot(filepath) {
28
23
  /**
29
24
  * type check
30
25
  */
31
26
  if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
32
27
  throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
33
28
  }
34
- const absoluteFilepath = (0, utils_1.getAbsoluteFilepath)(filepath);
35
- (0, utils_1.assertDirectoryExists)(absoluteFilepath);
29
+ const absoluteFilepath = getAbsoluteFilepath(filepath);
30
+ assertDirectoryExists(absoluteFilepath);
36
31
  const screenBuffer = await this.takeScreenshot();
37
32
  const screenshot = Buffer.from(screenBuffer, 'base64');
38
- fs_1.default.writeFileSync(absoluteFilepath, screenshot);
33
+ fs.writeFileSync(absoluteFilepath, screenshot);
39
34
  return screenshot;
40
35
  }
41
- exports.default = saveScreenshot;
@@ -0,0 +1,25 @@
1
+ /**
2
+ *
3
+ * Scroll within the browser viewport. Note that `x` and `y` coordinates are relative to the current
4
+ * scroll positon, therefore `browser.scroll(0, 0)` is a non operation.
5
+ *
6
+ * <example>
7
+ :scroll.js
8
+ it('should demonstrate the scroll command', async () => {
9
+ await browser.url('https://webdriver.io')
10
+
11
+ console.log(await browser.execute(() => window.scrollY)) // returns 0
12
+ await browser.scroll(0, 200)
13
+ console.log(await browser.execute(() => window.scrollY)) // returns 200
14
+ });
15
+ * </example>
16
+ *
17
+ * @alias element.scroll
18
+ * @param {number=} x horizontal scroll position (default: `0`)
19
+ * @param {number=} y vertical scroll position (default: `0`)
20
+ * @uses protocol/execute
21
+ * @type utility
22
+ *
23
+ */
24
+ export default function scroll(this: WebdriverIO.Browser, x?: number, y?: number): void | Promise<void>;
25
+ //# sourceMappingURL=scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/scroll.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,CAAC,SAAI,EACL,CAAC,SAAI,wBAiBR"}