webdriverio 7.20.6 → 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
@@ -0,0 +1,3 @@
1
+ import type { Options } from '@wdio/types';
2
+ export declare type RemoteOptions = Options.WebdriverIO & Omit<Options.Testrunner, 'capabilities'>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,aAAa,CAAA;AAGxD,oBAAY,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ exports.remote = async function (params, remoteModifier) {
2
+ const { remote } = await import('../index.js');
3
+ return remote(params, remoteModifier);
4
+ };
5
+ exports.attach = async function (attachOptions) {
6
+ const { attach } = await import('../index.js');
7
+ return attach(attachOptions);
8
+ };
9
+ exports.multiremote = async function (params, { automationProtocol } = {}) {
10
+ const { multiremote } = await import('../index.js');
11
+ return multiremote(params, { automationProtocol });
12
+ };
13
+
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,3 +1,4 @@
1
+ import type { ElementReference } from '@wdio/protocols';
1
2
  import type { Selector, ElementArray } from '../../types';
2
3
  /**
3
4
  * The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver#findelements) command in order
@@ -38,6 +39,14 @@ import type { Selector, ElementArray } from '../../types';
38
39
  })[0];
39
40
  console.log(await text.$$('li')[2].$('a').getText()); // outputs: "API"
40
41
  });
42
+
43
+ it('can create element array out of single elements', async () => {
44
+ const red = await $('.red');
45
+ const green = await $('.green');
46
+ const elems = $$([red, green]);
47
+ console.log(await elems.map((e) => e.getAttribute('class')));
48
+ // returns "[ 'box red ui-droppable', 'box green' ]"
49
+ });
41
50
  * </example>
42
51
  *
43
52
  * @alias $$
@@ -46,5 +55,5 @@ import type { Selector, ElementArray } from '../../types';
46
55
  * @type utility
47
56
  *
48
57
  */
