@sap_oss/wdio-qmate-service 1.0.0 → 1.0.2

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 (144) hide show
  1. package/README.md +2 -1
  2. package/{test/core/package-lock.json → docs/bestPractices/spec.md} +0 -0
  3. package/docs/doc.md +176 -353
  4. package/docs/gettingStarted/setup.md +2 -2
  5. package/docs/index.md +1 -1
  6. package/docs/sections/bestPractices/authentication.md +151 -0
  7. package/docs/sections/bestPractices/dataHandling.md +61 -0
  8. package/docs/sections/bestPractices/selectors.md +44 -0
  9. package/docs/{contact.md → sections/contact.md} +0 -0
  10. package/docs/sections/features/advancedDataHandling.md +252 -0
  11. package/docs/sections/features/config.md +171 -0
  12. package/docs/sections/features/dataHandling.md +83 -0
  13. package/docs/{gettingStarted → sections/features}/selectors.md +0 -0
  14. package/docs/sections/features/spec.md +0 -0
  15. package/docs/sections/gettingStarted/config.md +18 -0
  16. package/docs/sections/gettingStarted/execution.md +7 -0
  17. package/docs/sections/gettingStarted/setup.md +9 -0
  18. package/docs/sections/gettingStarted/spec.md +31 -0
  19. package/docs/sections/gettingStarted/specs.md +19 -0
  20. package/docs/sections/support/bugReporting.md +19 -0
  21. package/docs/sections/support/knownIssuesAndLimitations.md +0 -0
  22. package/docs/sections/support/troubleshooting.md +16 -0
  23. package/docs/sources/images/fiori_form.PNG +0 -0
  24. package/docs/sources/images/sapCloud_form.PNG +0 -0
  25. package/lib/index.js +59 -82
  26. package/lib/index.js.map +1 -1
  27. package/lib/reuse/authenticator/authHandler.js +12 -23
  28. package/lib/reuse/authenticator/authHandler.js.map +1 -1
  29. package/lib/reuse/authenticator/basicUrlAuthenticator.js +21 -32
  30. package/lib/reuse/authenticator/basicUrlAuthenticator.js.map +1 -1
  31. package/lib/reuse/authenticator/customAuthenticator.js +42 -55
  32. package/lib/reuse/authenticator/customAuthenticator.js.map +1 -1
  33. package/lib/reuse/authenticator/formAuthenticator.js +37 -50
  34. package/lib/reuse/authenticator/formAuthenticator.js.map +1 -1
  35. package/lib/reuse/authenticator/plainAuthenticator.js +5 -16
  36. package/lib/reuse/authenticator/plainAuthenticator.js.map +1 -1
  37. package/lib/reuse/helper/jsDocGen.js +4 -12
  38. package/lib/reuse/helper/jsDocGen.js.map +1 -1
  39. package/lib/reuse/index.js +20 -5
  40. package/lib/reuse/index.js.map +1 -1
  41. package/lib/reuse/modules/common/navigation.js +10 -23
  42. package/lib/reuse/modules/common/navigation.js.map +1 -1
  43. package/lib/reuse/modules/common/userInteraction.js +40 -73
  44. package/lib/reuse/modules/common/userInteraction.js.map +1 -1
  45. package/lib/reuse/modules/nonUi5/assertion.js +31 -52
  46. package/lib/reuse/modules/nonUi5/assertion.js.map +1 -1
  47. package/lib/reuse/modules/nonUi5/element.js +266 -331
  48. package/lib/reuse/modules/nonUi5/element.js.map +1 -1
  49. package/lib/reuse/modules/nonUi5/navigation.js +10 -21
  50. package/lib/reuse/modules/nonUi5/navigation.js.map +1 -1
  51. package/lib/reuse/modules/nonUi5/userInteraction.js +176 -215
  52. package/lib/reuse/modules/nonUi5/userInteraction.js.map +1 -1
  53. package/lib/reuse/modules/service/odata.d.ts +106 -94
  54. package/lib/reuse/modules/service/odata.js +209 -204
  55. package/lib/reuse/modules/service/odata.js.map +1 -1
  56. package/lib/reuse/modules/service/rest.js +64 -81
  57. package/lib/reuse/modules/service/rest.js.map +1 -1
  58. package/lib/reuse/modules/ui5/assertion.js +217 -268
  59. package/lib/reuse/modules/ui5/assertion.js.map +1 -1
  60. package/lib/reuse/modules/ui5/confirmationDialog.js +17 -42
  61. package/lib/reuse/modules/ui5/confirmationDialog.js.map +1 -1
  62. package/lib/reuse/modules/ui5/control.js +12 -33
  63. package/lib/reuse/modules/ui5/control.js.map +1 -1
  64. package/lib/reuse/modules/ui5/date.js +70 -89
  65. package/lib/reuse/modules/ui5/date.js.map +1 -1
  66. package/lib/reuse/modules/ui5/element.js +121 -156
  67. package/lib/reuse/modules/ui5/element.js.map +1 -1
  68. package/lib/reuse/modules/ui5/errorDialog.js +4 -17
  69. package/lib/reuse/modules/ui5/errorDialog.js.map +1 -1
  70. package/lib/reuse/modules/ui5/footerBar.js +28 -63
  71. package/lib/reuse/modules/ui5/footerBar.js.map +1 -1
  72. package/lib/reuse/modules/ui5/mockserver.js +390 -427
  73. package/lib/reuse/modules/ui5/mockserver.js.map +1 -1
  74. package/lib/reuse/modules/ui5/navigation.js +105 -132
  75. package/lib/reuse/modules/ui5/navigation.js.map +1 -1
  76. package/lib/reuse/modules/ui5/navigationBar.js +58 -77
  77. package/lib/reuse/modules/ui5/navigationBar.js.map +1 -1
  78. package/lib/reuse/modules/ui5/qunit.js +16 -27
  79. package/lib/reuse/modules/ui5/qunit.js.map +1 -1
  80. package/lib/reuse/modules/ui5/session.js +200 -236
  81. package/lib/reuse/modules/ui5/session.js.map +1 -1
  82. package/lib/reuse/modules/ui5/table.js +79 -98
  83. package/lib/reuse/modules/ui5/table.js.map +1 -1
  84. package/lib/reuse/modules/ui5/userInteraction.js +264 -335
  85. package/lib/reuse/modules/ui5/userInteraction.js.map +1 -1
  86. package/lib/reuse/modules/util/browser.js +131 -178
  87. package/lib/reuse/modules/util/browser.js.map +1 -1
  88. package/lib/reuse/modules/util/data.js +3 -2
  89. package/lib/reuse/modules/util/data.js.map +1 -1
  90. package/lib/reuse/modules/util/file.js +71 -90
  91. package/lib/reuse/modules/util/file.js.map +1 -1
  92. package/lib/reuse/modules/util/function.js +68 -87
  93. package/lib/reuse/modules/util/function.js.map +1 -1
  94. package/lib/reuse/modules/util/system.js +22 -33
  95. package/lib/reuse/modules/util/system.js.map +1 -1
  96. package/lib/scripts/dataExchange/dataExchange.js +145 -160
  97. package/lib/scripts/dataExchange/dataExchange.js.map +1 -1
  98. package/lib/scripts/dataExchange/dataExchangeUtil.js +93 -114
  99. package/lib/scripts/dataExchange/dataExchangeUtil.js.map +1 -1
  100. package/lib/scripts/hooks/after.js +3 -14
  101. package/lib/scripts/hooks/after.js.map +1 -1
  102. package/lib/scripts/hooks/before.js +9 -20
  103. package/lib/scripts/hooks/before.js.map +1 -1
  104. package/lib/scripts/hooks/beforeSession.js +7 -18
  105. package/lib/scripts/hooks/beforeSession.js.map +1 -1
  106. package/lib/scripts/hooks/onComplete.js +2 -13
  107. package/lib/scripts/hooks/onComplete.js.map +1 -1
  108. package/lib/scripts/hooks/onPrepare.js +9 -20
  109. package/lib/scripts/hooks/onPrepare.js.map +1 -1
  110. package/lib/scripts/hooks/utils/addLocatorCommands.js +109 -172
  111. package/lib/scripts/hooks/utils/addLocatorCommands.js.map +1 -1
  112. package/lib/scripts/hooks/utils/browserLog.js +18 -31
  113. package/lib/scripts/hooks/utils/browserLog.js.map +1 -1
  114. package/lib/scripts/hooks/utils/dataExchangeCommands.js +13 -24
  115. package/lib/scripts/hooks/utils/dataExchangeCommands.js.map +1 -1
  116. package/lib/scripts/hooks/utils/decryption.d.ts +1 -1
  117. package/lib/scripts/hooks/utils/decryption.js +33 -14
  118. package/lib/scripts/hooks/utils/decryption.js.map +1 -1
  119. package/lib/scripts/hooks/utils/lib.js +249 -272
  120. package/lib/scripts/hooks/utils/lib.js.map +1 -1
  121. package/lib/scripts/hooks/utils/locatorCommands.js +154 -183
  122. package/lib/scripts/hooks/utils/locatorCommands.js.map +1 -1
  123. package/mkdocs.yml +16 -3
  124. package/package.json +14 -11
  125. package/test/authenticator/staticLogin/specs/custom.spec.js +30 -1
  126. package/test/reuse/nonUi5/element/getById.spec.js +17 -0
  127. package/test/reuse/service/odata/get.spec.js +61 -0
  128. package/test/reuse/service/odata/getEntitySet.spec.js +87 -0
  129. package/test/reuse/service/odata/test.odata.conf.js +15 -0
  130. package/test/reuse/ui5/confirmationDialog/clickButton.spec.js +87 -0
  131. package/test/reuse/ui5/confirmationDialog/test.confirmationDialog.conf.js +2 -1
  132. package/test/reuse/ui5/element/test.element.conf.js +2 -1
  133. package/test/reuse/ui5/element/waitForAll.spec.js +46 -0
  134. package/test/reuse/ui5/userInteraction/clearAndFillSmartFieldInputAndRetry.spec.js +28 -0
  135. package/test/reuse/ui5/userInteraction/test.userInteraction.conf.js +1 -0
  136. package/test/reuse/util/browser/switchToNewWindow.spec.js +2 -2
  137. package/test/reuse/util/console/console.spec.js +27 -0
  138. package/test/reuse/util/console/test.console.conf.js +12 -0
  139. package/test/reuse/util/data/data/test.secure.json +7 -3
  140. package/test/reuse/util/data/getSecureData.spec.js +9 -3
  141. package/test/reuse/util/file/pdfParser.spec.js +33 -8
  142. package/test/reuse/util/system/system.spec.js +16 -0
  143. package/test/reuse/util/system/test.system.conf.js +12 -0
  144. package/tsconfig.json +1 -1
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.UserInteraction = void 0;
13
4
  /**
@@ -25,33 +16,29 @@ class UserInteraction {
25
16
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
26
17
  * @example await ui5.userInteraction.click(selector);
27
18
  */
