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
@@ -67,6 +67,6 @@
67
67
  * @type utility
68
68
  *
69
69
  */
70
- import $ from '../browser/$';
70
+ import $ from '../browser/$.js';
71
71
  export default $;
72
72
  //# sourceMappingURL=$.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/$.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,OAAO,CAAC,MAAM,cAAc,CAAA;AAC5B,eAAe,CAAC,CAAA"}
1
+ {"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/$.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,OAAO,CAAC,MAAM,iBAAiB,CAAA;AAC/B,eAAe,CAAC,CAAA"}
@@ -1,8 +1,3 @@
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
1
  /**
7
2
  * The `$` command is a short way to call the [`findElement`](/docs/api/webdriver#findelement) command in order
8
3
  * to fetch a single element on the page similar to the `$` command from the browser scope. The difference when calling
@@ -72,5 +67,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
72
67
  * @type utility
73
68
  *
74
69
  */
75
- const _1 = __importDefault(require("../browser/$"));
76
- exports.default = _1.default;
70
+ import $ from '../browser/$.js';
71
+ export default $;
@@ -1,15 +1,13 @@
1
- export declare type CommandOptions = {
2
- translateToUnicode?: boolean;
3
- };
4
- export declare type Value = string | number;
5
1
  /**
6
2
  *
7
- * Add a value to an object found by given selector. You can also use unicode
8
- * characters like Left arrow or Back space. WebdriverIO will take care of
9
- * translating them into unicode characters. You’ll find all supported characters
10
- * [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
11
- * To do that, the value has to correspond to a key from the table. It can be disabled
12
- * by setting `translateToUnicode` optional parameter to false.
3
+ * Add a value to an input or textarea element found by given selector.
4
+ *
5
+ * :::info
6
+ *
7
+ * If you like to use special characters, e.g. to copy and paste a value from one input to another, use the
8
+ * [`keys`](/docs/api/browser/keys) command.
9
+ *
10
+ * :::
13
11
  *
14
12
  * <example>
15
13
  :addValue.js
@@ -24,10 +22,8 @@ export declare type Value = string | number;
24
22
  * </example>
25
23
  *
26
24
  * @alias element.addValue
27
- * @param {string | number | Array<string | number>} value value to be added
28
- * @param {CommandOptions=} options command options (optional)
29
- * @param {boolean} options.translateToUnicode enable translation string to unicode value automatically
25
+ * @param {string | number} value value to be added
30
26
  *
31
27
  */
32
- export default function addValue(this: WebdriverIO.Element, value: Value | Value[], { translateToUnicode }?: CommandOptions): Promise<void>;
28
+ export default function addValue(this: WebdriverIO.Element, value: string | number): Promise<void>;
33
29
  //# sourceMappingURL=addValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addValue.d.ts","sourceRoot":"","sources":["../../../src/commands/element/addValue.ts"],"names":[],"mappings":"AAKA,oBAAY,cAAc,GAAG;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED,oBAAY,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AASnC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC5B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,EACtB,EAAE,kBAAyB,EAAE,GAAE,cAAmB,iBAWrD"}