49
- export default function $$(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementArray>;
58
+ export default function $$(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector | ElementReference[] | WebdriverIO.Element[]): Promise<ElementArray>;
50
59
  //# sourceMappingURL=$$.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAA8B,EAAE,CAC5B,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,yBAKrB"}
1
+ {"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAA8B,EAAE,CAC5B,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,yBAOlE"}
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
4
- const getElementObject_1 = require("../../utils/getElementObject");
1
+ import { findElements, enhanceElementsArray } from '../../utils/index.js';
2
+ import { getElements } from '../../utils/getElementObject.js';
5
3
  /**
6
4
  * The `$$` command is a short way to call the [`findElements`](/docs/api/webdriver#findelements) command in order
7
5
  * to fetch multiple elements on the page. It returns an array with element results that will have an
@@ -41,6 +39,14 @@ const getElementObject_1 = require("../../utils/getElementObject");
41
39
  })[0];
42
40
  console.log(await text.$$('li')[2].$('a').getText()); // outputs: "API"
43
41
  });
42
+
43
+ it('can create element array out of single elements', async () => {
44
+ const red = await $('.red');
45
+ const green = await $('.green');
46
+ const elems = $$([red, green]);
47
+ console.log(await elems.map((e) => e.getAttribute('class')));
48
+ // returns "[ 'box red ui-droppable', 'box green' ]"
49
+ });
44
50
  * </example>
45
51
  *
46
52
  * @alias $$
@@ -49,9 +55,10 @@ const getElementObject_1 = require("../../utils/getElementObject");
49
55
  * @type utility
50
56
  *
51
57
  */
52
- async function $$(selector) {
53
- const res = await utils_1.findElements.call(this, selector);
54
- const elements = await getElementObject_1.getElements.call(this, selector, res);
55
- return (0, utils_1.enhanceElementsArray)(elements, this, selector);
58
+ export default async function $$(selector) {
59
+ const res = Array.isArray(selector)
60
+ ? selector
61
+ : await findElements.call(this, selector);
62
+ const elements = await getElements.call(this, selector, res);
63
+ return enhanceElementsArray(elements, this, selector);
56
64
  }
57
- exports.default = $$;
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
4
- const getElementObject_1 = require("../../utils/getElementObject");
5
- const constants_1 = require("../../constants");
1
+ import { findElement } from '../../utils/index.js';
2
+ import { getElement } from '../../utils/getElementObject.js';
3
+ import { ELEMENT_KEY } from '../../constants.js';
6
4
  /**
7
5
  * The `$` command is a short way to call the [`findElement`](/docs/api/webdriver#findelement) command in order
8
6
  * to fetch a single element on the page. It returns an object that with an extended prototype to call
@@ -77,18 +75,17 @@ const constants_1 = require("../../constants");
77
75
  * @type utility
78
76
  *
79
77
  */
80
- async function $(selector) {
78
+ export default async function $(selector) {
81
79
  /**
82
80
  * convert protocol result into WebdriverIO element
83
81
  * e.g. when element was fetched with `getActiveElement`
84
82
  */
85
83
  if (typeof selector === 'object') {
86
84
  const elementRef = selector;
87
- if (typeof elementRef[constants_1.ELEMENT_KEY] === 'string') {
88
- return getElementObject_1.getElement.call(this, undefined, elementRef);
85
+ if (typeof elementRef[ELEMENT_KEY] === 'string') {
86
+ return getElement.call(this, undefined, elementRef);
89
87
  }
90
88
  }
91
- const res = await utils_1.findElement.call(this, selector);
92
- return getElementObject_1.getElement.call(this, selector, res);
89
+ const res = await findElement.call(this, selector);
90
+ return getElement.call(this, selector, res);
93
91
  }
94
- exports.default = $;
@@ -0,0 +1,132 @@
1
+ import { KeyAction, PointerAction, WheelAction, BaseActionParams } from '../../utils/actions/index.js';
2
+ /**
3
+ * The action command is a low-level interface for providing virtualized device input actions to the web browser.
4
+ *
5
+ * In addition to high level commands such like `scrollIntoView`, `doubleClick`, the Actions API provides granular
6
+ * control over exactly what designated input devices can do. WebdriverIO provides an interface for 3 kinds of input
7
+ * sources:
8
+ *
9
+ * - a key input for keyboard devices
10
+ * - a pointer input for a mouse, pen or touch devices
11
+ * - and wheel inputs for scroll wheel devices
12
+ *
13
+ * Every chain of action commands has to be completed calling `perform` in order to trigger the set of actions. This
14
+ * causes actions [to be released](https://w3c.github.io/webdriver/#release-actions) and events to be fired. You can
15
+ * skip this by passing in `true` (e.g. `browser.actions(...).perform(true)`).
16
+ *
17
+ * :::info
18
+ *
19
+ * Support for this command and specific actions can differ based on the environment. Progress on the development
20
+ * can be followed on [wpt.fyi](https://wpt.fyi/results/webdriver/tests/perform_actions?label=experimental&label=master&aligned).
21
+ * For mobile you might want to use Appium specific gesture commands on [iOS](https://github.com/appium/appium-xcuitest-driver#mobile-pinch)
22
+ * and [Android](https://github.com/appium/appium-uiautomator2-driver#mobile-gesture-commands).
23
+ *
24
+ * :::
25
+ *
26
+ * ### Key input source
27
+ *
28
+ * A key input source is an input source that is associated with a keyboard-type device. It can be triggered
29
+ * by using the `key` type parameters. e.g.:
30
+ *
31
+ * ```ts
32
+ * browser.action('key')
33
+ * ```
34
+ *
35
+ * It returns a `KeyAction` object that supports the following actions:
36
+ *
37
+ * - `down(value: string)`: generates a key down action
38
+ * - `up(value: string)`: generates a key up action
39
+ * - `pause(ms: number)`: indicate that an input source does nothing during a particular tick
40
+ *
41
+ * ### Pointer input source
42
+ *
43
+ * A pointer input source is an input source that is associated with a pointer-type input device. The type can be
44
+ * specified when invoking the `action` command, e.g.:
45
+ *
46
+ * ```ts
47
+ * browser.action('pointer'. {
48
+ * parameters: { pointerType: 'mouse' } // "mouse" is default value, also possible: "pen" or "touch"
49
+ * })
50
+ * ```
51
+ *
52
+ * It returns a `PointerAction` object that supports the following actions:
53
+ *
54
+ * - `down (button: 'left' | 'middle' | 'right')`: creates an action to press a single key
55
+ * - `down (params: PointerActionParams)`: creates an action to press a single key with detailed parameters
56
+ * - `move (x: number, y: number)`: Creates an action for moving the pointer `x` and `y` pixels from the viewport
57
+ * - `move (params: PointerActionMoveParams)`: Creates an action for moving the pointer `x` and `y` pixels from the
58
+ * specified `origin`. The `origin` may be defined as the pointers current position (e.g. "pointer"), the viewport
59
+ * (e.g. "viewport") or the center of a specific element.
60
+ * - `up (button: 'left' | 'middle' | 'right')`: creates an action to release a single key
61
+ * - `up (params: PointerActionUpParams)`: creates an action to release a single key with detailed parameters
62
+ * - `cancel()`: An action that cancels this pointer's current input.
63
+ * - `pause(ms: number)`: indicate that an input source does nothing during a particular tick
64
+ *
65
+ * You can find detailed information on the [`PointerActionParams`](https://github.com/webdriverio/webdriverio/blob/8ca026c75bf7c27ef9d574f0ec48d8bc13658602/packages/webdriverio/src/utils/actions/pointer.ts#L20-L35), [`PointerActionMoveParams`](https://github.com/webdriverio/webdriverio/blob/8ca026c75bf7c27ef9d574f0ec48d8bc13658602/packages/webdriverio/src/utils/actions/pointer.ts#L20-L42) and [`PointerActionUpParams`](https://github.com/webdriverio/webdriverio/blob/8ca026c75bf7c27ef9d574f0ec48d8bc13658602/packages/webdriverio/src/utils/actions/pointer.ts#L13-L19)
66
+ * parameter types in the project type definition.
67
+ *
68
+ * ### Wheel input source
69
+ *
70
+ * A wheel input source is an input source that is associated with a wheel-type input device.
71
+ *
72
+ * ```ts
73
+ * browser.action('wheel')
74
+ * ```
75
+ *
76
+ * It returns a `WheelAction` object that supports the following actions:
77
+ *
78
+ * - `scroll (params: ScrollParams)`: scrolls a page to given coordinates or origin
79
+ * - `pause(ms: number)`: indicate that an input source does nothing during a particular tick
80
+ *
81
+ * You can find detailed information on the [`ScrollParams`](https://github.com/webdriverio/webdriverio/blob/8ca026c75bf7c27ef9d574f0ec48d8bc13658602/packages/webdriverio/src/utils/actions/wheel.ts#L4-L29) parameter type in the project type definition.
82
+ *
83
+ * <example>
84
+ :pointer-action.js
85
+ it('drag and drop using pointer action command', async () => {
86
+ const origin = await $('#source')
87
+ const targetOrigin = await $('#target')
88
+
89
+ return browser.action('pointer')
90
+ .move({ duration: 0, origin, x: 0, y: 0 })
91
+ .down({ button: 0 }) // left button
92
+ .pause(10)
93
+ .move({ duration, origin: targetOrigin })
94
+ .up({ button: 0 })
95
+ .perform()
96
+ });
97
+ :key-action.js
98
+ it('should emit key events using key action commands', async () => {
99
+ const elem = await $('input')
100
+ await elem.click() // make element active
101
+
102
+ await browser.action('key)
103
+ .down('f')
104
+ .down('o')
105
+ .down('o')
106
+ .up('f')
107
+ .up('o')
108
+ .up('o')
109
+ .perform()
110
+
111
+ console.log(await elem.getValue()) // returns "foo"
112
+ })
113
+ :wheel-action.js
114
+ it('should scroll using wheel action commands', async () => {
115
+ console.log(await browser.execute(() => window.scrollY)) // returns 0
116
+ await browser.action('wheel').scroll({
117
+ deltaX: 0,
118
+ deltaY: 500,
119
+ duration: 200
120
+ }).perform()
121
+ console.log(await browser.execute(() => window.scrollY)) // returns 500
122
+ })
123
+ * </example>
124
+ *
125
+ * @alias browser.action
126
+ * @type utility
127
+ *
128
+ */
129
+ export default function action(this: WebdriverIO.Browser, type: 'key', opts?: Pick<BaseActionParams, 'id'>): KeyAction;
130
+ export default function action(this: WebdriverIO.Browser, type: 'pointer', opts?: BaseActionParams): PointerAction;
131
+ export default function action(this: WebdriverIO.Browser, type: 'wheel', opts?: Pick<BaseActionParams, 'id'>): WheelAction;
132
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAc,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAElH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8HG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,IAAI,EAAE,KAAK,EACX,IAAI,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,GACpC,SAAS,CAAA;AACZ,MAAM,CAAC,OAAO,UAAU,MAAM,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,IAAI,EAAE,SAAS,EACf,IAAI,CAAC,EAAE,gBAAgB,GACxB,aAAa,CAAA;AAChB,MAAM,CAAC,OAAO,UAAU,MAAM,CAC1B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,IAAI,EAAE,OAAO,EACb,IAAI,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,GACpC,WAAW,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { KeyAction, PointerAction, WheelAction } from '../../utils/actions/index.js';
2
+ export default function action(type, opts) {
3
+ if (type === 'key') {
4
+ return new KeyAction(this, opts);
5
+ }
6
+ if (type === 'pointer') {
7
+ return new PointerAction(this, opts);
8
+ }
9
+ if (type === 'wheel') {
10
+ return new WheelAction(this, opts);
11
+ }
12
+ throw new Error(`Unsupported action type "${type}", supported are "key", "pointer", "wheel"`);
13
+ }
@@ -0,0 +1,29 @@
1
+ import { KeyAction, PointerAction, WheelAction } from '../../utils/actions/index.js';
2
+ /**
3
+ * Allows to run multiple action interaction at once, e.g. to simulate a pinch zoom.
4
+ * For more information on the `action` command, check out the [docs](./action).
5
+ *
6
+ * <example>
7
+ :action.js
8
+ it('run multiple actions at once for a pinch zoom', async () => {
9
+ await browser.actions([
10
+ browser.action('pointer')
11
+ .move(500, 500)
12
+ .down()
13
+ .move(250, 250)
14
+ .up(),
15
+ browser.action('pointer')
16
+ .move(500, 500)
17
+ .down()
18
+ .move(750, 750)
19
+ .up()
20
+ ])
21
+ });
22
+ * </example>
23
+ *
24
+ * @alias browser.action
25
+ * @type utility
26
+ *
27
+ */
28
+ export default function actions(this: WebdriverIO.Browser, actions: (KeyAction | PointerAction | WheelAction)[]): Promise<void>;
29
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,CAAC,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC,EAAE,GACrD,OAAO,CAAC,IAAI,CAAC,CAGf"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Allows to run multiple action interaction at once, e.g. to simulate a pinch zoom.
3
+ * For more information on the `action` command, check out the [docs](./action).
4
+ *
5
+ * <example>
6
+ :action.js
7
+ it('run multiple actions at once for a pinch zoom', async () => {
8
+ await browser.actions([
9
+ browser.action('pointer')
10
+ .move(500, 500)
11
+ .down()
12
+ .move(250, 250)
13
+ .up(),
14
+ browser.action('pointer')
15
+ .move(500, 500)
16
+ .down()
17
+ .move(750, 750)
18
+ .up()
19
+ ])
20
+ });
21
+ * </example>
22
+ *
23
+ * @alias browser.action
24
+ * @type utility
25
+ *
26
+ */
27
+ export default async function actions(actions) {
28
+ await this.performActions(actions.map((action) => action.toJSON()));
29
+ await this.releaseActions();
30
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The browser method `addCommand` helps you to write your own set of commands. You can write your command in a synchronous way or in an asynchronous way.
2
+ * The browser method `addCommand` helps you to write your own set of commands.
3
3
  *
4
4
  * :::info
5
5
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * The browser method `addCommand` helps you to write your own set of commands. You can write your command in a synchronous way or in an asynchronous way.
3
+ * The browser method `addCommand` helps you to write your own set of commands.
4
4
  *
5
5
  * :::info
6
6
  *
@@ -1,12 +1,14 @@
1
1
  /**
2
- * You can use `call` to execute any async action within your test spec. The command itself
3
- * is treated like a synchronous function. It accepts promises and stops the execution until
4
- * the promise has resolved.
2
+ * You can use `call` to execute any async action within your test spec.
3
+ * It accepts promises and stops the execution until the promise has been resolved.
5
4
  *
6
- * This command helps to run asynchronous code within a synchronous context. With
7
- * WebdriverIO deprecating synchronous usage (see [RFC](https://github.com/webdriverio/webdriverio/discussions/6702))
5
+ * :::info
6
+ *
7
+ * With WebdriverIO deprecating synchronous usage (see [RFC](https://github.com/webdriverio/webdriverio/discussions/6702))
8
8
  * this command is not very useful anymore.
9
9
  *
10
+ * :::
11
+ *
10
12
  * <example>
11
13
  :call.js
12
14
  it('some testing here', async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC,EAAG,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM5D"}
1
+ {"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,CAAC,EAAG,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM5D"}
@@ -1,14 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
- * You can use `call` to execute any async action within your test spec. The command itself
5
- * is treated like a synchronous function. It accepts promises and stops the execution until
6
- * the promise has resolved.
2
+ * You can use `call` to execute any async action within your test spec.
3
+ * It accepts promises and stops the execution until the promise has been resolved.
7
4
  *
8
- * This command helps to run asynchronous code within a synchronous context. With
9
- * WebdriverIO deprecating synchronous usage (see [RFC](https://github.com/webdriverio/webdriverio/discussions/6702))
5
+ * :::info
6
+ *
7
+ * With WebdriverIO deprecating synchronous usage (see [RFC](https://github.com/webdriverio/webdriverio/discussions/6702))
10
8
  * this command is not very useful anymore.
11
9
  *
10
+ * :::
11
+ *
12
12
  * <example>
13
13
  :call.js
14
14
  it('some testing here', async () => {
@@ -40,10 +40,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  * @type utility
41
41
  *
42
42
  */
43
- function call(fn) {
43
+ export default function call(fn) {
44
44
  if (typeof fn === 'function') {
45
45
  return fn();
46
46
  }
47
47
  throw new Error('Command argument for "call" needs to be a function');
48
48
  }
49
- exports.default = call;
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
4
- const getElementObject_1 = require("../../utils/getElementObject");
5
- const constants_1 = require("../../constants");
1
+ import { enhanceElementsArray } from '../../utils/index.js';
2
+ import { getElements } from '../../utils/getElementObject.js';
3
+ import { ELEMENT_KEY } from '../../constants.js';
6
4
  /**
7
5
  *
8
6
  * The `customs$$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
@@ -26,7 +24,7 @@ const constants_1 = require("../../constants");
26
24
  * @param {Any} strategyArguments
27
25
  * @return {ElementArray}
28
26
  */
29
- async function custom$$(strategyName, ...strategyArguments) {
27
+ export default async function custom$$(strategyName, ...strategyArguments) {
30
28
  const strategy = this.strategies.get(strategyName);
31
29
  if (!strategy) {
32
30
  throw Error('No strategy found for ' + strategyName);
@@ -41,8 +39,7 @@ async function custom$$(strategyName, ...strategyArguments) {
41
39
  if (!Array.isArray(res)) {
42
40
  res = [res];
43
41
  }
44
- res = res.filter(el => !!el && typeof el[constants_1.ELEMENT_KEY] === 'string');
45
- const elements = res.length ? await getElementObject_1.getElements.call(this, strategyRef, res) : [];
46
- return (0, utils_1.enhanceElementsArray)(elements, this, strategyName, 'custom$$', strategyArguments);
42
+ res = res.filter(el => !!el && typeof el[ELEMENT_KEY] === 'string');
43
+ const elements = res.length ? await getElements.call(this, strategyRef, res) : [];
44
+ return enhanceElementsArray(elements, this, strategyName, 'custom$$', strategyArguments);
47
45
  }
48
- exports.default = custom$$;
@@ -6,7 +6,7 @@
6
6
  :example.js
7
7
  it('should fetch the project title', async () => {
8
8
  await browser.url('https://webdriver.io')
9
- await browser.addLocatorStrategy('myStrat', (selector) => {
9
+ browser.addLocatorStrategy('myStrat', (selector) => {
10
10
  return document.querySelectorAll(selector)
11
11
  })
12
12
 
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getElementObject_1 = require("../../utils/getElementObject");
4
- const constants_1 = require("../../constants");
1
+ import { getElement } from '../../utils/getElementObject.js';
2
+ import { ELEMENT_KEY } from '../../constants.js';
5
3
  /**
6
4
  *
7
5
  * The `custom$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
@@ -10,7 +8,7 @@ const constants_1 = require("../../constants");
10
8
  :example.js
11
9
  it('should fetch the project title', async () => {
12
10
  await browser.url('https://webdriver.io')
13
- await browser.addLocatorStrategy('myStrat', (selector) => {
11
+ browser.addLocatorStrategy('myStrat', (selector) => {
14
12
  return document.querySelectorAll(selector)
15
13
  })
16
14
 
@@ -25,7 +23,7 @@ const constants_1 = require("../../constants");
25
23
  * @param {Any} strategyArguments
26
24
  * @return {Element}
27
25
  */
28
- async function custom$(strategyName, ...strategyArguments) {
26
+ export default async function custom$(strategyName, ...strategyArguments) {
29
27
  const strategy = this.strategies.get(strategyName);
30
28
  if (!strategy) {
31
29
  throw Error('No strategy found for ' + strategyName);
@@ -40,9 +38,8 @@ async function custom$(strategyName, ...strategyArguments) {
40
38
  if (Array.isArray(res)) {
41
39
  res = res[0];
42
40
  }
43
- if (res && typeof res[constants_1.ELEMENT_KEY] === 'string') {
44
- return await getElementObject_1.getElement.call(this, strategyRef, res);
41
+ if (res && typeof res[ELEMENT_KEY] === 'string') {
42
+ return await getElement.call(this, strategyRef, res);
45
43
  }
46
44
  throw Error('Your locator strategy script must return an element');
47
45
  }
48
- exports.default = custom$;
@@ -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 serialize_error_1 = require("serialize-error");
7
- const repl_1 = __importDefault(require("@wdio/repl"));
1
+ import { serializeError } from 'serialize-error';
2
+ import WDIORepl from '@wdio/repl';
8
3
  /**
9
4
  *
10
5
  * This command helps you to debug your integration tests. It stops the running browser and gives
@@ -35,15 +30,15 @@ const repl_1 = __importDefault(require("@wdio/repl"));
35
30
  * @type utility
36
31
  *
37
32
  */
38
- function debug(commandTimeout = 5000) {
39
- const repl = new repl_1.default();
40
- const { introMessage } = repl_1.default;
33
+ export default function debug(commandTimeout = 5000) {
34
+ const repl = new WDIORepl();
35
+ const { introMessage } = WDIORepl;
41
36
  /**
42
37
  * run repl in standalone mode
43
38
  */
44
- if (!process.env.WDIO_WORKER || typeof process.send !== 'function') {
39
+ if (!process.env.WDIO_WORKER_ID || typeof process.send !== 'function') {
45
40
  // eslint-disable-next-line
46
- console.log(repl_1.default.introMessage);
41
+ console.log(WDIORepl.introMessage);
47
42
  const context = {
48
43
  browser: this,
49
44
  driver: this,
@@ -85,7 +80,7 @@ function debug(commandTimeout = 5000) {
85
80
  name: 'result',
86
81
  params: {
87
82
  error: true,
88
- ...(0, serialize_error_1.serializeError)(err)
83
+ ...serializeError(err)
89
84
  }
90
85
  });
91
86
  }
@@ -105,4 +100,3 @@ function debug(commandTimeout = 5000) {
105
100
  });
106
101
  return new Promise((resolve) => (commandResolve = resolve));
107
102
  }
108
- exports.default = debug;
@@ -1,6 +1,6 @@
1
1
  /**
2
- *
3
- * Delete cookies visible to the current page. By providing a cookie name it just removes the single cookie or more when multiple names are passed.
2
+ * Delete cookies visible to the current page. By providing a cookie name it
3
+ * just removes the single cookie or more when multiple names are passed.
4
4
  *
5
5
  * <example>
6
6
  :deleteCookie.js
@@ -36,7 +36,7 @@
36
36
  * </example>
37
37
  *
38
38
  * @alias browser.deleteCookies
39
- * @param {String=|String[]=} names names of cookies to be deleted
39
+ * @param {String | String[]} names names of cookies to be deleted
40
40
  * @uses webdriver/deleteAllCookies,webdriver/deleteCookie
41
41
  * @type cookie
42
42
  *
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
- *
5
- * Delete cookies visible to the current page. By providing a cookie name it just removes the single cookie or more when multiple names are passed.
2
+ * Delete cookies visible to the current page. By providing a cookie name it
3
+ * just removes the single cookie or more when multiple names are passed.
6
4
  *
7
5
  * <example>
8
6
  :deleteCookie.js
@@ -38,12 +36,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
36
  * </example>
39
37
  *
40
38
  * @alias browser.deleteCookies
41
- * @param {String=|String[]=} names names of cookies to be deleted
39
+ * @param {String | String[]} names names of cookies to be deleted
42
40
  * @uses webdriver/deleteAllCookies,webdriver/deleteCookie
43
41
  * @type cookie
44
42
  *
45
43
  */
46
- function deleteCookies(names) {
44
+ export default function deleteCookies(names) {
47
45
  if (names === undefined) {
48
46
  return this.deleteAllCookies();
49
47
  }
@@ -53,4 +51,3 @@ function deleteCookies(names) {
53
51
  }
54
52
  return Promise.all(namesList.map(name => this.deleteCookie(name)));
55
53
  }
56
- exports.default = deleteCookies;
@@ -24,8 +24,8 @@
24
24
  });
25
25
  * </example>
26
26
  *
27
- * @param {String|Function} script The script to execute.
28
- * @param {*=} arguments script arguments
27
+ * @param {String|Function} script The script to execute.
28
+ * @param {*=} arguments script arguments
29
29
  *
30
30
  * @return {*} The script result.
31
31
  *