28
- click(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- let elem = null;
31
- yield browser.waitUntil(function () {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- elem = yield ui5.element.getDisplayed(selector, index, timeout);
34
- if (!elem)
35
- return false;
36
- return elem.isClickable();
37
- });
38
- }, {
39
- timeout,
40
- timeoutMsg: `Element not clickable after ${+timeout / 1000}s`
41
- });
42
- try {
43
- // @ts-ignore
44
- yield elem.click();
45
- }
46
- catch (error) {
19
+ async click(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
20
+ let elem = null;
21
+ await browser.waitUntil(async function () {
22
+ elem = await ui5.element.getDisplayed(selector, index, timeout);
23
+ if (!elem)
24
+ return false;
25
+ return elem.isClickable();
26
+ }, {
27
+ timeout,
28
+ timeoutMsg: `Element not clickable after ${+timeout / 1000}s`
29
+ });
30
+ try {
31
+ // @ts-ignore
32
+ await elem.click();
33
+ }
34
+ catch (error) {
35
+ // @ts-ignore
36
+ if (error.message && error.message.match(new RegExp(/is not clickable at point/))) {
47
37
  // @ts-ignore
48
- if (error.message && error.message.match(new RegExp(/is not clickable at point/))) {
49
- // @ts-ignore
50
- const errorMessage = yield util.function.mapWdioErrorToQmateErrorMessage(error, "click");
51
- throw new Error(errorMessage);
52
- }
38
+ const errorMessage = await util.function.mapWdioErrorToQmateErrorMessage(error, "click");
39
+ throw new Error(errorMessage);
53
40
  }
54
- });
41
+ }
55
42
  }
