webdriverio 7.20.7 → 7.20.8-alpha.504

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 (229) 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/$$.d.ts +10 -1
  6. package/build/commands/browser/$$.d.ts.map +1 -1
  7. package/build/commands/browser/$$.js +16 -9
  8. package/build/commands/browser/$.js +8 -11
  9. package/build/commands/browser/action.d.ts +132 -0
  10. package/build/commands/browser/action.d.ts.map +1 -0
  11. package/build/commands/browser/action.js +13 -0
  12. package/build/commands/browser/actions.d.ts +29 -0
  13. package/build/commands/browser/actions.d.ts.map +1 -0
  14. package/build/commands/browser/actions.js +30 -0
  15. package/build/commands/browser/addCommand.d.ts +1 -1
  16. package/build/commands/browser/addCommand.js +1 -1
  17. package/build/commands/browser/call.d.ts +7 -5
  18. package/build/commands/browser/call.d.ts.map +1 -1
  19. package/build/commands/browser/call.js +8 -9
  20. package/build/commands/browser/custom$$.js +7 -10
  21. package/build/commands/browser/custom$.d.ts +1 -1
  22. package/build/commands/browser/custom$.js +6 -9
  23. package/build/commands/browser/debug.js +8 -14
  24. package/build/commands/browser/deleteCookies.d.ts +3 -3
  25. package/build/commands/browser/deleteCookies.js +4 -7
  26. package/build/commands/browser/execute.d.ts +2 -2
  27. package/build/commands/browser/execute.js +5 -8
  28. package/build/commands/browser/executeAsync.js +3 -6
  29. package/build/commands/browser/getCookies.d.ts +2 -2
  30. package/build/commands/browser/getCookies.js +3 -6
  31. package/build/commands/browser/getPuppeteer.d.ts +1 -1
  32. package/build/commands/browser/getPuppeteer.d.ts.map +1 -1
  33. package/build/commands/browser/getPuppeteer.js +14 -21
  34. package/build/commands/browser/getWindowSize.js +3 -6
  35. package/build/commands/browser/keys.d.ts +20 -10
  36. package/build/commands/browser/keys.d.ts.map +1 -1
  37. package/build/commands/browser/keys.js +29 -24
  38. package/build/commands/browser/mock.d.ts +5 -4
  39. package/build/commands/browser/mock.d.ts.map +1 -1
  40. package/build/commands/browser/mock.js +16 -22
  41. package/build/commands/browser/mockClearAll.js +5 -11
  42. package/build/commands/browser/mockRestoreAll.js +5 -11
  43. package/build/commands/browser/newWindow.js +5 -11
  44. package/build/commands/browser/pause.js +1 -4
  45. package/build/commands/browser/react$$.d.ts.map +1 -1
  46. package/build/commands/browser/react$$.js +16 -17
  47. package/build/commands/browser/react$.d.ts.map +1 -1
  48. package/build/commands/browser/react$.js +13 -14
  49. package/build/commands/browser/reloadSession.js +5 -12
  50. package/build/commands/browser/savePDF.d.ts +14 -14
  51. package/build/commands/browser/savePDF.js +21 -27
  52. package/build/commands/browser/saveRecordingScreen.js +6 -12
  53. package/build/commands/browser/saveScreenshot.js +6 -12
  54. package/build/commands/browser/scroll.d.ts +25 -0
  55. package/build/commands/browser/scroll.d.ts.map +1 -0
  56. package/build/commands/browser/scroll.js +41 -0
  57. package/build/commands/browser/setCookies.d.ts +1 -1
  58. package/build/commands/browser/setCookies.d.ts.map +1 -1
  59. package/build/commands/browser/setCookies.js +5 -7
  60. package/build/commands/browser/setTimeout.js +1 -4
  61. package/build/commands/browser/setWindowSize.js +3 -6
  62. package/build/commands/browser/switchWindow.js +1 -4
  63. package/build/commands/browser/throttle.js +3 -6
  64. package/build/commands/browser/touchAction.d.ts +1 -1
  65. package/build/commands/browser/touchAction.d.ts.map +1 -1
  66. package/build/commands/browser/touchAction.js +3 -6
  67. package/build/commands/browser/uploadFile.d.ts +1 -1
  68. package/build/commands/browser/uploadFile.d.ts.map +1 -1
  69. package/build/commands/browser/uploadFile.js +10 -15
  70. package/build/commands/browser/url.js +3 -6
  71. package/build/commands/browser/waitUntil.d.ts +1 -2
  72. package/build/commands/browser/waitUntil.d.ts.map +1 -1
  73. package/build/commands/browser/waitUntil.js +4 -11
  74. package/build/commands/browser.d.ts +37 -69
  75. package/build/commands/browser.d.ts.map +1 -1
  76. package/build/commands/browser.js +37 -44
  77. package/build/commands/constant.d.ts +1 -1
  78. package/build/commands/constant.d.ts.map +1 -1
  79. package/build/commands/constant.js +6 -12
  80. package/build/commands/element/$$.d.ts +1 -1
  81. package/build/commands/element/$$.d.ts.map +1 -1
  82. package/build/commands/element/$$.js +2 -7
  83. package/build/commands/element/$.d.ts +1 -1
  84. package/build/commands/element/$.d.ts.map +1 -1
  85. package/build/commands/element/$.js +2 -7
  86. package/build/commands/element/addValue.d.ts +10 -14
  87. package/build/commands/element/addValue.d.ts.map +1 -1
  88. package/build/commands/element/addValue.js +23 -27
  89. package/build/commands/element/clearValue.d.ts +1 -1
  90. package/build/commands/element/clearValue.js +2 -5
  91. package/build/commands/element/click.d.ts +1 -1
  92. package/build/commands/element/click.d.ts.map +1 -1
  93. package/build/commands/element/click.js +19 -34
  94. package/build/commands/element/custom$$.js +9 -11
  95. package/build/commands/element/custom$.js +8 -10
  96. package/build/commands/element/doubleClick.d.ts.map +1 -1
  97. package/build/commands/element/doubleClick.js +11 -17
  98. package/build/commands/element/dragAndDrop.d.ts.map +1 -1
  99. package/build/commands/element/dragAndDrop.js +13 -19
  100. package/build/commands/element/getAttribute.js +1 -4
  101. package/build/commands/element/getCSSProperty.d.ts +1 -1
  102. package/build/commands/element/getCSSProperty.d.ts.map +1 -1
  103. package/build/commands/element/getCSSProperty.js +7 -13
  104. package/build/commands/element/getComputedLabel.js +1 -4
  105. package/build/commands/element/getComputedRole.js +1 -4
  106. package/build/commands/element/getHTML.js +7 -13
  107. package/build/commands/element/getLocation.js +3 -5
  108. package/build/commands/element/getProperty.d.ts +5 -5
  109. package/build/commands/element/getProperty.d.ts.map +1 -1
  110. package/build/commands/element/getProperty.js +5 -11
  111. package/build/commands/element/getSize.js +3 -5
  112. package/build/commands/element/getTagName.js +1 -4
  113. package/build/commands/element/getText.js +1 -4
  114. package/build/commands/element/getValue.js +1 -4
  115. package/build/commands/element/isClickable.d.ts.map +1 -1
  116. package/build/commands/element/isClickable.js +10 -13
  117. package/build/commands/element/isDisplayed.js +9 -16
  118. package/build/commands/element/isDisplayedInViewport.js +7 -13
  119. package/build/commands/element/isEnabled.js +1 -4
  120. package/build/commands/element/isEqual.d.ts.map +1 -1
  121. package/build/commands/element/isEqual.js +9 -9
  122. package/build/commands/element/isExisting.js +1 -4
  123. package/build/commands/element/isFocused.js +7 -13
  124. package/build/commands/element/isSelected.js +1 -4
  125. package/build/commands/element/moveTo.d.ts.map +1 -1
  126. package/build/commands/element/moveTo.js +8 -13
  127. package/build/commands/element/nextElement.js +2 -5
  128. package/build/commands/element/parentElement.js +2 -5
  129. package/build/commands/element/previousElement.js +2 -5
  130. package/build/commands/element/react$$.d.ts.map +1 -1
  131. package/build/commands/element/react$$.js +16 -16
  132. package/build/commands/element/react$.d.ts.map +1 -1
  133. package/build/commands/element/react$.js +15 -14
  134. package/build/commands/element/saveScreenshot.js +6 -12
  135. package/build/commands/element/scrollIntoView.d.ts +4 -2
  136. package/build/commands/element/scrollIntoView.d.ts.map +1 -1
  137. package/build/commands/element/scrollIntoView.js +33 -12
  138. package/build/commands/element/selectByAttribute.js +3 -6
  139. package/build/commands/element/selectByIndex.js +3 -6
  140. package/build/commands/element/selectByVisibleText.js +3 -6
  141. package/build/commands/element/setValue.d.ts +13 -14
  142. package/build/commands/element/setValue.d.ts.map +1 -1
  143. package/build/commands/element/setValue.js +14 -17
  144. package/build/commands/element/shadow$$.d.ts +1 -1
  145. package/build/commands/element/shadow$$.d.ts.map +1 -1
  146. package/build/commands/element/shadow$$.js +3 -6
  147. package/build/commands/element/shadow$.js +3 -6
  148. package/build/commands/element/touchAction.js +3 -6
  149. package/build/commands/element/waitForClickable.js +1 -4
  150. package/build/commands/element/waitForDisplayed.js +1 -4
  151. package/build/commands/element/waitForEnabled.js +1 -4
  152. package/build/commands/element/waitForExist.js +1 -4
  153. package/build/commands/element/waitUntil.d.ts +2 -3
  154. package/build/commands/element/waitUntil.d.ts.map +1 -1
  155. package/build/commands/element/waitUntil.js +3 -9
  156. package/build/commands/element.d.ts +49 -99
  157. package/build/commands/element.d.ts.map +1 -1
  158. package/build/commands/element.js +49 -63
  159. package/build/constants.d.ts +67 -0
  160. package/build/constants.d.ts.map +1 -1
  161. package/build/constants.js +105 -12
  162. package/build/index.d.ts +65 -6
  163. package/build/index.d.ts.map +1 -1
  164. package/build/index.js +48 -86
  165. package/build/middlewares.d.ts +1 -1
  166. package/build/middlewares.js +11 -19
  167. package/build/multiremote.js +18 -24
  168. package/build/protocol-stub.d.ts.map +1 -1
  169. package/build/protocol-stub.js +4 -6
  170. package/build/scripts/getHTML.js +1 -4
  171. package/build/scripts/getProperty.d.ts +5 -5
  172. package/build/scripts/getProperty.d.ts.map +1 -1
  173. package/build/scripts/getProperty.js +1 -4
  174. package/build/scripts/isElementClickable.js +1 -4
  175. package/build/scripts/isElementDisplayed.js +2 -5
  176. package/build/scripts/isElementInViewport.js +1 -4
  177. package/build/scripts/isFocused.js +1 -4
  178. package/build/scripts/newWindow.js +1 -4
  179. package/build/scripts/resq.js +3 -9
  180. package/build/scripts/shadowFnFactory.js +2 -6
  181. package/build/types.d.ts +5 -9
  182. package/build/types.d.ts.map +1 -1
  183. package/build/types.js +1 -2
  184. package/build/utils/SevereServiceError.js +1 -4
  185. package/build/utils/Timer.d.ts.map +1 -1
  186. package/build/utils/Timer.js +13 -29
  187. package/build/utils/actions/base.d.ts +32 -0
  188. package/build/utils/actions/base.d.ts.map +1 -0
  189. package/build/utils/actions/base.js +66 -0
  190. package/build/utils/actions/index.d.ts +6 -0
  191. package/build/utils/actions/index.d.ts.map +1 -0
  192. package/build/utils/actions/index.js +5 -0
  193. package/build/utils/actions/key.d.ts +15 -0
  194. package/build/utils/actions/key.d.ts.map +1 -0
  195. package/build/utils/actions/key.js +22 -0
  196. package/build/utils/actions/pointer.d.ts +62 -0
  197. package/build/utils/actions/pointer.d.ts.map +1 -0
  198. package/build/utils/actions/pointer.js +76 -0
  199. package/build/utils/actions/wheel.d.ts +36 -0
  200. package/build/utils/actions/wheel.d.ts.map +1 -0
  201. package/build/utils/actions/wheel.js +20 -0
  202. package/build/utils/detectBackend.d.ts +1 -1
  203. package/build/utils/detectBackend.d.ts.map +1 -1
  204. package/build/utils/detectBackend.js +3 -7
  205. package/build/utils/findStrategy.d.ts.map +1 -1
  206. package/build/utils/findStrategy.js +50 -19
  207. package/build/utils/getElementObject.d.ts +1 -1
  208. package/build/utils/getElementObject.d.ts.map +1 -1
  209. package/build/utils/getElementObject.js +51 -32
  210. package/build/utils/implicitWait.js +3 -9
  211. package/build/utils/index.d.ts +8 -7
  212. package/build/utils/index.d.ts.map +1 -1
  213. package/build/utils/index.js +125 -148
  214. package/build/utils/interception/devtools.d.ts +1 -1
  215. package/build/utils/interception/devtools.d.ts.map +1 -1
  216. package/build/utils/interception/devtools.js +17 -36
  217. package/build/utils/interception/index.d.ts +2 -2
  218. package/build/utils/interception/index.d.ts.map +1 -1
  219. package/build/utils/interception/index.js +10 -13
  220. package/build/utils/interception/types.d.ts +1 -1
  221. package/build/utils/interception/types.d.ts.map +1 -1
  222. package/build/utils/interception/types.js +1 -2
  223. package/build/utils/interception/webdriver.d.ts +1 -1
  224. package/build/utils/interception/webdriver.d.ts.map +1 -1
  225. package/build/utils/interception/webdriver.js +6 -11
  226. package/build/utils/refetchElement.js +3 -9
  227. package/package.json +27 -17
  228. package/async.d.ts +0 -24
  229. package/sync.d.ts +0 -24
