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
@@ -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 isElementClickable_1 = __importDefault(require("../../scripts/isElementClickable"));
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
3
+ import isElementClickableScript from '../../scripts/isElementClickable.js';
9
4
  /**
10
5
  *
11
6
  * Return true if the selected DOM-element:
@@ -44,14 +39,16 @@ const isElementClickable_1 = __importDefault(require("../../scripts/isElementCli
44
39
  * @type state
45
40
  *
46
41
  */
47
- async function isClickable() {
42
+ export default async function isClickable() {
48
43
  if (!await this.isDisplayed()) {
49
44
  return false;
50
45
  }
51
- const browser = (0, utils_1.getBrowserObject)(this);
52
- return browser.execute(isElementClickable_1.default, {
53
- [constants_1.ELEMENT_KEY]: this.elementId,
46
+ if (this.isMobile && await this.getContext() === 'NATIVE_APP') {
47
+ throw new Error('Method not supported in mobile native environment. It is unlikely that you need to use this command.');
48
+ }
49
+ const browser = getBrowserObject(this);
50
+ return browser.execute(isElementClickableScript, {
51
+ [ELEMENT_KEY]: this.elementId,
54
52
  ELEMENT: this.elementId // jsonwp compatible
55
53
  });
56
54
  }
57
- exports.default = isClickable;
@@ -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 isElementDisplayed_1 = __importDefault(require("../../scripts/isElementDisplayed"));
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject, hasElementId } from '../../utils/index.js';
3
+ import isElementDisplayedScript from '../../scripts/isElementDisplayed.js';
9
4
  const noW3CEndpoint = ['microsoftedge', 'msedge', 'safari', 'chrome', 'safari technology preview'];
10
5
  /**
11
6
  *
@@ -55,10 +50,9 @@ const noW3CEndpoint = ['microsoftedge', 'msedge', 'safari', 'chrome', 'safari te
55
50
  * @type state
56
51
  *
57
52
  */
58
- async function isDisplayed() {
59
- var _a;
60
- const browser = (0, utils_1.getBrowserObject)(this);
61
- if (!await (0, utils_1.hasElementId)(this)) {
53
+ export default async function isDisplayed() {
54
+ const browser = getBrowserObject(this);
55
+ if (!await hasElementId(this)) {
62
56
  return false;
63
57
  }
64
58
  /*
@@ -74,12 +68,11 @@ async function isDisplayed() {
74
68
  const useAtom = (await browser.isDevTools ||
75
69
  (await browser.isW3C &&
76
70
  !browser.isMobile &&
77
- noW3CEndpoint.includes((_a = browser.capabilities.browserName) === null || _a === void 0 ? void 0 : _a.toLowerCase())));
71
+ noW3CEndpoint.includes(browser.capabilities.browserName?.toLowerCase())));
78
72
  return useAtom
79
- ? await browser.execute(isElementDisplayed_1.default, {
80
- [constants_1.ELEMENT_KEY]: this.elementId,
73
+ ? await browser.execute(isElementDisplayedScript, {
74
+ [ELEMENT_KEY]: this.elementId,
81
75
  ELEMENT: this.elementId // jsonwp compatible
82
76
  }) :
83
77
  await this.isElementDisplayed(this.elementId);
84
78
  }
85
- exports.default = isDisplayed;
@@ -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 isElementInViewport_1 = __importDefault(require("../../scripts/isElementInViewport"));
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
3
+ import isElementInViewportScript from '../../scripts/isElementInViewport.js';
9
4
  /**
10
5
  *
11
6
  * Return true if the selected DOM-element found by given selector is partially visible and within the viewport.
@@ -42,14 +37,13 @@ const isElementInViewport_1 = __importDefault(require("../../scripts/isElementIn
42
37
  * @type state
43
38
  *
44
39
  */
45
- async function isDisplayedInViewport() {
40
+ export default async function isDisplayedInViewport() {
46
41
  if (!await this.isDisplayed()) {
47
42
  return false;
48
43
  }
49
- const browser = (0, utils_1.getBrowserObject)(this);
50
- return browser.execute(isElementInViewport_1.default, {
51
- [constants_1.ELEMENT_KEY]: this.elementId,
44
+ const browser = getBrowserObject(this);
45
+ return browser.execute(isElementInViewportScript, {
46
+ [ELEMENT_KEY]: this.elementId,
52
47
  ELEMENT: this.elementId // jsonwp compatible
53
48
  });
54
49
  }
55
- exports.default = isDisplayedInViewport;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Return true or false if the selected DOM-element is enabled.
@@ -32,7 +30,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
32
30
  * @type state
33
31
  *
34
32
  */
35
- function isEnabled() {
33
+ export default function isEnabled() {
36
34
  return this.isElementEnabled(this.elementId);
37
35
  }
38
- exports.default = isEnabled;
@@ -1 +1 @@
1
- {"version":3,"file":"isEqual.d.ts","sourceRoot":"","sources":["../../../src/commands/element/isEqual.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,EAAE,EAAE,WAAW,CAAC,OAAO,oBAwB1B"}
1
+ {"version":3,"file":"isEqual.d.ts","sourceRoot":"","sources":["../../../src/commands/element/isEqual.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,EAAE,EAAE,WAAW,CAAC,OAAO,oBA4B1B"}
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../constants");
4
- const utils_1 = require("../../utils");
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
5
3
  const getWebElement = (el) => ({
6
- [constants_1.ELEMENT_KEY]: el.elementId,
4
+ [ELEMENT_KEY]: el.elementId,
7
5
  ELEMENT: el.elementId // jsonwp compatible
8
6
  });
9
7
  /**
@@ -28,12 +26,15 @@ const getWebElement = (el) => ({
28
26
  * @return {Boolean} true if elements are equal
29
27
  *
30
28
  */
31
- async function isEqual(el) {
32
- const browser = (0, utils_1.getBrowserObject)(this);
29
+ export default async function isEqual(el) {
30
+ const browser = getBrowserObject(this);
33
31
  // mobile native
34
32
  if (browser.isMobile) {
35
33
  const context = await browser.getContext();
36
- if (context === null || context === void 0 ? void 0 : context.toLowerCase().includes('native')) {
34
+ const contextId = typeof context === 'string'
35
+ ? context
36
+ : context?.id;
37
+ if (contextId && contextId.toLowerCase().includes('native')) {
37
38
  return this.elementId === el.elementId;
38
39
  }
39
40
  }
@@ -49,4 +50,3 @@ async function isEqual(el) {
49
50
  }
50
51
  return result;
51
52
  }
52
- exports.default = isEqual;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Returns true if element exists in the DOM.
@@ -47,7 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
47
45
  * @type state
48
46
  *
49
47
  */
50
- async function isExisting() {
48
+ export default async function isExisting() {
51
49
  /**
52
50
  * if an element was composed via `const elem = $({ 'element-6066-11e4-a52e-4f735466cecf': <elementId> })`
53
51
  * we don't have any selector information. Therefore we can only check existance
@@ -62,4 +60,3 @@ async function isExisting() {
62
60
  const command = this.isReactElement ? this.parent.react$$.bind(this.parent) : this.parent.$$.bind(this.parent);
63
61
  return command(this.selector).then((res) => res.length > 0);
64
62
  }
65
- exports.default = isExisting;
@@ -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 isFocused_1 = __importDefault(require("../../scripts/isFocused"));
1
+ import { ELEMENT_KEY } from '../../constants.js';
2
+ import { getBrowserObject } from '../../utils/index.js';
3
+ import isFocusedScript from '../../scripts/isFocused.js';
9
4
  /**
10
5
  *
11
6
  * Return true or false if the selected DOM-element currently has focus. If the selector matches
@@ -32,11 +27,10 @@ const isFocused_1 = __importDefault(require("../../scripts/isFocused"));
32
27
  * @type state
33
28
  *
34
29
  */
35
- async function isFocused() {
36
- const browser = await (0, utils_1.getBrowserObject)(this);
37
- return browser.execute(isFocused_1.default, {
38
- [constants_1.ELEMENT_KEY]: this.elementId,
30
+ export default async function isFocused() {
31
+ const browser = await getBrowserObject(this);
32
+ return browser.execute(isFocusedScript, {
33
+ [ELEMENT_KEY]: this.elementId,
39
34
  ELEMENT: this.elementId // jsonwp compatible
40
35
  });
41
36
  }
42
- exports.default = isFocused;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Will return true or false whether or not an `<option>` or `<input>` element of type
@@ -29,7 +27,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
27
  * @type state
30
28
  *
31
29
  */
32
- function isSelected() {
30
+ export default function isSelected() {
33
31
  return this.isElementSelected(this.elementId);
34
32
  }
35
- exports.default = isSelected;
@@ -1 +1 @@
1
- {"version":3,"file":"moveTo.d.ts","sourceRoot":"","sources":["../../../src/commands/element/moveTo.ts"],"names":[],"mappings":"AAEA,aAAK,aAAa,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAE,aAAkB,iBAuB3C"}
1
+ {"version":3,"file":"moveTo.d.ts","sourceRoot":"","sources":["../../../src/commands/element/moveTo.ts"],"names":[],"mappings":"AAEA,aAAK,aAAa,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAE,aAAkB,iBAqB3C"}
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { getElementRect, getScrollPosition, getBrowserObject } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Move the mouse by an offset of the specified element. If no element is specified,
@@ -15,25 +13,22 @@ const utils_1 = require("../../utils");
15
13
  * @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidmoveto
16
14
  * @type protocol
17
15
  */
18
- async function moveTo({ xOffset, yOffset } = {}) {
16
+ export default async function moveTo({ xOffset, yOffset } = {}) {
19
17
  if (!this.isW3C) {
20
18
  return this.moveToElement(this.elementId, xOffset, yOffset);
21
19
  }
22
20
  /**
23
21
  * get rect of element
24
22
  */
25
- const { x, y, width, height } = await (0, utils_1.getElementRect)(this);
26
- const { scrollX, scrollY } = await (0, utils_1.getScrollPosition)(this);
23
+ const { x, y, width, height } = await getElementRect(this);
24
+ const { scrollX, scrollY } = await getScrollPosition(this);
27
25
  const newXOffset = Math.floor(x - scrollX + (typeof xOffset === 'number' ? xOffset : (width / 2)));
28
26
  const newYOffset = Math.floor(y - scrollY + (typeof yOffset === 'number' ? yOffset : (height / 2)));
29
27
  /**
30
28
  * W3C way of handle the mouse move actions
31
29
  */
32
- return this.performActions([{
33
- type: 'pointer',
34
- id: 'finger1',
35
- parameters: { pointerType: 'mouse' },
36
- actions: [{ type: 'pointerMove', duration: 0, x: newXOffset, y: newYOffset }]
37
- }]).then(() => this.releaseActions());
30
+ const browser = getBrowserObject(this);
31
+ return browser.action('pointer', { parameters: { pointerType: 'mouse' } })
32
+ .move({ x: newXOffset, y: newYOffset })
33
+ .perform();
38
34
  }
39
- exports.default = moveTo;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  *
4
3
  * Returns the next sibling element of the selected DOM-element.
@@ -22,10 +21,8 @@
22
21
  * @return {Element}
23
22
  * @type utility
24
23
  */
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- function nextElement() {
27
- return this.$(/* istanbul ignore next */ function () {
24
+ export default function nextElement() {
25
+ return this.$(/* istanbul ignore next */ function nextElement() {
28
26
  return this.nextElementSibling;
29
27
  });
30
28
  }
31
- exports.default = nextElement;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Returns the parent element of the selected DOM-element.
@@ -23,9 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
21
  * @return {Element}
24
22
  * @type utility
25
23
  */
26
- function parentElement() {
27
- return this.$(/* istanbul ignore next */ function () {
24
+ export default function parentElement() {
25
+ return this.$(/* istanbul ignore next */ function parentElement() {
28
26
  return this.parentElement;
29
27
  });
30
28
  }
31
- exports.default = parentElement;
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /**
4
2
  *
5
3
  * Returns the previous sibling element of the selected DOM-element.
@@ -23,9 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
21
  * @return {Element}
24
22
  * @type utility
25
23
  */
26
- function previousElement() {
27
- return this.$(/* istanbul ignore next */ function () {
24
+ export default function previousElement() {
25
+ return this.$(/* istanbul ignore next */ function previousElement() {
28
26
  return this.previousElementSibling;
29
27
  });
30
28
  }
31
- exports.default = previousElement;
@@ -1 +1 @@
1
- {"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$$.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,+CAUxD"}
1
+ {"version":3,"file":"react$$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$$.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAA8B,OAAO,CACjC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,+CAgBxD"}
@@ -1,13 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const utils_1 = require("../../utils");
8
- const getElementObject_1 = require("../../utils/getElementObject");
9
- const resq_1 = require("../../scripts/resq");
10
- const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
1
+ import fs from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { enhanceElementsArray, getBrowserObject } from '../../utils/index.js';
4
+ import { getElements } from '../../utils/getElementObject.js';
5
+ import { waitToLoadReact, react$$ as react$$Script } from '../../scripts/resq.js';
6
+ let resqScript;
11
7
  /**
12
8
  *
13
9
  * The `react$$` command is a useful command to query multiple React Components
@@ -41,11 +37,15 @@ const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
41
37
  * @return {ElementArray}
42
38
  *
43
39
  */
44
- async function react$$(selector, { props = {}, state = {} } = {}) {
40
+ export default async function react$$(selector, { props = {}, state = {} } = {}) {
41
+ if (!resqScript) {
42
+ const require = createRequire(import.meta.url);
43
+ resqScript = (await fs.readFile(require.resolve('resq'))).toString();
44
+ }
45
+ const browser = await getBrowserObject(this);
45
46
  await this.executeScript(resqScript.toString(), []);
46
- await this.execute(resq_1.waitToLoadReact);
47
- const res = await this.execute(resq_1.react$$, selector, props, state, this);
48
- const elements = await getElementObject_1.getElements.call(this, selector, res, true);
49
- return (0, utils_1.enhanceElementsArray)(elements, this, selector, 'react$$', [props, state]);
47
+ await browser.execute(waitToLoadReact);
48
+ const res = await browser.execute(react$$Script, selector, props, state, this);
49
+ const elements = await getElements.call(this, selector, res, true);
50
+ return enhanceElementsArray(elements, this, selector, 'react$$', [props, state]);
50
51
  }
51
- exports.default = react$$;
@@ -1 +1 @@
1
- {"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,gCASxD"}
1
+ {"version":3,"file":"react$.d.ts","sourceRoot":"","sources":["../../../src/commands/element/react$.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAA8B,MAAM,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,KAAU,EAAE,KAAU,EAAE,GAAE,oBAAyB,gCAexD"}
@@ -1,12 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const getElementObject_1 = require("../../utils/getElementObject");
8
- const resq_1 = require("../../scripts/resq");
9
- const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
1
+ import fs from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { getBrowserObject } from '../../utils/index.js';
4
+ import { getElement } from '../../utils/getElementObject.js';
5
+ import { waitToLoadReact, react$ as react$Script } from '../../scripts/resq.js';
6
+ let resqScript;
10
7
  /**
11
8
  *
12
9
  * The `react$` command is a useful command to query React Components by their
@@ -50,10 +47,14 @@ const resqScript = fs_1.default.readFileSync(require.resolve('resq'));
50
47
  * @return {Element}
51
48
  *
52
49
  */
53
- async function react$(selector, { props = {}, state = {} } = {}) {
50
+ export default async function react$(selector, { props = {}, state = {} } = {}) {
51
+ if (!resqScript) {
52
+ const require = createRequire(import.meta.url);
53
+ resqScript = (await fs.readFile(require.resolve('resq'))).toString();
54
+ }
55
+ const browser = await getBrowserObject(this);
54
56
  await this.executeScript(resqScript.toString(), []);
55
- await this.execute(resq_1.waitToLoadReact);
56
- const res = await this.execute(resq_1.react$, selector, props, state, this);
57
- return getElementObject_1.getElement.call(this, selector, res, true);
57
+ await browser.execute(waitToLoadReact);
58
+ const res = await browser.execute(react$Script, selector, props, state, this);
59
+ return getElement.call(this, selector, res, true);
58
60
  }
59
- exports.default = react$;
@@ -1,10 +1,5 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const utils_1 = require("../../utils");
1
+ import fs from 'node:fs';
2
+ import { getAbsoluteFilepath, assertDirectoryExists } from '../../utils/index.js';
8
3
  /**
9
4
  *
10
5
  * Save a screenshot of an element to a PNG file on your OS.
@@ -23,18 +18,17 @@ const utils_1 = require("../../utils");
23
18
  * @type utility
24
19
  *
25
20
  */
26
- async function saveScreenshot(filepath) {
21
+ export default async function saveScreenshot(filepath) {
27
22
  /**
28
23
  * type check
29
24
  */
30
25
  if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
31
26
  throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
32
27
  }
33
- const absoluteFilepath = (0, utils_1.getAbsoluteFilepath)(filepath);
34
- (0, utils_1.assertDirectoryExists)(absoluteFilepath);
28
+ const absoluteFilepath = getAbsoluteFilepath(filepath);
29
+ assertDirectoryExists(absoluteFilepath);
35
30
  const screenBuffer = await this.takeElementScreenshot(this.elementId);
36
31
  const screenshot = Buffer.from(screenBuffer, 'base64');
37
- fs_1.default.writeFileSync(absoluteFilepath, screenshot);
32
+ fs.writeFileSync(absoluteFilepath, screenshot);
38
33
  return screenshot;
39
34
  }
40
- exports.default = saveScreenshot;
@@ -8,14 +8,16 @@
8
8
  const elem = await $('#myElement');
9
9
  // scroll to specific element
10
10
  await elem.scrollIntoView();
11
+ // center element within the viewport
12
+ await elem.scrollIntoView({ block: 'center', inline: 'center' });
11
13
  });
12
14
  * </example>
13
15
  *
14
16
  * @alias element.scrollIntoView
15
- * @param {object|boolean=} scrollIntoViewOptions options for `Element.scrollIntoView()` (default: `true`)
17
+ * @param {object|boolean=} scrollIntoViewOptions options for `Element.scrollIntoView()` (default: `{ block: 'start', inline: 'nearest' }`)
16
18
  * @uses protocol/execute
17
19
  * @type utility
18
20
  *
19
21
  */
20
- export default function scrollIntoView(this: WebdriverIO.Element, scrollIntoViewOptions?: boolean | ScrollIntoViewOptions): Promise<void>;
22
+ export default function scrollIntoView(this: WebdriverIO.Element, options?: ScrollIntoViewOptions | boolean): Promise<void>;
21
23
  //# sourceMappingURL=scrollIntoView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrollIntoView.d.ts","sourceRoot":"","sources":["../../../src/commands/element/scrollIntoView.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAClC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,qBAAqB,GAAE,OAAO,GAAG,qBAA4B,iBAQhE"}
1
+ {"version":3,"file":"scrollIntoView.d.ts","sourceRoot":"","sources":["../../../src/commands/element/scrollIntoView.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAA8B,cAAc,CACxC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,GAAE,qBAAqB,GAAG,OAA+C,iBA8BnF"}
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../../constants");
1
+ import { getBrowserObject } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Scroll element into viewport ([MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)).
@@ -11,21 +9,44 @@ const constants_1 = require("../../constants");
11
9
  const elem = await $('#myElement');
12
10
  // scroll to specific element
13
11
  await elem.scrollIntoView();
12
+ // center element within the viewport
13
+ await elem.scrollIntoView({ block: 'center', inline: 'center' });
14
14
  });
15
15
  * </example>
16
16
  *
17
17
  * @alias element.scrollIntoView
18
- * @param {object|boolean=} scrollIntoViewOptions options for `Element.scrollIntoView()` (default: `true`)
18
+ * @param {object|boolean=} scrollIntoViewOptions options for `Element.scrollIntoView()` (default: `{ block: 'start', inline: 'nearest' }`)
19
19
  * @uses protocol/execute
20
20
  * @type utility
21
21
  *
22
22
  */
23
- function scrollIntoView(scrollIntoViewOptions = true) {
24
- return this.parent.execute(/* istanbul ignore next */ function (elem, options) {
25
- elem.scrollIntoView(options);
26
- }, {
27
- [constants_1.ELEMENT_KEY]: this.elementId,
28
- ELEMENT: this.elementId // jsonwp compatible
29
- }, scrollIntoViewOptions);
23
+ export default async function scrollIntoView(options = { block: 'start', inline: 'nearest' }) {
24
+ const browser = getBrowserObject(this);
25
+ let deltaX = 0;
26
+ let deltaY = 0;
27
+ /**
28
+ * by default the WebDriver action scrolls the element just into the
29
+ * viewport. In order to stay complaint with `Element.scrollIntoView()`
30
+ * we need to adjust the values a bit.
31
+ */
32
+ if (typeof options === 'boolean' || typeof options.block === 'string' || typeof options.inline === 'string') {
33
+ const htmlElem = await browser.$('html');
34
+ const viewport = await htmlElem.getSize();
35
+ const elemSize = await this.getSize();
36
+ if (options === true || options.block === 'start') {
37
+ deltaY += viewport.height - elemSize.height;
38
+ }
39
+ else if (options.block === 'center') {
40
+ deltaY += Math.round((viewport.height - elemSize.height) / 2);
41
+ }
42
+ if (options.inline === 'start') {
43
+ deltaX += viewport.height - elemSize.height;
44
+ }
45
+ else if (options.block === 'center') {
46
+ deltaX += Math.round((viewport.height - elemSize.height) / 2);
47
+ }
48
+ }
49
+ return browser.action('wheel')
50
+ .scroll({ origin: this, duration: 200, deltaY, deltaX })
51
+ .perform();
30
52
  }
31
- exports.default = scrollIntoView;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { getElementFromResponse } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Select option with a specific value.
@@ -36,7 +34,7 @@ const utils_1 = require("../../utils");
36
34
  * @type action
37
35
  *
38
36
  */
39
- async function selectByAttribute(attribute, value) {
37
+ export default async function selectByAttribute(attribute, value) {
40
38
  /**
41
39
  * convert value into string
42
40
  */
@@ -54,6 +52,5 @@ async function selectByAttribute(attribute, value) {
54
52
  /**
55
53
  * select option
56
54
  */
57
- return this.elementClick((0, utils_1.getElementFromResponse)(optionElement));
55
+ return this.elementClick(getElementFromResponse(optionElement));
58
56
  }
59
- exports.default = selectByAttribute;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { getElementFromResponse } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Select option with a specific index.
@@ -30,7 +28,7 @@ const utils_1 = require("../../utils");
30
28
  * @type action
31
29
  *
32
30
  */
33
- async function selectByIndex(index) {
31
+ export default async function selectByIndex(index) {
34
32
  /**
35
33
  * negative index check
36
34
  */
@@ -50,6 +48,5 @@ async function selectByIndex(index) {
50
48
  /**
51
49
  * select option
52
50
  */
53
- return this.elementClick((0, utils_1.getElementFromResponse)(optionElements[index]));
51
+ return this.elementClick(getElementFromResponse(optionElements[index]));
54
52
  }
55
- exports.default = selectByIndex;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../utils");
1
+ import { getElementFromResponse } from '../../utils/index.js';
4
2
  /**
5
3
  *
6
4
  * Select option with displayed text matching the argument.
@@ -30,7 +28,7 @@ const utils_1 = require("../../utils");
30
28
  * @type action
31
29
  *
32
30
  */
33
- async function selectByVisibleText(text) {
31
+ export default async function selectByVisibleText(text) {
34
32
  /**
35
33
  * convert value into string
36
34
  */
@@ -61,6 +59,5 @@ async function selectByVisibleText(text) {
61
59
  /**
62
60
  * select option
63
61
  */
64
- return this.elementClick((0, utils_1.getElementFromResponse)(optionElement));
62
+ return this.elementClick(getElementFromResponse(optionElement));
65
63
  }
66
- exports.default = selectByVisibleText;