56
43
  ;
57
44
  /**
@@ -65,10 +52,8 @@ class UserInteraction {
65
52
  * @param {Number} [interval=5000] - The delay between the retries (ms). Can be set in config for all functions under params.stepRetriesIntervals.
66
53
  * @example await ui5.userInteraction.clickAndRetry(selector);
67
54
  */
68
- clickAndRetry(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- yield util.function.retry(this.click, [selector, index, timeout], retries, interval, this);
71
- });
55
+ async clickAndRetry(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
56
+ await util.function.retry(this.click, [selector, index, timeout], retries, interval, this);
72
57
  }
73
58
  ;
74
59
  /**
@@ -81,19 +66,15 @@ class UserInteraction {
81
66
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
82
67
  * @example await ui5.userInteraction.clickTab(selector);
83
68
  */
84
- clickTab(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- yield util.function.retry(function (selector, index, timeout) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- yield ui5.userInteraction.click(selector);
89
- const tab = yield ui5.element.getDisplayed(selector, index, timeout);
90
- const classList = yield tab.getAttribute("class");
91
- if (!classList.includes("sapUxAPAnchorBarButtonSelected")) {
92
- throw new Error();
93
- }
94
- });
95
- }, [selector, index, timeout], 3, 5000, this);
96
- });
69
+ async clickTab(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
70
+ await util.function.retry(async function (selector, index, timeout) {
71
+ await ui5.userInteraction.click(selector);
72
+ const tab = await ui5.element.getDisplayed(selector, index, timeout);
73
+ const classList = await tab.getAttribute("class");
74
+ if (!classList.includes("sapUxAPAnchorBarButtonSelected")) {
75
+ throw new Error();
76
+ }
77
+ }, [selector, index, timeout], 3, 5000, this);
97
78
  }
98
79
  ;
99
80
  /**
@@ -107,16 +88,14 @@ class UserInteraction {
107
88
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
108
89
  * @example await ui5.userInteraction.clickListItem(selector);
109
90
  */
110
- clickListItem(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- const elem = yield ui5.element.getDisplayed(selector, index, timeout);
113
- yield ui5.control.execute(function (control, done) {
114
- control.attachPress(function () {
115
- done();
116
- });
117
- control.firePress();
118
- }, elem);
119
- });
91
+ async clickListItem(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
92
+ const elem = await ui5.element.getDisplayed(selector, index, timeout);
93
+ await ui5.control.execute(function (control, done) {
94
+ control.attachPress(function () {
95
+ done();
96
+ });
97
+ control.firePress();
98
+ }, elem);
120
99
  }
121
100
  ;
122
101
  // =================================== FILL ===================================