@@ -10,5 +10,72 @@ export declare const DRIVER_DEFAULT_ENDPOINT: {
10
10
  };
11
11
  export declare const FF_REMOTE_DEBUG_ARG = "-remote-debugging-port";
12
12
  export declare const DEEP_SELECTOR = ">>>";
13
+ export declare const ARIA_SELECTOR = "aria/";
13
14
  export declare const ERROR_REASON: string[];
15
+ /**
16
+ * Special Characters
17
+ */
18
+ export declare const Key: {
19
+ /**
20
+ * Special control key that works cross browser for Mac, where it's the command key, and for
21
+ * Windows or Linux, where it is the control key.
22
+ */
23
+ readonly Ctrl: "WDIO_CONTROL";
24
+ readonly NULL: "";
25
+ readonly Cancel: "";
26
+ readonly Help: "";
27
+ readonly Backspace: "";
28
+ readonly Tab: "";
29
+ readonly Clear: "";
30
+ readonly Return: "";
31
+ readonly Enter: "";
32
+ readonly Shift: "";
33
+ readonly Control: "";
34
+ readonly Alt: "";
35
+ readonly Pause: "";
36
+ readonly Escape: "";
37
+ readonly Space: "";
38
+ readonly PageUp: "";
39
+ readonly PageDown: "";
40
+ readonly End: "";
41
+ readonly Home: "";
42
+ readonly ArrowLeft: "";
43
+ readonly ArrowUp: "";
44
+ readonly ArrowRight: "";
45
+ readonly ArrowDown: "";
46
+ readonly Insert: "";
47
+ readonly Delete: "";
48
+ readonly Semicolon: "";
49
+ readonly Equals: "";
50
+ readonly Numpad0: "";
51
+ readonly Numpad1: "";
52
+ readonly Numpad2: "";
53
+ readonly Numpad3: "";
54
+ readonly Numpad4: "";
55
+ readonly Numpad5: "";
56
+ readonly Numpad6: "";
57
+ readonly Numpad7: "";
58
+ readonly Numpad8: "";
59
+ readonly Numpad9: "";
60
+ readonly Multiply: "";
61
+ readonly Add: "";
62
+ readonly Separator: "";
63
+ readonly Subtract: "";
64
+ readonly Decimal: "";
65
+ readonly Divide: "";
66
+ readonly F1: "";
67
+ readonly F2: "";
68
+ readonly F3: "";
69
+ readonly F4: "";
70
+ readonly F5: "";
71
+ readonly F6: "";
72
+ readonly F7: "";
73
+ readonly F8: "";
74
+ readonly F9: "";
75
+ readonly F10: "";
76
+ readonly F11: "";
77
+ readonly F12: "";
78
+ readonly Command: "";
79
+ readonly ZenkakuHankaku: "";
80
+ };
14
81
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAqC,MAAM,aAAa,CAAA;AA4B7E,eAAO,MAAM,WAAW,wCAAwC,CAAA;AAEhE,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAuQtF,CAAA;AAED,eAAO,MAAM,uBAAuB,UAA0E,CAAA;AAE9G,eAAO,MAAM,uBAAuB;;;;;CAKnC,CAAA;AAED,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAC3D,eAAO,MAAM,aAAa,QAAQ,CAAA;AAElC,eAAO,MAAM,YAAY,UAKxB,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAqC,MAAM,aAAa,CAAA;AAqC7E,eAAO,MAAM,WAAW,wCAAwC,CAAA;AAEhE,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAwRtF,CAAA;AAED,eAAO,MAAM,uBAAuB,UAA0E,CAAA;AAE9G,eAAO,MAAM,uBAAuB;;;;;CAKnC,CAAA;AAED,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAC3D,eAAO,MAAM,aAAa,QAAQ,CAAA;AAClC,eAAO,MAAM,aAAa,UAAU,CAAA;AAEpC,eAAO,MAAM,YAAY,UAKxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG;IACZ;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DG,CAAA"}
@@ -1,6 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ERROR_REASON = exports.DEEP_SELECTOR = exports.FF_REMOTE_DEBUG_ARG = exports.DRIVER_DEFAULT_ENDPOINT = exports.W3C_SELECTOR_STRATEGIES = exports.WDIO_DEFAULTS = exports.ELEMENT_KEY = void 0;
1
+ import { fileURLToPath } from 'node:url';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { createRequire } from 'node:module';
4
+ import { UNICODE_CHARACTERS } from '@wdio/utils';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ const require = createRequire(import.meta.url);
7
+ var SupportedAutomationProtocols;
8
+ (function (SupportedAutomationProtocols) {
9
+ SupportedAutomationProtocols["browser"] = "browser-runner/build/browser/driver.js";
10
+ SupportedAutomationProtocols["webdriver"] = "webdriver";
11
+ SupportedAutomationProtocols["devtools"] = "devtools";
12
+ SupportedAutomationProtocols["stub"] = "./protocol-stub.js";
13
+ })(SupportedAutomationProtocols || (SupportedAutomationProtocols = {}));
4
14
  /* istanbul ignore next */