1
+ {"version":3,"file":"addValue.d.ts","sourceRoot":"","sources":["../../../src/commands/element/addValue.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC5B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,KAAK,EAAE,MAAM,GAAG,MAAM,iBAoBzB"}
@@ -1,22 +1,14 @@
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("../../utils");
7
- const logger_1 = __importDefault(require("@wdio/logger"));
8
- const log = (0, logger_1.default)('addValue');
9
- const isNumberOrString = (input) => typeof input === 'string' || typeof input === 'number';
10
- const isValidType = (value) => (isNumberOrString(value) ||
11
- Array.isArray(value) && value.every((item) => isNumberOrString(item)));
1
+ const VALID_TYPES = ['string', 'number'];
12
2
  /**
13
3
  *
14
- * Add a value to an object found by given selector. You can also use unicode
15
- * characters like Left arrow or Back space. WebdriverIO will take care of
16
- * translating them into unicode characters. You’ll find all supported characters
17
- * [here](https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions).
18
- * To do that, the value has to correspond to a key from the table. It can be disabled
19
- * by setting `translateToUnicode` optional parameter to false.
4
+ * Add a value to an input or textarea element found by given selector.
5
+ *
6
+ * :::info
7
+ *
8
+ * If you like to use special characters, e.g. to copy and paste a value from one input to another, use the
9
+ * [`keys`](/docs/api/browser/keys) command.
10
+ *
11
+ * :::
20
12
  *
21
13
  * <example>
22
14
  :addValue.js
@@ -31,18 +23,22 @@ const isValidType = (value) => (isNumberOrString(value) ||
31
23
  * </example>
32
24
  *
33
25
  * @alias element.addValue
34
- * @param {string | number | Array<string | number>} value value to be added
35
- * @param {CommandOptions=} options command options (optional)
36
- * @param {boolean} options.translateToUnicode enable translation string to unicode value automatically
26
+ * @param {string | number} value value to be added
37
27
  *
38
28
  */
39
- function addValue(value, { translateToUnicode = true } = {}) {
40
- if (!isValidType(value)) {
41
- log.warn('@deprecated: support for type "string", "number" or "Array<string | number>" is deprecated');
29
+ export default function addValue(value) {
30
+ /**
31
+ * The JSONWireProtocol allowed array values and use of special characters when adding a value to an input.
32
+ * With the W3C protocol this was not possible anymore. This is a type check to ensure users are aware of
33
+ * this transition.
34
+ */
35
+ if (!VALID_TYPES.includes(typeof value)) {
36
+ throw new Error('The setValue/addValue command only take string or number values. ' +
37
+ 'If you like to use special characters, use the "keys" command.');
42
38
  }
43
- if (!this.isW3C) {
44
- return this.elementSendKeys(this.elementId, (0, utils_1.transformToCharString)(value, translateToUnicode));
39
+ if (this.isW3C) {
40
+ return this.elementSendKeys(this.elementId, value.toString());
45
41
  }
46
- return this.elementSendKeys(this.elementId, (0, utils_1.transformToCharString)(value, translateToUnicode).join(''));
42
+ // @ts-expect-error command is not typed as JWP command
43
+ return this.elementSendKeys(this.elementId, [value.toString()]);
47
44
  }
48
- exports.default = addValue;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  *
3
- * Clear a `<textarea>` or text `<input>` element’s value. Make sure you can interact with the
3
+ * Clear the value of an input or textarea element. Make sure you can interact with the
4
4
  * element before using this command. You can't clear an input element that is disabled or in
5
5
  * readonly mode.
6
6
  *
@@ -1,7 +1,6 @@
1
- "use strict";
2
1
  /**
3
2
  *
4
- * Clear a `<textarea>` or text `<input>` element’s value. Make sure you can interact with the
3
+ * Clear the value of an input or textarea element. Make sure you can interact with the
5
4
  * element before using this command. You can't clear an input element that is disabled or in
6
5
  * readonly mode.
7
6
  *
@@ -25,8 +24,6 @@
25
24
  * @type action
26
25
  *
27
26
  */
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- function clearValue() {
27
+ export default function clearValue() {
30
28
  return this.elementClear(this.elementId);
31
29
  }
32
- exports.default = clearValue;
@@ -1,4 +1,4 @@
1
- import { ClickOptions } from '../../types';
1
+ import type { ClickOptions } from '../../types';
2
2
  /**
3
3
  *
4
4
  * Click on an element.
@@ -1 +1 @@
1
- {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../src/commands/element/click.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,wBAA8B,KAAK,CAC/B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,CAAC,EAAE,YAAY,iBAoEzB"}
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../src/commands/element/click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,wBAA8B,KAAK,CAC/B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,CAAC,EAAE,YAAY,iBAyDzB"}
@@ -1,10 +1,4 @@
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/click');
1
+ import { getBrowserObject } from '../../utils/index.js';
8
2
  /**
9
3
  *
10
4
  * Click on an element.
@@ -84,58 +78,49 @@ const log = (0, logger_1.default)('webdriverio/click');
84
78
  * @param {number=} options.y Number (optional)
85
79
  * @param {number=} options.skipRelease Boolean (optional)
86
80
  */
87
- async function click(options) {
81
+ export default async function click(options) {
88
82
  if (typeof options === 'undefined') {
89
83
  return this.elementClick(this.elementId);
90
84
  }
91
85
  if (typeof options !== 'object' || Array.isArray(options)) {
92
86
  throw new TypeError('Options must be an object');
93
87
  }
94
- let { button = 0, x: xoffset = 0, y: yoffset = 0, skipRelease = false } = options || {};
88
+ let button = (options.button || 0);
89
+ let { x: xoffset = 0, y: yoffset = 0, skipRelease = false } = options || {};
95
90
  if (typeof xoffset !== 'number'
96
91
  || typeof yoffset !== 'number'
97
92
  || !Number.isInteger(xoffset)
98
93
  || !Number.isInteger(yoffset)) {
99
94
  throw new TypeError('Coordinates must be integers');
100
95
  }
101
- if (button === 'left') {
96
+ if (options.button === 'left') {
102
97
  button = 0;
103
98
  }
104
- if (button === 'middle') {
99
+ if (options.button === 'middle') {
105
100
  button = 1;
106
101
  }
107
- if (button === 'right') {
102
+ if (options.button === 'right') {
108
103
  button = 2;
109
104
  }
110
105
  if (![0, 1, 2].includes(button)) {
111
106
  throw new Error('Button type not supported.');
112
107
  }
113
108
  if (this.isW3C) {
114
- await this.performActions([{
115
- type: 'pointer',
116
- id: 'pointer1',
117
- parameters: {
118
- pointerType: 'mouse'
119
- },
120
- actions: [{
121
- type: 'pointerMove',
122
- origin: this,
123
- x: xoffset,
124
- y: yoffset
125
- }, {
126
- type: 'pointerDown',
127
- button
128
- }, {
129
- type: 'pointerUp',
130
- button
131
- }]
132
- }]);
133
- if (!skipRelease)
134
- await this.releaseActions().then(() => null, (err) => log.warn(`Failed to call "releaseAction" command due to: ${err.message}, ignoring!`));
109
+ const browser = getBrowserObject(this);
110
+ await browser.action('pointer', {
111
+ parameters: { pointerType: 'mouse' }
112
+ })
113
+ .move({
114
+ origin: this,
115
+ x: xoffset,
116
+ y: yoffset
117
+ })
118
+ .down({ button })
119
+ .up({ button })
120
+ .perform(skipRelease);
135
121
  return;
136
122
  }
137
123
  const { width, height } = await this.getElementSize(this.elementId);
138
124
  await this.moveToElement(this.elementId, xoffset + (width / 2), yoffset + (height / 2));
139
125
  return this.positionClick(button);
140
126
  }
141
- exports.default = click;
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getElementObject_1 = require("../../utils/getElementObject");
4
- const utils_1 = require("../../utils");
5
- const constants_1 = require("../../constants");
1
+ import { getElements } from '../../utils/getElementObject.js';
2
+ import { getBrowserObject, enhanceElementsArray } from '../../utils/index.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`
@@ -28,7 +26,7 @@ const constants_1 = require("../../constants");
28
26
  * @return {ElementArray}
29
27
  */
30
28
  async function custom$$(strategyName, ...strategyArguments) {
31
- const browserObject = (0, utils_1.getBrowserObject)(this);
29
+ const browserObject = getBrowserObject(this);
32
30
  const strategy = browserObject.strategies.get(strategyName);
33
31
  if (!strategy) {
34
32
  /* istanbul ignore next */
@@ -42,7 +40,7 @@ async function custom$$(strategyName, ...strategyArguments) {
42
40
  throw Error(`Can't call custom$ on element with selector "${this.selector}" because element wasn't found`);
43
41
  }
44
42
  const strategyRef = { strategy, strategyName, strategyArguments: [...strategyArguments, this] };
45
- let res = await this.execute(strategy, ...strategyArguments, this);
43
+ let res = await browserObject.execute(strategy, ...strategyArguments, this);
46
44
  /**
47
45
  * if the user's script return just one element
48
46
  * then we convert it to an array as this method
@@ -51,8 +49,8 @@ async function custom$$(strategyName, ...strategyArguments) {
51
49
  if (!Array.isArray(res)) {
52
50
  res = [res];
53
51
  }
54
- res = res.filter((el) => !!el && typeof el[constants_1.ELEMENT_KEY] === 'string');
55
- const elements = res.length ? await getElementObject_1.getElements.call(this, strategyRef, res) : [];
56
- return (0, utils_1.enhanceElementsArray)(elements, this, strategyName, 'custom$$', strategyArguments);
52
+ res = res.filter((el) => !!el && typeof el[ELEMENT_KEY] === 'string');
53
+ const elements = res.length ? await getElements.call(this, strategyRef, res) : [];
54
+ return enhanceElementsArray(elements, this, strategyName, 'custom$$', strategyArguments);
57
55
  }
58
- exports.default = custom$$;
56
+ export default custom$$;
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getElementObject_1 = require("../../utils/getElementObject");
4
- const utils_1 = require("../../utils");
5
- const constants_1 = require("../../constants");
1
+ import { getElement } from '../../utils/getElementObject.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
3
+ import { ELEMENT_KEY } from '../../constants.js';
6
4
  /**
7
5
  *
8
6
  * The `custom$` allows you to use a custom strategy declared by using `browser.addLocatorStrategy`
@@ -28,7 +26,7 @@ const constants_1 = require("../../constants");
28
26
  * @return {Element}
29
27
  */
30
28
  async function custom$(strategyName, ...strategyArguments) {
31
- const browserObject = (0, utils_1.getBrowserObject)(this);
29
+ const browserObject = getBrowserObject(this);
32
30
  const strategy = browserObject.strategies.get(strategyName);
33
31
  if (!strategy) {
34
32
  throw Error('No strategy found for ' + strategyName);
@@ -41,7 +39,7 @@ async function custom$(strategyName, ...strategyArguments) {
41
39
  throw Error(`Can't call custom$ on element with selector "${this.selector}" because element wasn't found`);
42
40
  }
43
41
  const strategyRef = { strategy, strategyName, strategyArguments: [...strategyArguments, this] };
44
- let res = await this.execute(strategy, ...strategyArguments, this);
42
+ let res = await browserObject.execute(strategy, ...strategyArguments, this);
45
43
  /**
46
44
  * if the user's script returns multiple elements
47
45
  * then we just return the first one as this method
@@ -50,9 +48,9 @@ async function custom$(strategyName, ...strategyArguments) {
50
48
  if (Array.isArray(res)) {
51
49
  res = res[0];
52
50
  }
53
- if (res && typeof res[constants_1.ELEMENT_KEY] === 'string') {
54
- return await getElementObject_1.getElement.call(this, strategyRef, res);
51
+ if (res && typeof res[ELEMENT_KEY] === 'string') {
52
+ return await getElement.call(this, strategyRef, res);
55
53
  }
56
54
  throw Error('Your locator strategy script must return an element');
57
55
  }
58
- exports.default = custom$;
56
+ export default custom$;
@@ -1 +1 @@
1
- {"version":3,"file":"doubleClick.d.ts","sourceRoot":"","sources":["../../../src/commands/element/doubleClick.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAA8B,WAAW,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,iBAyBnE"}
1
+ {"version":3,"file":"doubleClick.d.ts","sourceRoot":"","sources":["../../../src/commands/element/doubleClick.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAA8B,WAAW,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,iBAqBnE"}
@@ -1,5 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ import { getBrowserObject } from '../../utils/index.js';
3
2
  /**
4
3
  *
5
4
  * Double-click on an element.
@@ -23,7 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
22
  * @type action
24
23
  *
25
24
  */
26
- async function doubleClick() {
25
+ export default async function doubleClick() {
27
26
  /**
28
27
  * move to element
29
28
  */
@@ -34,18 +33,13 @@ async function doubleClick() {
34
33
  /**
35
34
  * W3C way of handle the double click actions
36
35
  */
37
- return this.performActions([{
38
- type: 'pointer',
39
- id: 'pointer1',
40
- parameters: { pointerType: 'mouse' },
41
- actions: [
42
- { type: 'pointerMove', origin: this, x: 0, y: 0 },
43
- { type: 'pointerDown', button: 0 },
44
- { type: 'pointerUp', button: 0 },
45
- { type: 'pause', duration: 10 },
46
- { type: 'pointerDown', button: 0 },
47
- { type: 'pointerUp', button: 0 }
48
- ]
49
- }]);
36
+ const browser = getBrowserObject(this);
37
+ return browser.action('pointer', { parameters: { pointerType: 'mouse' } })
38
+ .move({ origin: this })
39
+ .down()
40
+ .up()
41
+ .pause(10)
42
+ .down()
43
+ .up()
44
+ .perform();
50
45
  }
51
- exports.default = doubleClick;
@@ -1 +1 @@
1
- {"version":3,"file":"dragAndDrop.d.ts","sourceRoot":"","sources":["../../../src/commands/element/dragAndDrop.ts"],"names":[],"mappings":"AAOA,aAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,aAAK,kBAAkB,GAAG;IACtB,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAA8B,WAAW,CACrC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,MAAM,EAAE,WAAW,CAAC,OAAO,GAAG,kBAAkB,EAChD,EAAE,QAAa,EAAE,GAAE,kBAAuB,iBAyE7C"}
1
+ {"version":3,"file":"dragAndDrop.d.ts","sourceRoot":"","sources":["../../../src/commands/element/dragAndDrop.ts"],"names":[],"mappings":"AAQA,aAAK,kBAAkB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,aAAK,kBAAkB,GAAG;IACtB,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAA8B,WAAW,CACrC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,MAAM,EAAE,WAAW,CAAC,OAAO,GAAG,kBAAkB,EAChD,EAAE,QAAa,EAAE,GAAE,kBAAuB,iBAqE7C"}
@@ -1,6 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../constants");
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
4
3
  const ACTION_BUTTON = 0;
5
4
  const sleep = (time = 0) => new Promise((resolve) => setTimeout(resolve, time));
6
5
  /**
@@ -34,7 +33,7 @@ const sleep = (time = 0) => new Promise((resolve) => setTimeout(resolve, time));
34
33
  * @param {DragAndDropOptions=} options dragAndDrop command options
35
34
  * @param {Number=} options.duration how long the drag should take place
36
35
  */
37
- async function dragAndDrop(target, { duration = 10 } = {}) {
36
+ export default async function dragAndDrop(target, { duration = 10 } = {}) {
38
37
  const moveToCoordinates = target;
39
38
  const moveToElement = target;
40
39
  /**
@@ -73,8 +72,8 @@ async function dragAndDrop(target, { duration = 10 } = {}) {
73
72
  await sleep(duration);
74
73
  return this.buttonUp(ACTION_BUTTON);
75
74
  }
76
- const sourceRef = { [constants_1.ELEMENT_KEY]: this[constants_1.ELEMENT_KEY] };
77
- const targetRef = { [constants_1.ELEMENT_KEY]: moveToElement[constants_1.ELEMENT_KEY] };
75
+ const sourceRef = { [ELEMENT_KEY]: this[ELEMENT_KEY] };
76
+ const targetRef = { [ELEMENT_KEY]: moveToElement[ELEMENT_KEY] };
78
77
  const origin = sourceRef;
79
78
  const targetOrigin = isMovingToElement ? targetRef : 'pointer';
80
79
  const targetX = isMovingToElement ? 0 : moveToCoordinates.x;
@@ -82,17 +81,12 @@ async function dragAndDrop(target, { duration = 10 } = {}) {
82
81
  /**
83
82
  * W3C way of handle the drag and drop action
84
83
  */
85
- return this.performActions([{
86
- type: 'pointer',
87
- id: 'finger1',
88
- parameters: { pointerType: 'mouse' },
89
- actions: [
90
- { type: 'pointerMove', duration: 0, origin, x: 0, y: 0 },
91
- { type: 'pointerDown', button: ACTION_BUTTON },
92
- { type: 'pause', duration: 10 },
93
- { type: 'pointerMove', duration, origin: targetOrigin, x: targetX, y: targetY },
94
- { type: 'pointerUp', button: ACTION_BUTTON }
95
- ]
96
- }]).then(() => this.releaseActions());
84
+ const browser = getBrowserObject(this);
85
+ return browser.action('pointer')
86
+ .move({ duration: 0, origin, x: 0, y: 0 })
87
+ .down({ button: ACTION_BUTTON })
88
+ .pause(10)
89
+ .move({ duration, origin: targetOrigin, x: targetX, y: targetY })
90
+ .up({ button: ACTION_BUTTON })
91
+ .perform();
97
92
  }
98
- exports.default = dragAndDrop;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Get an attribute from a DOM-element based on the attribute name.
@@ -26,7 +24,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
24
  * @type property
27
25
  *
28
26
  */
29
- function getAttribute(attributeName) {
27
+ export default function getAttribute(attributeName) {
30
28
  return this.getElementAttribute(this.elementId, attributeName);
31
29
  }
32
- exports.default = getAttribute;
@@ -67,5 +67,5 @@
67
67
  * @return {CSSProperty} The specified css of the element
68
68
  *
69
69
  */
70
- export default function getCSSProperty(this: WebdriverIO.Element, cssProperty: string): Promise<import("../..").ParsedCSSValue>;
70
+ export default function getCSSProperty(this: WebdriverIO.Element, cssProperty: string): Promise<import("../../types.js").ParsedCSSValue>;
71
71
  //# sourceMappingURL=getCSSProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCSSProperty.d.ts","sourceRoot":"","sources":["../../../src/commands/element/getCSSProperty.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAA8B,cAAc,CACxC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,WAAW,EAAE,MAAM,2CAsCtB"}
1
+ {"version":3,"file":"getCSSProperty.d.ts","sourceRoot":"","sources":["../../../src/commands/element/getCSSProperty.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,wBAA8B,cAAc,CACxC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,WAAW,EAAE,MAAM,oDAsCtB"}
@@ -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 css_shorthand_properties_1 = __importDefault(require("css-shorthand-properties"));
7
- const utils_1 = require("../../utils");
1
+ import cssShorthandProps from 'css-shorthand-properties';
2
+ import { parseCSS } from '../../utils/index.js';
8
3
  /**
9
4
  *
10
5
  * Get a css property from a DOM-element selected by given selector. The return value
@@ -74,18 +69,18 @@ const utils_1 = require("../../utils");
74
69
  * @return {CSSProperty} The specified css of the element
75
70
  *
76
71
  */
77
- async function getCSSProperty(cssProperty) {
72
+ export default async function getCSSProperty(cssProperty) {
78
73
  /**
79
74
  * Getting the css value of a shorthand property results in different results
80
75
  * given that the behavior of `getComputedStyle` is not defined in this case.
81
76
  * Therefore if we don't deal with a shorthand property run `getElementCSSValue`
82
77
  * otherwise expand it and run the command for each longhand property.
83
78
  */
84
- if (!css_shorthand_properties_1.default.isShorthand(cssProperty)) {
79
+ if (!cssShorthandProps.isShorthand(cssProperty)) {
85
80
  const cssValue = await this.getElementCSSValue(this.elementId, cssProperty);
86
- return (0, utils_1.parseCSS)(cssValue, cssProperty);
81
+ return parseCSS(cssValue, cssProperty);
87
82
  }
88
- const properties = css_shorthand_properties_1.default.expand(cssProperty);
83
+ const properties = cssShorthandProps.expand(cssProperty);
89
84
  let cssValues = await Promise.all(properties.map((prop) => this.getElementCSSValue(this.elementId, prop)));
90
85
  /**
91
86
  * merge equal symmetrical values
@@ -103,6 +98,5 @@ async function getCSSProperty(cssProperty) {
103
98
  }
104
99
  cssValues = cssValues.slice(0, cssValues.length / 2);
105
100
  }
106
- return (0, utils_1.parseCSS)(cssValues.join(' '), cssProperty);
101
+ return parseCSS(cssValues.join(' '), cssProperty);
107
102
  }
108
- exports.default = getCSSProperty;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Get the computed WAI-ARIA label of an element.
@@ -18,7 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
16
  * @type property
19
17
  *
20
18
  */
21
- function getComputedLabel() {
19
+ export default function getComputedLabel() {
22
20
  return this.getElementComputedLabel(this.elementId);
23
21
  }
24
- exports.default = getComputedLabel;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Get the computed WAI-ARIA label of an element.
@@ -18,7 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
16
  * @type property
19
17
  *
20
18
  */
21
- function getComputedRole() {
19
+ export default function getComputedRole() {
22
20
  return this.getElementComputedRole(this.elementId);
23
21
  }
24
- exports.default = getComputedRole;
@@ -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 constants_1 = require("../../constants");
7
- const utils_1 = require("../../utils");
8
- const getHTML_1 = __importDefault(require("../../scripts/getHTML"));
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
3
+ import getHTMLScript from '../../scripts/getHTML.js';
9
4
  /**
10
5
  *
11
6
  * Get source code of specified DOM element by selector.
@@ -36,11 +31,10 @@ const getHTML_1 = __importDefault(require("../../scripts/getHTML"));
36
31
  * @type property
37
32
  *
38
33
  */
39
- function getHTML(includeSelectorTag = true) {
40
- const browser = (0, utils_1.getBrowserObject)(this);
41
- return browser.execute(getHTML_1.default, {
42
- [constants_1.ELEMENT_KEY]: this.elementId,
34
+ export default function getHTML(includeSelectorTag = true) {
35
+ const browser = getBrowserObject(this);
36
+ return browser.execute(getHTMLScript, {
37
+ [ELEMENT_KEY]: this.elementId,
43
38
  ELEMENT: this.elementId // jsonwp compatible
44
39
  }, includeSelectorTag);
45
40
  }
46
- exports.default = getHTML;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { getElementRect } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Determine an element’s location on the page. The point (0, 0) refers to
@@ -31,7 +29,7 @@ const utils_1 = require("../../utils");
31
29
  async function getLocation(prop) {
32
30
  let location = {};
33
31
  if (this.isW3C) {
34
- location = await (0, utils_1.getElementRect)(this);
32
+ location = await getElementRect(this);
35
33
  delete location.width;
36
34
  delete location.height;
37
35
  }
@@ -43,4 +41,4 @@ async function getLocation(prop) {
43
41
  }
44
42
  return location;
45
43
  }
46
- exports.default = getLocation;
44
+ export default getLocation;