@@ -130,20 +109,18 @@ class UserInteraction {
130
109
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
131
110
  * @example await ui5.userInteraction.fill(selector, "My Value");
132
111
  */
133
- fill(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- if (value !== null) {
136
- const id = yield ui5.element.getId(selector, index, timeout);
137
- let elem = null;
138
- if (selector.elementProperties.metadata === "sap.m.TextArea") {
139
- elem = yield nonUi5.element.getByCss("[id='" + id + "'] textarea", index, timeout);
140
- }
141
- else {
142
- elem = yield nonUi5.element.getByCss("[id='" + id + "'] input", index, timeout);
143
- }
144
- yield elem.setValue(value);
112
+ async fill(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
113
+ if (value !== null) {
114
+ const id = await ui5.element.getId(selector, index, timeout);
115
+ let elem = null;
116
+ if (selector.elementProperties.metadata === "sap.m.TextArea") {
117
+ elem = await nonUi5.element.getByCss("[id='" + id + "'] textarea", index, timeout);
145
118
  }
146
- });
119
+ else {
120
+ elem = await nonUi5.element.getByCss("[id='" + id + "'] input", index, timeout);
121
+ }
122
+ await elem.setValue(value);
123
+ }
147
124
  }
148
125
  ;
149
126
  /**
@@ -158,10 +135,8 @@ class UserInteraction {
158
135
  * @param {Number} [interval=5000] - The delay between the retries (ms). Can be set in config for all functions under params.stepRetriesIntervals.
159
136
  * @example await ui5.userInteraction.fillAndRetry(selector, "My Value");
160
137
  */
161
- fillAndRetry(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
162
- return __awaiter(this, void 0, void 0, function* () {
163
- yield util.function.retry(this.fill, [selector, value, index, timeout], retries, interval, this);
164
- });
138
+ async fillAndRetry(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
139
+ await util.function.retry(this.fill, [selector, value, index, timeout], retries, interval, this);
165
140
  }
166
141
  ;
167
142
  // =================================== CLEAR ===================================
@@ -175,10 +150,8 @@ class UserInteraction {
175
150
  * @example await ui5.userInteraction.clear(selector);
176
151
  */
177
152
  //TODO remove clearHelper and use clear
178
- clear(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- yield this._clearHelper(selector, index, timeout);
181
- });
153
+ async clear(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
154
+ await this._clearHelper(selector, index, timeout);
182
155
  }
183
156
  ;
184
157
  /**
@@ -192,10 +165,8 @@ class UserInteraction {
192
165
  * @param {Number} [interval=5000] - The delay between the retries (ms). Can be set in config for all functions under params.stepRetriesIntervals.
193
166
  * @example await ui5.userInteraction.clearAndRetry(selector);
194
167
  */
195
- clearAndRetry(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- yield util.function.retry(this.clear, [selector, index, timeout], retries, interval, this);
198
- });
168
+ async clearAndRetry(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
169
+ await util.function.retry(this.clear, [selector, index, timeout], retries, interval, this);
199
170
  }
200
171
  ;
201
172
  /**
@@ -208,16 +179,14 @@ class UserInteraction {
208
179
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
209
180
  * @example await ui5.userInteraction.clearAndFill(selector, "My Value");
210
181
  */
211
- clearAndFill(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- if (value !== null) {
214
- yield this.clear(selector, index, timeout);
215
- yield common.userInteraction.fillActive(value);
216
- }
217
- else {
218
- throw new Error("Function 'clearAndFill' failed. Please provide a value as second parameter.");
219
- }
220
- });
182
+ async clearAndFill(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
183
+ if (value !== null) {
184
+ await this.clear(selector, index, timeout);
185
+ await common.userInteraction.fillActive(value);
186
+ }
187
+ else {
188
+ throw new Error("Function 'clearAndFill' failed. Please provide a value as second parameter.");
189
+ }
221
190
  }
222
191
  ;
223
192
  /**
@@ -233,22 +202,20 @@ class UserInteraction {
233
202
  * @param {Boolean} [verify=true] - Specifies if the filled value should be verified.
234
203
  * @example await ui5.userInteraction.clearAndFillAndRetry(selector, "My Value");
235
204
  */