5
15
  const HOOK_DEFINITION = {
6
16
  type: 'object',
@@ -25,19 +35,28 @@ const HOOK_DEFINITION = {
25
35
  }
26
36
  }
27
37
  };
28
- exports.ELEMENT_KEY = 'element-6066-11e4-a52e-4f735466cecf';
29
- exports.WDIO_DEFAULTS = {
38
+ export const ELEMENT_KEY = 'element-6066-11e4-a52e-4f735466cecf';
39
+ export const WDIO_DEFAULTS = {
30
40
  /**
31
41
  * allows to specify automation protocol
32
42
  */
33
43
  automationProtocol: {
34
44
  type: 'string',
35
45
  validate: (param) => {
36
- if (!['webdriver', 'devtools', './protocol-stub'].includes(param.toLowerCase())) {
46
+ /**
47
+ * path when proxy is used for browser testing
48
+ */
49
+ if (param.endsWith(SupportedAutomationProtocols.browser)) {
50
+ return;
51
+ }
52
+ if (!Object.values(SupportedAutomationProtocols).includes(param.toLowerCase())) {
37
53
  throw new Error(`Currently only "webdriver" and "devtools" is supproted as automationProtocol, you set "${param}"`);
38
54
  }
39
55
  try {
40
- require.resolve(param);
56
+ const id = param === SupportedAutomationProtocols.stub
57
+ ? resolve(__dirname, '..', 'build', param)
58
+ : param;
59
+ require.resolve(id);
41
60
  }
42
61
  catch (err) {
43
62
  /* istanbul ignore next */
@@ -238,6 +257,13 @@ exports.WDIO_DEFAULTS = {
238
257
  maxInstancesPerCapability: {
239
258
  type: 'number'
240
259
  },
260
+ /**
261
+ * whether or not testrunner should inject `browser`, `$` and `$$` as
262
+ * global environment variables
263
+ */
264
+ injectGlobals: {
265
+ type: 'boolean'
266
+ },
241
267
  /**
242
268
  * list of strings to watch of `wdio` command is called with `--watch` flag
243
269
  */
@@ -270,18 +296,85 @@ exports.WDIO_DEFAULTS = {
270
296
  onComplete: HOOK_DEFINITION,
271
297
  onReload: HOOK_DEFINITION
272
298
  };
273
- exports.W3C_SELECTOR_STRATEGIES = ['css selector', 'link text', 'partial link text', 'tag name', 'xpath'];
274
- exports.DRIVER_DEFAULT_ENDPOINT = {
299
+ export const W3C_SELECTOR_STRATEGIES = ['css selector', 'link text', 'partial link text', 'tag name', 'xpath'];
300
+ export const DRIVER_DEFAULT_ENDPOINT = {
275
301
  method: 'GET',
276
302
  host: 'localhost',
277
303
  port: 4444,
278
304
  path: '/status'
279
305
  };
280
- exports.FF_REMOTE_DEBUG_ARG = '-remote-debugging-port';
281
- exports.DEEP_SELECTOR = '>>>';
282
- exports.ERROR_REASON = [
306
+ export const FF_REMOTE_DEBUG_ARG = '-remote-debugging-port';
307
+ export const DEEP_SELECTOR = '>>>';
308
+ export const ARIA_SELECTOR = 'aria/';
309
+ export const ERROR_REASON = [
283
310
  'Failed', 'Aborted', 'TimedOut', 'AccessDenied', 'ConnectionClosed',
284
311
  'ConnectionReset', 'ConnectionRefused', 'ConnectionAborted',
285
312
  'ConnectionFailed', 'NameNotResolved', 'InternetDisconnected',
286
313
  'AddressUnreachable', 'BlockedByClient', 'BlockedByResponse'
287
314
  ];
315
+ /**
316
+ * Special Characters
317
+ */
318
+ export const Key = {
319
+ /**
320
+ * Special control key that works cross browser for Mac, where it's the command key, and for
321
+ * Windows or Linux, where it is the control key.
322
+ */
323
+ Ctrl: 'WDIO_CONTROL',
324
+ NULL: UNICODE_CHARACTERS.NULL,
325
+ Cancel: UNICODE_CHARACTERS.Cancel,
326
+ Help: UNICODE_CHARACTERS.Help,
327
+ Backspace: UNICODE_CHARACTERS.Backspace,
328
+ Tab: UNICODE_CHARACTERS.Tab,
329
+ Clear: UNICODE_CHARACTERS.Clear,
330
+ Return: UNICODE_CHARACTERS.Return,
331
+ Enter: UNICODE_CHARACTERS.Enter,
332
+ Shift: UNICODE_CHARACTERS.Shift,
333
+ Control: UNICODE_CHARACTERS.Control,
334
+ Alt: UNICODE_CHARACTERS.Alt,
335
+ Pause: UNICODE_CHARACTERS.Pause,
336
+ Escape: UNICODE_CHARACTERS.Escape,
337
+ Space: UNICODE_CHARACTERS.Space,
338
+ PageUp: UNICODE_CHARACTERS.PageUp,
339
+ PageDown: UNICODE_CHARACTERS.PageDown,
340
+ End: UNICODE_CHARACTERS.End,
341
+ Home: UNICODE_CHARACTERS.Home,
342
+ ArrowLeft: UNICODE_CHARACTERS.ArrowLeft,
343
+ ArrowUp: UNICODE_CHARACTERS.ArrowUp,
344
+ ArrowRight: UNICODE_CHARACTERS.ArrowRight,
345
+ ArrowDown: UNICODE_CHARACTERS.ArrowDown,
346
+ Insert: UNICODE_CHARACTERS.Insert,
347
+ Delete: UNICODE_CHARACTERS.Delete,
348
+ Semicolon: UNICODE_CHARACTERS.Semicolon,
349
+ Equals: UNICODE_CHARACTERS.Equals,
350
+ Numpad0: UNICODE_CHARACTERS['Numpad 0'],
351
+ Numpad1: UNICODE_CHARACTERS['Numpad 1'],
352
+ Numpad2: UNICODE_CHARACTERS['Numpad 2'],
353
+ Numpad3: UNICODE_CHARACTERS['Numpad 3'],
354
+ Numpad4: UNICODE_CHARACTERS['Numpad 4'],
355
+ Numpad5: UNICODE_CHARACTERS['Numpad 5'],
356
+ Numpad6: UNICODE_CHARACTERS['Numpad 6'],
357
+ Numpad7: UNICODE_CHARACTERS['Numpad 7'],
358
+ Numpad8: UNICODE_CHARACTERS['Numpad 8'],
359
+ Numpad9: UNICODE_CHARACTERS['Numpad 9'],
360
+ Multiply: UNICODE_CHARACTERS.Multiply,
361
+ Add: UNICODE_CHARACTERS.Add,
362
+ Separator: UNICODE_CHARACTERS.Separator,
363
+ Subtract: UNICODE_CHARACTERS.Subtract,
364
+ Decimal: UNICODE_CHARACTERS.Decimal,
365
+ Divide: UNICODE_CHARACTERS.Divide,
366
+ F1: UNICODE_CHARACTERS.F1,
367
+ F2: UNICODE_CHARACTERS.F2,
368
+ F3: UNICODE_CHARACTERS.F3,
369
+ F4: UNICODE_CHARACTERS.F4,
370
+ F5: UNICODE_CHARACTERS.F5,
371
+ F6: UNICODE_CHARACTERS.F6,
372
+ F7: UNICODE_CHARACTERS.F7,
373
+ F8: UNICODE_CHARACTERS.F8,
374
+ F9: UNICODE_CHARACTERS.F9,
375
+ F10: UNICODE_CHARACTERS.F10,
376
+ F11: UNICODE_CHARACTERS.F11,
377
+ F12: UNICODE_CHARACTERS.F12,
378
+ Command: UNICODE_CHARACTERS.Command,
379
+ ZenkakuHankaku: UNICODE_CHARACTERS.ZenkakuHankaku
380
+ };
package/build/index.d.ts CHANGED
@@ -1,13 +1,72 @@
1
- import { Options, Capabilities } from '@wdio/types';
2
- import SevereServiceErrorImport from './utils/SevereServiceError';
1
+ import type { Options, Capabilities } from '@wdio/types';
2
+ import SevereServiceErrorImport from './utils/SevereServiceError.js';
3
3
  import type { AttachOptions } from './types';
4
4
  export declare type RemoteOptions = Options.WebdriverIO & Omit<Options.Testrunner, 'capabilities'>;
5
+ export declare const Key: {
6
+ readonly Ctrl: "WDIO_CONTROL";
7
+ readonly NULL: "";
8
+ readonly Cancel: "";
9
+ readonly Help: "";
10
+ readonly Backspace: "";
11
+ readonly Tab: "";
12
+ readonly Clear: "";
13
+ readonly Return: "";
14
+ readonly Enter: "";
15
+ readonly Shift: "";
16
+ readonly Control: "";
17
+ readonly Alt: "";
18
+ readonly Pause: "";
19
+ readonly Escape: "";
20
+ readonly Space: "";
21
+ readonly PageUp: "";
22
+ readonly PageDown: "";
23
+ readonly End: "";
24
+ readonly Home: "";
25
+ readonly ArrowLeft: "";
26
+ readonly ArrowUp: "";
27
+ readonly ArrowRight: "";
28
+ readonly ArrowDown: "";
29
+ readonly Insert: "";
30
+ readonly Delete: "";
31
+ readonly Semicolon: "";
32
+ readonly Equals: "";
33
+ readonly Numpad0: "";
34
+ readonly Numpad1: "";
35
+ readonly Numpad2: "";
36
+ readonly Numpad3: "";
37
+ readonly Numpad4: "";
38
+ readonly Numpad5: "";
39
+ readonly Numpad6: "";
40
+ readonly Numpad7: "";
41
+ readonly Numpad8: "";
42
+ readonly Numpad9: "";
43
+ readonly Multiply: "";
44
+ readonly Add: "";
45
+ readonly Separator: "";
46
+ readonly Subtract: "";
47
+ readonly Decimal: "";
48
+ readonly Divide: "";
49
+ readonly F1: "";
50
+ readonly F2: "";
51
+ readonly F3: "";
52
+ readonly F4: "";
53
+ readonly F5: "";
54
+ readonly F6: "";
55
+ readonly F7: "";
56
+ readonly F8: "";
57
+ readonly F9: "";
58
+ readonly F10: "";
59
+ readonly F11: "";
60
+ readonly F12: "";
61
+ readonly Command: "";
62
+ readonly ZenkakuHankaku: "";
63
+ };
5
64
  /**
6
65
  * A method to create a new session with WebdriverIO.
7
66
  *
8
67
  * <b>
9
68
  * NOTE: If you hit "error TS2694: Namespace 'global.WebdriverIO' has no exported member 'Browser'" when using typescript,
10
- * add "webdriverio/async" into tsconfig.json's "types" array will solve it: <code> { "compilerOptions": { "types": ["webdriverio/async"] } } </code>
69
+ * add "@wdio/globals/types" into tsconfig.json's "types" array will solve it: <code> { "compilerOptions": { "types": ["@wdio/globals/types"] } } </code>
11
70
  * </b>
12
71
  *
13
72
  * @param {Object} [params={}] Options to create the session with
@@ -19,7 +78,7 @@ export declare const remote: (params: RemoteOptions, remoteModifier?: Function)
19
78
  export declare const attach: (attachOptions: AttachOptions) => Promise<WebdriverIO.Browser>;
20
79
  /**
21
80
  * WebdriverIO allows you to run multiple automated sessions in a single test.
22
- * This is handy when youre testing features that require multiple users (for example, chat or WebRTC applications).
81
+ * This is handy when you're testing features that require multiple users (for example, chat or WebRTC applications).
23
82
  *
24
83
  * Instead of creating a couple of remote instances where you need to execute common commands like newSession() or url() on each instance,
25
84
  * you can simply create a multiremote instance and control all browsers at the same time.
@@ -40,6 +99,6 @@ export declare const multiremote: (params: Capabilities.MultiRemoteCapabilities,
40
99
  automationProtocol?: string | undefined;
41
100
  }) => Promise<WebdriverIO.MultiRemoteBrowser>;
42
101
  export declare const SevereServiceError: typeof SevereServiceErrorImport;
43
- export * from './types';
44
- export * from './utils/interception/types';
102
+ export * from './types.js';
103
+ export * from './utils/interception/types.js';
45
104
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAKnD,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AAOjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,oBAAY,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;AAE1F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,WAA2B,aAAa,mBAAmB,QAAQ,KAAG,QAAQ,YAAY,OAAO,CA+CnH,CAAA;AAED,eAAO,MAAM,MAAM,kBAAkC,aAAa,KAAG,QAAQ,YAAY,OAAO,CAmB/F,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,WACZ,aAAa,uBAAuB;;MAE7C,QAAQ,YAAY,kBAAkB,CAgExC,CAAA;AAED,eAAO,MAAM,kBAAkB,iCAA2B,CAAA;AAC1D,cAAc,SAAS,CAAA;AACvB,cAAc,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAIxD,OAAO,wBAAwB,MAAM,+BAA+B,CAAA;AAOpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5C,oBAAY,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;AAC1F,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAc,CAAA;AAE9B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,WAA2B,aAAa,mBAAmB,QAAQ,KAAG,QAAQ,YAAY,OAAO,CA6CnH,CAAA;AAED,eAAO,MAAM,MAAM,kBAAkC,aAAa,KAAG,QAAQ,YAAY,OAAO,CAmB/F,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,WACZ,aAAa,uBAAuB;;MAE7C,QAAQ,YAAY,kBAAkB,CAgExC,CAAA;AAED,eAAO,MAAM,kBAAkB,iCAA2B,CAAA;AAC1D,cAAc,YAAY,CAAA;AAC1B,cAAc,+BAA+B,CAAA"}
package/build/index.js CHANGED
@@ -1,51 +1,19 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.SevereServiceError = exports.multiremote = exports.attach = exports.remote = void 0;
33
- const logger_1 = __importDefault(require("@wdio/logger"));
34
- const webdriver_1 = __importDefault(require("webdriver"));
35
- const webdriver_2 = require("webdriver");
36
- const config_1 = require("@wdio/config");
37
- const utils_1 = require("@wdio/utils");
38
- const multiremote_1 = __importDefault(require("./multiremote"));
39
- const SevereServiceError_1 = __importDefault(require("./utils/SevereServiceError"));
40
- const detectBackend_1 = __importDefault(require("./utils/detectBackend"));
41
- const constants_1 = require("./constants");
42
- const utils_2 = require("./utils");
1
+ import logger from '@wdio/logger';
2
+ import WebDriver, { DEFAULTS } from 'webdriver';
3
+ import { validateConfig } from '@wdio/config';
4
+ import { wrapCommand } from '@wdio/utils';
5
+ import MultiRemote from './multiremote.js';
6
+ import SevereServiceErrorImport from './utils/SevereServiceError.js';
7
+ import detectBackend from './utils/detectBackend.js';
8
+ import { WDIO_DEFAULTS, Key as KeyConstant } from './constants.js';
9
+ import { getPrototype, addLocatorStrategyHandler, isStub, getAutomationProtocol, updateCapabilities } from './utils/index.js';
10
+ export const Key = KeyConstant;
43
11
  /**
44
12
  * A method to create a new session with WebdriverIO.
45
13
  *
46
14
  * <b>
47
15
  * NOTE: If you hit "error TS2694: Namespace 'global.WebdriverIO' has no exported member 'Browser'" when using typescript,
48
- * add "webdriverio/async" into tsconfig.json's "types" array will solve it: <code> { "compilerOptions": { "types": ["webdriverio/async"] } } </code>
16
+ * add "@wdio/globals/types" into tsconfig.json's "types" array will solve it: <code> { "compilerOptions": { "types": ["@wdio/globals/types"] } } </code>
49
17
  * </b>
50
18
  *
51
19
  * @param {Object} [params={}] Options to create the session with
@@ -53,10 +21,10 @@ const utils_2 = require("./utils");
53
21
  * @return {object} browser object with sessionId
54
22
  * @see <a href="https://webdriver.io/docs/typescript">Typescript setup</a>
55
23
  */
56
- const remote = async function (params, remoteModifier) {
57
- logger_1.default.setLogLevelsConfig(params.logLevels, params.logLevel);
58
- const config = (0, config_1.validateConfig)(constants_1.WDIO_DEFAULTS, params, Object.keys(webdriver_2.DEFAULTS));
59
- const automationProtocol = await (0, utils_2.getAutomationProtocol)(config);
24
+ export const remote = async function (params, remoteModifier) {
25
+ logger.setLogLevelsConfig(params.logLevels, params.logLevel);
26
+ const config = validateConfig(WDIO_DEFAULTS, params, Object.keys(DEFAULTS));
27
+ const automationProtocol = await getAutomationProtocol(config);
60
28
  const modifier = (client, options) => {
61
29
  /**
62
30
  * overwrite instance options with default values of the protocol
@@ -70,49 +38,44 @@ const remote = async function (params, remoteModifier) {
70
38
  options.automationProtocol = automationProtocol;
71
39
  return client;
72
40
  };
73
- const prototype = (0, utils_2.getPrototype)('browser');
74
- const ProtocolDriver = (await Promise.resolve().then(() => __importStar(require(automationProtocol)))).default;
75
- params = Object.assign({}, (0, detectBackend_1.default)(params), params);
76
- await (0, utils_2.updateCapabilities)(params, automationProtocol);
77
- const instance = await ProtocolDriver.newSession(params, modifier, prototype, utils_1.wrapCommand);
41
+ const prototype = getPrototype('browser');
42
+ const ProtocolDriver = (await import(automationProtocol)).default;
43
+ params = Object.assign({}, detectBackend(params), params);
44
+ updateCapabilities(params, automationProtocol);
45
+ const instance = await ProtocolDriver.newSession(params, modifier, prototype, wrapCommand);
78
46
  /**
79
47
  * we need to overwrite the original addCommand and overwriteCommand
80
- * in order to wrap the function within Fibers (only if webdriverio
81
- * is used with @wdio/cli)
82
48
  */
83
- if (params.framework && !(0, utils_2.isStub)(automationProtocol)) {
49
+ if (params.framework && !isStub(automationProtocol)) {
84
50
  const origAddCommand = instance.addCommand.bind(instance);
85
- instance.addCommand = (name, fn, attachToElement) => (origAddCommand(name, (0, utils_1.runFnInFiberContext)(fn), attachToElement));
51
+ instance.addCommand = (name, fn, attachToElement) => (origAddCommand(name, fn, attachToElement));
86
52
  const origOverwriteCommand = instance.overwriteCommand.bind(instance);
87
- instance.overwriteCommand = (name, fn, attachToElement) => (origOverwriteCommand(name, (0, utils_1.runFnInFiberContext)(fn), attachToElement));
53
+ instance.overwriteCommand = (name, fn, attachToElement) => (origOverwriteCommand(name, fn, attachToElement));
88
54
  }
89
- instance.addLocatorStrategy = (0, utils_2.addLocatorStrategyHandler)(instance);
55
+ instance.addLocatorStrategy = addLocatorStrategyHandler(instance);
90
56
  return instance;
91
57
  };
92
- exports.remote = remote;
93
- const attach = async function (attachOptions) {
94
- var _a, _b;
58
+ export const attach = async function (attachOptions) {
95
59
  /**
96
60
  * copy instances properties into new object
97
61
  */
98
62
  const params = {
99
63
  ...attachOptions,
100
64
  options: { ...attachOptions.options },
101
- ...(0, detectBackend_1.default)(attachOptions),
65
+ ...detectBackend(attachOptions),
102
66
  requestedCapabilities: attachOptions.requestedCapabilities
103
67
  };
104
- const prototype = (0, utils_2.getPrototype)('browser');
68
+ const prototype = getPrototype('browser');
105
69
  let automationProtocol = 'webdriver';
106
- if ((_a = params.options) === null || _a === void 0 ? void 0 : _a.automationProtocol) {
107
- automationProtocol = (_b = params.options) === null || _b === void 0 ? void 0 : _b.automationProtocol;
70
+ if (params.options?.automationProtocol) {
71
+ automationProtocol = params.options?.automationProtocol;
108
72
  }
109
- const ProtocolDriver = (await Promise.resolve().then(() => __importStar(require(automationProtocol)))).default;
110
- return ProtocolDriver.attachToSession(params, undefined, prototype, utils_1.wrapCommand);
73
+ const ProtocolDriver = (await import(automationProtocol)).default;
74
+ return ProtocolDriver.attachToSession(params, undefined, prototype, wrapCommand);
111
75
  };
112
- exports.attach = attach;
113
76
  /**
114
77
  * WebdriverIO allows you to run multiple automated sessions in a single test.
115
- * This is handy when youre testing features that require multiple users (for example, chat or WebRTC applications).
78
+ * This is handy when you're testing features that require multiple users (for example, chat or WebRTC applications).
116
79
  *
117
80
  * Instead of creating a couple of remote instances where you need to execute common commands like newSession() or url() on each instance,
118
81
  * you can simply create a multiremote instance and control all browsers at the same time.
@@ -129,47 +92,46 @@ exports.attach = attach;
129
92
  *
130
93
  * @see <a href="https://webdriver.io/docs/multiremote">External document and example usage</a>.
131
94
  */
132
- const multiremote = async function (params, { automationProtocol } = {}) {
133
- const multibrowser = new multiremote_1.default();
95
+ export const multiremote = async function (params, { automationProtocol } = {}) {
96
+ const multibrowser = new MultiRemote();
134
97
  const browserNames = Object.keys(params);
135
98
  /**
136
99
  * create all instance sessions
137
100
  */
138
101
  await Promise.all(browserNames.map(async (browserName) => {
139
- const instance = await (0, exports.remote)(params[browserName]);
102
+ const instance = await remote(params[browserName]);
140
103
  return multibrowser.addInstance(browserName, instance);
141
104
  }));
142
105
  /**
143
106
  * use attachToSession capability to wrap instances around blank pod
144
107
  */
145
- const prototype = (0, utils_2.getPrototype)('browser');
146
- const sessionParams = (0, utils_2.isStub)(automationProtocol) ? undefined : {
108
+ const prototype = getPrototype('browser');
109
+ const sessionParams = isStub(automationProtocol) ? undefined : {
147
110
  sessionId: '',
148
111
  isW3C: multibrowser.instances[browserNames[0]].isW3C,
149
112
  logLevel: multibrowser.instances[browserNames[0]].options.logLevel
150
113
  };
151
- const ProtocolDriver = automationProtocol && (0, utils_2.isStub)(automationProtocol)
152
- ? require(automationProtocol).default
153
- : webdriver_1.default;
154
- const driver = ProtocolDriver.attachToSession(sessionParams, multibrowser.modifier.bind(multibrowser), prototype, utils_1.wrapCommand);
114
+ const ProtocolDriver = automationProtocol && isStub(automationProtocol)
115
+ ? (await import(automationProtocol)).default
116
+ : WebDriver;
117
+ const driver = ProtocolDriver.attachToSession(sessionParams, multibrowser.modifier.bind(multibrowser), prototype, wrapCommand);
155
118
  /**
156
119
  * in order to get custom command overwritten or added to multiremote instance
157
120
  * we need to pass in the prototype of the multibrowser
158
121
  */
159
- if (!(0, utils_2.isStub)(automationProtocol)) {
122
+ if (!isStub(automationProtocol)) {
160
123
  const origAddCommand = driver.addCommand.bind(driver);
161
124
  driver.addCommand = (name, fn, attachToElement) => {
162
- return origAddCommand(name, (0, utils_1.runFnInFiberContext)(fn), attachToElement, Object.getPrototypeOf(multibrowser.baseInstance), multibrowser.instances);
125
+ return origAddCommand(name, fn, attachToElement, Object.getPrototypeOf(multibrowser.baseInstance), multibrowser.instances);
163
126
  };
164
127
  const origOverwriteCommand = driver.overwriteCommand.bind(driver);
165
128
  driver.overwriteCommand = (name, fn, attachToElement) => {
166
- return origOverwriteCommand(name, (0, utils_1.runFnInFiberContext)(fn), attachToElement, Object.getPrototypeOf(multibrowser.baseInstance), multibrowser.instances);
129
+ return origOverwriteCommand(name, fn, attachToElement, Object.getPrototypeOf(multibrowser.baseInstance), multibrowser.instances);
167
130
  };
168
131
  }
169
- driver.addLocatorStrategy = (0, utils_2.addLocatorStrategyHandler)(driver);
132
+ driver.addLocatorStrategy = addLocatorStrategyHandler(driver);
170
133
  return driver;
171
134
  };
172
- exports.multiremote = multiremote;
173
- exports.SevereServiceError = SevereServiceError_1.default;
174
- __exportStar(require("./types"), exports);
175
- __exportStar(require("./utils/interception/types"), exports);
135
+ export const SevereServiceError = SevereServiceErrorImport;
136
+ export * from './types.js';
137
+ export * from './utils/interception/types.js';
@@ -2,7 +2,7 @@
2
2
  * This method is an command wrapper for elements that checks if a command is called
3
3
  * that wasn't found on the page and automatically waits for it
4
4
  *
5
- * @param {Function} fn commandWrap from wdio-sync package (or shim if not running in sync)
5
+ * @param {Function} fn command shim
6
6
  */
7
7
  export declare const elementErrorHandler: (fn: Function) => (commandName: string, commandFn: Function) => (this: WebdriverIO.Element, ...args: any[]) => any;
8
8
  /**
@@ -1,32 +1,26 @@
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.multiremoteHandler = exports.elementErrorHandler = void 0;
7
- const refetchElement_1 = __importDefault(require("./utils/refetchElement"));
8
- const implicitWait_1 = __importDefault(require("./utils/implicitWait"));
9
- const utils_1 = require("./utils");
10
- const constants_1 = require("./constants");
1
+ import refetchElement from './utils/refetchElement.js';
2
+ import implicitWait from './utils/implicitWait.js';
3
+ import { getBrowserObject } from './utils/index.js';
4
+ import { ELEMENT_KEY } from './constants.js';
11
5
  /**
12
6
  * This method is an command wrapper for elements that checks if a command is called
13
7
  * that wasn't found on the page and automatically waits for it
14
8
  *
15
- * @param {Function} fn commandWrap from wdio-sync package (or shim if not running in sync)
9
+ * @param {Function} fn command shim
16
10
  */
17
- const elementErrorHandler = (fn) => (commandName, commandFn) => {
11
+ export const elementErrorHandler = (fn) => (commandName, commandFn) => {
18
12
  return function elementErrorHandlerCallback(...args) {
19
13
  return fn(commandName, async function elementErrorHandlerCallbackFn() {
20
- const element = await (0, implicitWait_1.default)(this, commandName);
14
+ const element = await implicitWait(this, commandName);
21
15
  this.elementId = element.elementId;
22
- this[constants_1.ELEMENT_KEY] = element.elementId;
16
+ this[ELEMENT_KEY] = element.elementId;
23
17
  try {
24
18
  const result = await fn(commandName, commandFn).apply(this, args);
25
19
  /**
26
20
  * assume Safari responses like { error: 'no such element', message: '', stacktrace: '' }
27
21
  * as `stale element reference`
28
22
  */
29
- const caps = (0, utils_1.getBrowserObject)(this).capabilities;
23
+ const caps = getBrowserObject(this).capabilities;
30
24
  if (caps && caps.browserName === 'safari' &&
31
25
  result && result.error === 'no such element') {
32
26
  const errorName = 'stale element reference';
@@ -38,7 +32,7 @@ const elementErrorHandler = (fn) => (commandName, commandFn) => {
38
32
  }
39
33
  catch (err) {
40
34
  if (err.name === 'stale element reference') {
41
- const element = await (0, refetchElement_1.default)(this, commandName);
35
+ const element = await refetchElement(this, commandName);
42
36
  this.elementId = element.elementId;
43
37
  this.parent = element.parent;
44
38
  return await fn(commandName, commandFn).apply(this, args);
@@ -48,11 +42,10 @@ const elementErrorHandler = (fn) => (commandName, commandFn) => {
48
42
  }).apply(this);
49
43
  };
50
44
  };
51
- exports.elementErrorHandler = elementErrorHandler;
52
45
  /**
53
46
  * handle single command calls from multiremote instances
54
47
  */
55
- const multiremoteHandler = (wrapCommand) => (commandName) => {
48
+ export const multiremoteHandler = (wrapCommand) => (commandName) => {
56
49
  return wrapCommand(commandName, function (...args) {
57
50
  // @ts-ignore
58
51
  const commandResults = this.instances.map((instanceName) => {
@@ -62,4 +55,3 @@ const multiremoteHandler = (wrapCommand) => (commandName) => {
62
55
  return Promise.all(commandResults);
63
56
  });
64
57
  };
65
- exports.multiremoteHandler = multiremoteHandler;