236
- clearAndFillAndRetry(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000, verify = true) {
237
- return __awaiter(this, void 0, void 0, function* () {
238
- yield util.function.retry((selector, value, index, timeout) => __awaiter(this, void 0, void 0, function* () {
239
- yield this.clearAndFill(selector, value, index, timeout);
240
- if (verify) {
241
- const elem = yield ui5.element.getDisplayed(selector);
242
- let elemValue = yield ui5.element.getValue(selector, index);
205
+ async clearAndFillAndRetry(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000, verify = true) {
206
+ await util.function.retry(async (selector, value, index, timeout) => {
207
+ await this.clearAndFill(selector, value, index, timeout);
208
+ if (verify) {
209
+ const elem = await ui5.element.getDisplayed(selector);
210
+ let elemValue = await ui5.element.getValue(selector, index);
211
+ if (elemValue != value) { // IMPORTANT: keep non-strict comparison for format changes after input (10 -> 10.00)
212
+ elemValue = await ui5.element.getInnerAttribute(elem, "data-" + "value");
243
213
  if (elemValue != value) { // IMPORTANT: keep non-strict comparison for format changes after input (10 -> 10.00)
244
- elemValue = yield ui5.element.getInnerAttribute(elem, "data-" + "value");
245
- if (elemValue != value) { // IMPORTANT: keep non-strict comparison for format changes after input (10 -> 10.00)
246
- throw new Error(`Actual value '${elemValue}' not equal to expected value '${value}'`);
247
- }
214
+ throw new Error(`Actual value '${elemValue}' not equal to expected value '${value}'`);
248
215
  }
249
216
  }
250
- }), [selector, value, index, timeout], retries, interval, this);
251
- });
217
+ }
218
+ }, [selector, value, index, timeout], retries, interval, this);
252
219
  }
253
220
  ;
254
221
  /**
@@ -260,10 +227,8 @@ class UserInteraction {
260
227
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
261
228
  * @example await ui5.userInteraction.clearSmartFieldInput(selector);
262
229
  */
263
- clearSmartFieldInput(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
264
- return __awaiter(this, void 0, void 0, function* () {
265
- yield ui5.userInteraction.clear(selector, index, timeout);
266
- });
230
+ async clearSmartFieldInput(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
231
+ await ui5.userInteraction.clear(selector, index, timeout);
267
232
  }
268
233
  ;
269
234
  /**
@@ -276,14 +241,12 @@ class UserInteraction {
276
241
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
277
242
  * @example await ui5.userInteraction.clearAndFillSmartFieldInput(selector, "My Value");
278
243
  */
279
- clearAndFillSmartFieldInput(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
280
- return __awaiter(this, void 0, void 0, function* () {
281
- const id = yield ui5.element.getId(selector, index, timeout);
282
- const elem = yield nonUi5.element.getByCss(`input[id*='${id}']`);
283
- yield elem.click();
284
- yield ui5.userInteraction.selectAll(selector, index, timeout);
285
- yield elem.setValue(value);
286
- });
244
+ async clearAndFillSmartFieldInput(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
245
+ const id = await ui5.element.getId(selector, index, timeout);
246
+ const elem = await nonUi5.element.getByCss(`input[id*='${id}']`);
247
+ await elem.click();
248
+ await ui5.userInteraction.selectAll(selector, index, timeout);
249
+ await elem.setValue(value);
287
250
  }
288
251
  ;
289
252
  /**
@@ -298,10 +261,8 @@ class UserInteraction {
298
261
  * @param {Number} [interval=5000] - The delay between the retries (ms). Can be set in config for all functions under params.stepRetriesIntervals.
299
262
  * @example await ui5.userInteraction.clearAndFillSmartFieldInputAndRetry(selector, "My Value");
300
263
  */
301
- clearAndFillSmartFieldInputAndRetry(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
302
- return __awaiter(this, void 0, void 0, function* () {
303
- yield util.function.retry(this.clearAndFillSmartFieldInput, [selector, value, index, timeout], retries, interval, this);
304
- });
264
+ async clearAndFillSmartFieldInputAndRetry(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, retries = 3, interval = 5000) {
265
+ await util.function.retry(this.clearAndFillSmartFieldInput, [selector, value, index, timeout], retries, interval, this);
305
266
  }
306
267
  ;
307
268
  // =================================== SELECT ===================================
@@ -316,25 +277,23 @@ class UserInteraction {
316
277
  * @param {Number} [index=0] - The index of the selector (in case there are more than one elements visible at the same time).
317
278
  * @example await ui5.userInteraction.selectBox(selector, "Germany");
318
279
  */
319
- selectBox(selector, value, index = 0) {
320
- return __awaiter(this, void 0, void 0, function* () {
321
- yield this.clickSelectArrow(selector, index);
322
- if (value) {
323
- const itemSelector = {
324
- "elementProperties": {
325
- "mProperties": {
326
- "text": value
327
- },
328
- "ancestorProperties": selector.elementProperties
329
- }
330
- };
331
- yield this.scrollToElement(itemSelector);
332
- yield this.click(itemSelector);
333
- }
334
- else {
335
- throw new Error("Function 'selectBox' failed: Please provide a value as second argument.");
336
- }
337
- });
280
+ async selectBox(selector, value, index = 0) {
281
+ await this.clickSelectArrow(selector, index);
282
+ if (value) {
283
+ const itemSelector = {
284
+ "elementProperties": {
285
+ "mProperties": {
286
+ "text": value
287
+ },
288
+ "ancestorProperties": selector.elementProperties
289
+ }
290
+ };
291
+ await this.scrollToElement(itemSelector);
292
+ await this.click(itemSelector);
293
+ }
294
+ else {
295
+ throw new Error("Function 'selectBox' failed: Please provide a value as second argument.");
296
+ }
338
297
  }
339
298
  ;
340
299
  /**
@@ -348,25 +307,23 @@ class UserInteraction {
348
307
  * @param {Number} [index=0] - The index of the selector (in case there are more than one elements visible at the same time).
349
308
  * @example await ui5.userInteraction.selectComboBox(selector, "Germany");
350
309
  */
351
- selectComboBox(selector, value, index = 0) {
352
- return __awaiter(this, void 0, void 0, function* () {
353
- yield this.clickSelectArrow(selector, index);
354
- if (value) {
355
- const selector = {
356
- "elementProperties": {
357
- "metadata": "sap.m.StandardListItem",
358
- "mProperties": {
359
- "title": value
360
- }
361
- },
362
- "parentProperties": {
363
- "metadata": "sap.m.List"
310
+ async selectComboBox(selector, value, index = 0) {
311
+ await this.clickSelectArrow(selector, index);
312
+ if (value) {
313
+ const selector = {
314
+ "elementProperties": {
315
+ "metadata": "sap.m.StandardListItem",
316
+ "mProperties": {
317
+ "title": value
364
318
  }
365
- };
366
- yield this.scrollToElement(selector);
367
- yield this.click(selector);
368
- }
369
- });
319
+ },
320
+ "parentProperties": {
321
+ "metadata": "sap.m.List"
322
+ }
323
+ };
324
+ await this.scrollToElement(selector);
325
+ await this.click(selector);
326
+ }
370
327
  }
371
328
  ;
372
329
  /**
@@ -380,27 +337,25 @@ class UserInteraction {
380
337
  * @param {Number} [index=0] - The index of the selector (in case there are more than one elements visible at the same time).
381
338
  * @example await ui5.userInteraction.selectMultiComboBox(selector, ["Option 1", "Option 2"]);
382
339
  */
383
- selectMultiComboBox(selector, values, index = 0) {
384
- return __awaiter(this, void 0, void 0, function* () {
385
- yield this.clickSelectArrow(selector, index);
386
- for (const v in values) {
387
- const ui5ControlProperties = {
388
- "elementProperties": {
389
- "metadata": "sap.m.CheckBox",
390
- "mProperties": {}
391
- },
392
- "parentProperties": {
393
- "metadata": "sap.m.StandardListItem",
394
- "mProperties": {
395
- "title": values[v]
396
- }
340
+ async selectMultiComboBox(selector, values, index = 0) {
341
+ await this.clickSelectArrow(selector, index);
342
+ for (const v in values) {
343
+ const ui5ControlProperties = {
344
+ "elementProperties": {
345
+ "metadata": "sap.m.CheckBox",
346
+ "mProperties": {}
347
+ },
348
+ "parentProperties": {
349
+ "metadata": "sap.m.StandardListItem",
350
+ "mProperties": {
351
+ "title": values[v]
397
352
  }
398
- };
399
- yield this.scrollToElement(ui5ControlProperties);
400
- yield this.click(ui5ControlProperties);
401
- }
402
- yield common.userInteraction.pressEnter();
403
- });
353
+ }
354
+ };
355
+ await this.scrollToElement(ui5ControlProperties);
356
+ await this.click(ui5ControlProperties);
357
+ }
358
+ await common.userInteraction.pressEnter();
404
359
  }
405
360
  ;
406
361
  /**
@@ -411,12 +366,10 @@ class UserInteraction {
411
366
  * @param {Number} [index=0] - The index of the selector (in case there are more than one elements visible at the same time).
412
367
  * @example await ui5.userInteraction.clickSelectArrow(selector);
413
368
  */
414
- clickSelectArrow(selector, index = 0) {
415
- return __awaiter(this, void 0, void 0, function* () {
416
- const id = yield ui5.element.getId(selector, index);
417
- const arrow = yield nonUi5.element.getByCss("[id='" + id + "-arrow']", 0, 3000);
418
- yield arrow.click();
419
- });
369
+ async clickSelectArrow(selector, index = 0) {
370
+ const id = await ui5.element.getId(selector, index);
371
+ const arrow = await nonUi5.element.getByCss("[id='" + id + "-arrow']", 0, 3000);
372
+ await arrow.click();
420
373
  }
421
374
  ;
422
375
  /**
@@ -429,10 +382,8 @@ class UserInteraction {
429
382
  * @param {Number} [interval=5000] - The delay between the retries (ms). Can be set in config for all functions under params.stepRetriesIntervals.
430
383
  * @example await ui5.userInteraction.clickSelectArrowAndRetry(selector);
431
384
  */
432
- clickSelectArrowAndRetry(selector, index = 0, retries = 3, interval = 5000) {
433
- return __awaiter(this, void 0, void 0, function* () {
434
- yield util.function.retry(this.clickSelectArrow, [selector, index], retries, interval, this);
435
- });
385
+ async clickSelectArrowAndRetry(selector, index = 0, retries = 3, interval = 5000) {
386
+ await util.function.retry(this.clickSelectArrow, [selector, index], retries, interval, this);
436
387
  }
437
388
  ;
438
389
  // =================================== OTHERS ===================================
@@ -445,17 +396,15 @@ class UserInteraction {
445
396
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
446
397
  * @example await ui5.userInteraction.mouseOverElement(selector);
447
398
  */
448
- mouseOverElement(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
449
- return __awaiter(this, void 0, void 0, function* () {
450
- let elem;
451
- try {
452
- elem = yield ui5.element.getDisplayed(selector, index, timeout);
453
- }
454
- catch (error) {
455
- throw new Error(`Function: 'mouseOverElement' failed: No element found for selector ${selector}`);
456
- }
457
- yield elem.moveTo();
458
- });
399
+ async mouseOverElement(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
400
+ let elem;
401
+ try {
402
+ elem = await ui5.element.getDisplayed(selector, index, timeout);
403
+ }
404
+ catch (error) {
405
+ throw new Error(`Function: 'mouseOverElement' failed: No element found for selector ${selector}`);
406
+ }
407
+ await elem.moveTo();
459
408
  }
460
409
  ;
461
410
  /**
@@ -470,17 +419,15 @@ class UserInteraction {
470
419
  * @example await ui5.userInteraction.scrollToElement(selector);
471
420
  * @example await ui5.userInteraction.scrollToElement(selector, 0, "start", 5000);
472
421
  */
473
- scrollToElement(selector, index = 0, alignment = "center", timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
474
- return __awaiter(this, void 0, void 0, function* () {
475
- const elem = yield ui5.element.getDisplayed(selector, index, timeout);
476
- if (elem) {
477
- const options = {
478
- "block": alignment,
479
- "inline": alignment
480
- };
481
- yield elem.scrollIntoView(options);
482
- }
483
- });
422
+ async scrollToElement(selector, index = 0, alignment = "center", timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
423
+ const elem = await ui5.element.getDisplayed(selector, index, timeout);
424
+ if (elem) {
425
+ const options = {
426
+ "block": alignment,
427
+ "inline": alignment
428
+ };
429
+ await elem.scrollIntoView(options);
430
+ }
484
431
  }
485
432
  ;
486
433
  /**
@@ -492,16 +439,14 @@ class UserInteraction {
492
439
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
493
440
  * @example await ui5.userInteraction.selectAll(selector);
494
441
  */
495
- selectAll(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
496
- return __awaiter(this, void 0, void 0, function* () {
497
- if (selector !== undefined) {
498
- yield this.click(selector, index, timeout);
499
- }
500
- else {
501
- util.console.info("Selector properties are undefined. Action will be performed on current element.");
502
- }
503
- yield common.userInteraction.pressKey(["\uE051", "a"]);
504
- });
442
+ async selectAll(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
443
+ if (selector !== undefined) {
444
+ await this.click(selector, index, timeout);
445
+ }
446
+ else {
447
+ util.console.info("Selector properties are undefined. Action will be performed on current element.");
448
+ }
449
+ await common.userInteraction.pressKey(["\uE051", "a"]);
505
450
  }
506
451
  ;
507
452
  /**
@@ -515,18 +460,16 @@ class UserInteraction {
515
460
  * The default value is true (triggered by pressing the F4-key). Set "useF4Key" to false, to trigger the search by clicking the button.
516
461
  * @example await ui5.userInteraction.openF4Help(selector, 0, 30000, false);
517
462
  */
518
- openF4Help(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, useF4Key = true) {
519
- return __awaiter(this, void 0, void 0, function* () {
520
- yield ui5.userInteraction.click(selector, index, timeout);
521
- if (useF4Key === true) {
522
- yield common.userInteraction.pressF4();
523
- }
524
- else {
525
- const id = yield ui5.element.getId(selector);
526
- const button = yield nonUi5.element.getByCss("[id='" + id + "-vhi']", 0, timeout);
527
- yield button.click();
528
- }
529
- });
463
+ async openF4Help(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, useF4Key = true) {
464
+ await ui5.userInteraction.click(selector, index, timeout);
465
+ if (useF4Key === true) {
466
+ await common.userInteraction.pressF4();
467
+ }
468
+ else {
469
+ const id = await ui5.element.getId(selector);
470
+ const button = await nonUi5.element.getByCss("[id='" + id + "-vhi']", 0, timeout);
471
+ await button.click();
472
+ }
530
473
  }
531
474
  ;
532
475
  /**
@@ -541,18 +484,16 @@ class UserInteraction {
541
484
  * The default value is true (triggered by pressing the Enter-key). Set "useEnter" to false, to trigger the search by clicking the search button.
542
485
  * @example await ui5.userInteraction.searchFor(selector, "My Value", 0, 30000, false);
543
486
  */
544
- searchFor(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, useEnter = true) {
545
- return __awaiter(this, void 0, void 0, function* () {
546
- yield ui5.userInteraction.clearAndFillAndRetry(selector, value, index, timeout);
547
- if (useEnter === true) {
548
- yield common.userInteraction.pressEnter();
549
- }
550
- else {
551
- const id = yield ui5.element.getId(selector, index, timeout);
552
- const searchButton = yield nonUi5.element.getByCss("[id='" + id + "-search']", 0, timeout);
553
- yield searchButton.click();
554
- }
555
- });
487
+ async searchFor(selector, value, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000, useEnter = true) {
488
+ await ui5.userInteraction.clearAndFillAndRetry(selector, value, index, timeout);
489
+ if (useEnter === true) {
490
+ await common.userInteraction.pressEnter();
491
+ }
492
+ else {
493
+ const id = await ui5.element.getId(selector, index, timeout);
494
+ const searchButton = await nonUi5.element.getByCss("[id='" + id + "-search']", 0, timeout);
495
+ await searchButton.click();
496
+ }
556
497
  }
557
498
  ;
558
499
  /**
@@ -564,51 +505,47 @@ class UserInteraction {
564
505
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
565
506
  * @example await ui5.userInteraction.resetSearch(selector);
566
507
  */
567
- resetSearch(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
568
- return __awaiter(this, void 0, void 0, function* () {
569
- const id = yield ui5.element.getId(selector, index, timeout);
570
- const resetButton = yield nonUi5.element.getByCss("[id='" + id + "-reset']", 0, timeout);
571
- yield resetButton.click();
572
- });
508
+ async resetSearch(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
509
+ const id = await ui5.element.getId(selector, index, timeout);
510
+ const resetButton = await nonUi5.element.getByCss("[id='" + id + "-reset']", 0, timeout);
511
+ await resetButton.click();
573
512
  }
574
513
  ;
575
514
  // =================================== HELPER ===================================
576
515
  //TODO: rework function in its whole. Why don't we use the clear function from native wdio here?
577
- _clearHelper(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
578
- return __awaiter(this, void 0, void 0, function* () {
579
- let id, elem;
580
- if (selector) {
581
- yield ui5.userInteraction.click(selector, index, timeout);
582
- id = yield ui5.element.getId(selector, index, timeout);
583
- elem = yield browser.getActiveElement();
516
+ async _clearHelper(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
517
+ let id, elem;
518
+ if (selector) {
519
+ await ui5.userInteraction.click(selector, index, timeout);
520
+ id = await ui5.element.getId(selector, index, timeout);
521
+ elem = await browser.getActiveElement();
522
+ }
523
+ else {
524
+ elem = await browser.getActiveElement();
525
+ await elem.click();
526
+ // @ts-ignore
527
+ id = await util.function.getAttribute(elem, "id");
528
+ }
529
+ const tokenizers = await browser.execute(function (id) {
530
+ // @ts-ignore
531
+ const t = document.getElementById(id).querySelectorAll(".sapMTokenizer");
532
+ // @ts-ignore
533
+ const inputs = document.getElementById(id).getElementsByTagName("input");
534
+ // @ts-ignore
535
+ const textareas = document.getElementById(id).getElementsByTagName("textarea");
536
+ if (inputs.length) {
537
+ inputs[0].value = "";
538
+ inputs[0].focus();
584
539
  }
585
- else {
586
- elem = yield browser.getActiveElement();
587
- yield elem.click();
588
- // @ts-ignore
589
- id = yield util.function.getAttribute(elem, "id");
540
+ if (textareas.length) {
541
+ textareas[0].value = "";
590
542
  }
591
- const tokenizers = yield browser.execute(function (id) {
592
- // @ts-ignore
593
- const t = document.getElementById(id).querySelectorAll(".sapMTokenizer");
594
- // @ts-ignore
595
- const inputs = document.getElementById(id).getElementsByTagName("input");
596
- // @ts-ignore
597
- const textareas = document.getElementById(id).getElementsByTagName("textarea");
598
- if (inputs.length) {
599
- inputs[0].value = "";
600
- inputs[0].focus();
601
- }
602
- if (textareas.length) {
603
- textareas[0].value = "";
604
- }
605
- return t;
606
- }, id);
607
- if ((yield tokenizers) && (yield tokenizers.length)) {
608
- yield ui5.userInteraction.selectAll(selector, index, timeout);
609
- yield common.userInteraction.pressBackspace();
610
- }
611
- });
543
+ return t;
544
+ }, id);
545
+ if (await tokenizers && await tokenizers.length) {
546
+ await ui5.userInteraction.selectAll(selector, index, timeout);
547
+ await common.userInteraction.pressBackspace();
548
+ }
612
549
  }
613
550
  /**
614
551
  * @function doubleClick
@@ -619,30 +556,26 @@ class UserInteraction {
619
556
  * @param {Number} [timeout=30000] - The timeout to wait (ms).
620
557
  * @example await ui5.userInteraction.doubleClick(selector);
621
558
  */
622
- doubleClick(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
623
- return __awaiter(this, void 0, void 0, function* () {
624
- let elem = null;
625
- yield browser.waitUntil(function () {
626
- return __awaiter(this, void 0, void 0, function* () {
627
- elem = yield ui5.element.getDisplayed(selector, index, timeout);
628
- if (!elem)
629
- return false;
630
- return elem.isClickable();
631
- });
632
- }, {
633
- timeout,
634
- timeoutMsg: `Element not clickable after ${+timeout / 1000}s`
635
- });
636
- try {
637
- // @ts-ignore
638
- yield elem.doubleClick();
639
- }
640
- catch (error) {
641
- // @ts-ignore
642
- const errorMessage = yield util.function.mapWdioErrorToQmateErrorMessage(error, "doubleClick");
643
- throw new Error(errorMessage);
644
- }
559
+ async doubleClick(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
560
+ let elem = null;
561
+ await browser.waitUntil(async function () {
562
+ elem = await ui5.element.getDisplayed(selector, index, timeout);
563
+ if (!elem)
564
+ return false;
565
+ return elem.isClickable();
566
+ }, {
567
+ timeout,
568
+ timeoutMsg: `Element not clickable after ${+timeout / 1000}s`
645
569
  });
570
+ try {
571
+ // @ts-ignore
572
+ await elem.doubleClick();
573
+ }
574
+ catch (error) {
575
+ // @ts-ignore
576
+ const errorMessage = await util.function.mapWdioErrorToQmateErrorMessage(error, "doubleClick");
577
+ throw new Error(errorMessage);
578
+ }
646
579
  }
647
580
  ;
648
581
  /**
@@ -655,32 +588,28 @@ class UserInteraction {
655
588
  * @example const elem = await nonUi5.element.getById("button01");
656
589
  * await ui5.userInteraction.rightClick(elem);
657
590
  */
658
- rightClick(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
659
- return __awaiter(this, void 0, void 0, function* () {
660
- let elem = null;
661
- yield browser.waitUntil(function () {
662
- return __awaiter(this, void 0, void 0, function* () {
663
- elem = yield ui5.element.getDisplayed(selector, index, timeout);
664
- if (!elem)
665
- return false;
666
- return elem.isClickable();
667
- });
668
- }, {
669
- timeout,
670
- timeoutMsg: `Element not clickable after ${+timeout / 1000}s`
671
- });
672
- try {
673
- // @ts-ignore
674
- yield elem.click({
675
- button: "right"
676
- });
677
- }
678
- catch (error) {
679
- // @ts-ignore
680
- const errorMessage = yield util.function.mapWdioErrorToQmateErrorMessage(error, "rightClick");
681
- throw new Error(errorMessage);
682
- }
591
+ async rightClick(selector, index = 0, timeout = process.env.QMATE_CUSTOM_TIMEOUT || 30000) {
592
+ let elem = null;
593
+ await browser.waitUntil(async function () {
594
+ elem = await ui5.element.getDisplayed(selector, index, timeout);
595
+ if (!elem)
596
+ return false;
597
+ return elem.isClickable();
598
+ }, {
599
+ timeout,
600
+ timeoutMsg: `Element not clickable after ${+timeout / 1000}s`
683
601
  });
602
+ try {
603
+ // @ts-ignore
604
+ await elem.click({
605
+ button: "right"
606
+ });
607
+ }
608
+ catch (error) {
609
+ // @ts-ignore
610
+ const errorMessage = await util.function.mapWdioErrorToQmateErrorMessage(error, "rightClick");
611
+ throw new Error(errorMessage);
612
+ }
684
613
  }
685
614
  ;
686
615
  }