askui 0.17.1 → 0.18.0

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 (233) hide show
  1. package/dist/cjs/execution/index.d.ts +1 -1
  2. package/dist/cjs/execution/ui-control-client.d.ts +154 -13
  3. package/dist/cjs/execution/ui-control-client.js +219 -21
  4. package/dist/cjs/lib/interactive_cli/create-example-project.js +1 -1
  5. package/dist/cjs/main.d.ts +1 -1
  6. package/dist/esm/execution/index.d.ts +1 -1
  7. package/dist/esm/execution/ui-control-client.d.ts +154 -13
  8. package/dist/esm/execution/ui-control-client.js +216 -21
  9. package/dist/esm/lib/interactive_cli/create-example-project.js +1 -1
  10. package/dist/esm/main.d.ts +1 -1
  11. package/dist/example_projects_templates/typescript/.eslintrc.json-template +3 -2
  12. package/package.json +1 -1
  13. package/dist/cjs/core/annotation/annotation-writer.js.map +0 -1
  14. package/dist/cjs/core/annotation/annotation.js.map +0 -1
  15. package/dist/cjs/core/inference-response/inference-response.js.map +0 -1
  16. package/dist/cjs/core/inference-response/invalid-model-type-error.js.map +0 -1
  17. package/dist/cjs/core/inference-response/model-type.js.map +0 -1
  18. package/dist/cjs/core/model/annotation-result/annotation-interface.js.map +0 -1
  19. package/dist/cjs/core/model/annotation-result/boundary-box.js.map +0 -1
  20. package/dist/cjs/core/model/annotation-result/detected-element.js.map +0 -1
  21. package/dist/cjs/core/model/custom-element-json.js.map +0 -1
  22. package/dist/cjs/core/model/custom-element.js.map +0 -1
  23. package/dist/cjs/core/reporting/default-step.js.map +0 -1
  24. package/dist/cjs/core/reporting/index.js.map +0 -1
  25. package/dist/cjs/core/reporting/instruction.js.map +0 -1
  26. package/dist/cjs/core/reporting/reporter-config.js.map +0 -1
  27. package/dist/cjs/core/reporting/reporter.js.map +0 -1
  28. package/dist/cjs/core/reporting/snapshot-detail-level.js.map +0 -1
  29. package/dist/cjs/core/reporting/snapshot.js.map +0 -1
  30. package/dist/cjs/core/reporting/step-reporter.js.map +0 -1
  31. package/dist/cjs/core/reporting/step-run.js.map +0 -1
  32. package/dist/cjs/core/reporting/step-status-end.js.map +0 -1
  33. package/dist/cjs/core/reporting/step-status.js.map +0 -1
  34. package/dist/cjs/core/reporting/step.js.map +0 -1
  35. package/dist/cjs/core/runner-protocol/index.js.map +0 -1
  36. package/dist/cjs/core/runner-protocol/request/capture-screenshot-request.js.map +0 -1
  37. package/dist/cjs/core/runner-protocol/request/control-request.js.map +0 -1
  38. package/dist/cjs/core/runner-protocol/request/get-server-process-pid.js.map +0 -1
  39. package/dist/cjs/core/runner-protocol/request/index.js.map +0 -1
  40. package/dist/cjs/core/runner-protocol/request/interactive-annotation-request.js.map +0 -1
  41. package/dist/cjs/core/runner-protocol/request/read-recording-request.js.map +0 -1
  42. package/dist/cjs/core/runner-protocol/request/runner-protocol-request.js.map +0 -1
  43. package/dist/cjs/core/runner-protocol/request/start-recording-request.js.map +0 -1
  44. package/dist/cjs/core/runner-protocol/request/stop-recording-request.js.map +0 -1
  45. package/dist/cjs/core/runner-protocol/response/index.js.map +0 -1
  46. package/dist/cjs/core/ui-control-commands/action.js.map +0 -1
  47. package/dist/cjs/core/ui-control-commands/control-command-code.js.map +0 -1
  48. package/dist/cjs/core/ui-control-commands/control-command.js.map +0 -1
  49. package/dist/cjs/core/ui-control-commands/index.js.map +0 -1
  50. package/dist/cjs/core/ui-control-commands/input-event.js.map +0 -1
  51. package/dist/cjs/execution/config-error.js.map +0 -1
  52. package/dist/cjs/execution/control-command-error.js.map +0 -1
  53. package/dist/cjs/execution/credentials-args.js.map +0 -1
  54. package/dist/cjs/execution/dsl.js.map +0 -1
  55. package/dist/cjs/execution/execution-runtime.js.map +0 -1
  56. package/dist/cjs/execution/index.js.map +0 -1
  57. package/dist/cjs/execution/inference-client.js.map +0 -1
  58. package/dist/cjs/execution/inference-response-error.js.map +0 -1
  59. package/dist/cjs/execution/is-image-required-interface.js.map +0 -1
  60. package/dist/cjs/execution/misc.js.map +0 -1
  61. package/dist/cjs/execution/model-composition-branch.js.map +0 -1
  62. package/dist/cjs/execution/read-environment-credentials.js.map +0 -1
  63. package/dist/cjs/execution/read-recording-response-stream-handler.js.map +0 -1
  64. package/dist/cjs/execution/repeat-error.js.map +0 -1
  65. package/dist/cjs/execution/ui-control-client-dependency-builder.js.map +0 -1
  66. package/dist/cjs/execution/ui-control-client.js.map +0 -1
  67. package/dist/cjs/execution/ui-controller-client-connection-state.js.map +0 -1
  68. package/dist/cjs/execution/ui-controller-client-error.js.map +0 -1
  69. package/dist/cjs/execution/ui-controller-client-interface.js.map +0 -1
  70. package/dist/cjs/execution/ui-controller-client.js.map +0 -1
  71. package/dist/cjs/lib/download-binaries.js.map +0 -1
  72. package/dist/cjs/lib/index.js.map +0 -1
  73. package/dist/cjs/lib/interactive_cli/add-script-package-json.d.ts +0 -1
  74. package/dist/cjs/lib/interactive_cli/add-script-package-json.js +0 -39
  75. package/dist/cjs/lib/interactive_cli/add-script-package-json.js.map +0 -1
  76. package/dist/cjs/lib/interactive_cli/cli-options-interface.js.map +0 -1
  77. package/dist/cjs/lib/interactive_cli/cli.js.map +0 -1
  78. package/dist/cjs/lib/interactive_cli/create-example-project.js.map +0 -1
  79. package/dist/cjs/lib/interactive_cli/index.js.map +0 -1
  80. package/dist/cjs/lib/libfuse-error.js.map +0 -1
  81. package/dist/cjs/lib/logger.js.map +0 -1
  82. package/dist/cjs/lib/timeout-error.js.map +0 -1
  83. package/dist/cjs/lib/ui-controller-args.js.map +0 -1
  84. package/dist/cjs/lib/ui-controller-darwin.js.map +0 -1
  85. package/dist/cjs/lib/ui-controller-facade.js.map +0 -1
  86. package/dist/cjs/lib/ui-controller-linux.js.map +0 -1
  87. package/dist/cjs/lib/ui-controller-win32.js.map +0 -1
  88. package/dist/cjs/lib/ui-controller.js.map +0 -1
  89. package/dist/cjs/lib/unkown-error.js.map +0 -1
  90. package/dist/cjs/lib/wayland-error.js.map +0 -1
  91. package/dist/cjs/main.js.map +0 -1
  92. package/dist/cjs/shared/index.js.map +0 -1
  93. package/dist/cjs/shared/log-levels.js.map +0 -1
  94. package/dist/cjs/shared/proxy-agent-args.js.map +0 -1
  95. package/dist/cjs/utils/analytics/analytics-interface.js.map +0 -1
  96. package/dist/cjs/utils/analytics/analytics.js.map +0 -1
  97. package/dist/cjs/utils/analytics/index.js.map +0 -1
  98. package/dist/cjs/utils/analytics/installation-timestamp-create-error.js.map +0 -1
  99. package/dist/cjs/utils/analytics/installation-timestamp-get-error.js.map +0 -1
  100. package/dist/cjs/utils/analytics/installation-timestamp.js.map +0 -1
  101. package/dist/cjs/utils/analytics/user-identifier-interface.js.map +0 -1
  102. package/dist/cjs/utils/analytics/user-identifier.js.map +0 -1
  103. package/dist/cjs/utils/base_64_image/base-64-image-error.js.map +0 -1
  104. package/dist/cjs/utils/base_64_image/base-64-image-string-error.js.map +0 -1
  105. package/dist/cjs/utils/base_64_image/base-64-image.js.map +0 -1
  106. package/dist/cjs/utils/base_64_image/sharp.js.map +0 -1
  107. package/dist/cjs/utils/http/credentials.js.map +0 -1
  108. package/dist/cjs/utils/http/custom-errors/authentication-http-client-error.js.map +0 -1
  109. package/dist/cjs/utils/http/custom-errors/client-http-client-error.js.map +0 -1
  110. package/dist/cjs/utils/http/custom-errors/general-http-client-error.js.map +0 -1
  111. package/dist/cjs/utils/http/custom-errors/http-client-error.js.map +0 -1
  112. package/dist/cjs/utils/http/custom-errors/index.js.map +0 -1
  113. package/dist/cjs/utils/http/custom-errors/server-http-client-error.js.map +0 -1
  114. package/dist/cjs/utils/http/custom-errors/unkown-http-client-error.js.map +0 -1
  115. package/dist/cjs/utils/http/http-client-got.js.map +0 -1
  116. package/dist/cjs/utils/http/index.js.map +0 -1
  117. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js.map +0 -1
  118. package/dist/cjs/utils/image-resize-errors/index.js.map +0 -1
  119. package/dist/cjs/utils/path.js.map +0 -1
  120. package/dist/cjs/utils/proxy/proxy-builder.js.map +0 -1
  121. package/dist/cjs/utils/resized-image-interface.js.map +0 -1
  122. package/dist/cjs/utils/transformations.js.map +0 -1
  123. package/dist/esm/core/annotation/annotation-writer.js.map +0 -1
  124. package/dist/esm/core/annotation/annotation.js.map +0 -1
  125. package/dist/esm/core/inference-response/inference-response.js.map +0 -1
  126. package/dist/esm/core/inference-response/invalid-model-type-error.js.map +0 -1
  127. package/dist/esm/core/inference-response/model-type.js.map +0 -1
  128. package/dist/esm/core/model/annotation-result/annotation-interface.js.map +0 -1
  129. package/dist/esm/core/model/annotation-result/boundary-box.js.map +0 -1
  130. package/dist/esm/core/model/annotation-result/detected-element.js.map +0 -1
  131. package/dist/esm/core/model/custom-element-json.js.map +0 -1
  132. package/dist/esm/core/model/custom-element.js.map +0 -1
  133. package/dist/esm/core/reporting/default-step.js.map +0 -1
  134. package/dist/esm/core/reporting/index.js.map +0 -1
  135. package/dist/esm/core/reporting/instruction.js.map +0 -1
  136. package/dist/esm/core/reporting/reporter-config.js.map +0 -1
  137. package/dist/esm/core/reporting/reporter.js.map +0 -1
  138. package/dist/esm/core/reporting/snapshot-detail-level.js.map +0 -1
  139. package/dist/esm/core/reporting/snapshot.js.map +0 -1
  140. package/dist/esm/core/reporting/step-reporter.js.map +0 -1
  141. package/dist/esm/core/reporting/step-run.js.map +0 -1
  142. package/dist/esm/core/reporting/step-status-end.js.map +0 -1
  143. package/dist/esm/core/reporting/step-status.js.map +0 -1
  144. package/dist/esm/core/reporting/step.js.map +0 -1
  145. package/dist/esm/core/runner-protocol/index.js.map +0 -1
  146. package/dist/esm/core/runner-protocol/request/capture-screenshot-request.js.map +0 -1
  147. package/dist/esm/core/runner-protocol/request/control-request.js.map +0 -1
  148. package/dist/esm/core/runner-protocol/request/get-server-process-pid.js.map +0 -1
  149. package/dist/esm/core/runner-protocol/request/index.js.map +0 -1
  150. package/dist/esm/core/runner-protocol/request/interactive-annotation-request.js.map +0 -1
  151. package/dist/esm/core/runner-protocol/request/read-recording-request.js.map +0 -1
  152. package/dist/esm/core/runner-protocol/request/runner-protocol-request.js.map +0 -1
  153. package/dist/esm/core/runner-protocol/request/start-recording-request.js.map +0 -1
  154. package/dist/esm/core/runner-protocol/request/stop-recording-request.js.map +0 -1
  155. package/dist/esm/core/runner-protocol/response/index.js.map +0 -1
  156. package/dist/esm/core/ui-control-commands/action.js.map +0 -1
  157. package/dist/esm/core/ui-control-commands/control-command-code.js.map +0 -1
  158. package/dist/esm/core/ui-control-commands/control-command.js.map +0 -1
  159. package/dist/esm/core/ui-control-commands/index.js.map +0 -1
  160. package/dist/esm/core/ui-control-commands/input-event.js.map +0 -1
  161. package/dist/esm/execution/config-error.js.map +0 -1
  162. package/dist/esm/execution/control-command-error.js.map +0 -1
  163. package/dist/esm/execution/credentials-args.js.map +0 -1
  164. package/dist/esm/execution/dsl.js.map +0 -1
  165. package/dist/esm/execution/execution-runtime.js.map +0 -1
  166. package/dist/esm/execution/index.js.map +0 -1
  167. package/dist/esm/execution/inference-client.js.map +0 -1
  168. package/dist/esm/execution/inference-response-error.js.map +0 -1
  169. package/dist/esm/execution/is-image-required-interface.js.map +0 -1
  170. package/dist/esm/execution/misc.js.map +0 -1
  171. package/dist/esm/execution/model-composition-branch.js.map +0 -1
  172. package/dist/esm/execution/read-environment-credentials.js.map +0 -1
  173. package/dist/esm/execution/read-recording-response-stream-handler.js.map +0 -1
  174. package/dist/esm/execution/repeat-error.js.map +0 -1
  175. package/dist/esm/execution/ui-control-client-dependency-builder.js.map +0 -1
  176. package/dist/esm/execution/ui-control-client.js.map +0 -1
  177. package/dist/esm/execution/ui-controller-client-connection-state.js.map +0 -1
  178. package/dist/esm/execution/ui-controller-client-error.js.map +0 -1
  179. package/dist/esm/execution/ui-controller-client-interface.js.map +0 -1
  180. package/dist/esm/execution/ui-controller-client.js.map +0 -1
  181. package/dist/esm/lib/download-binaries.js.map +0 -1
  182. package/dist/esm/lib/index.js.map +0 -1
  183. package/dist/esm/lib/interactive_cli/add-script-package-json.d.ts +0 -1
  184. package/dist/esm/lib/interactive_cli/add-script-package-json.js +0 -32
  185. package/dist/esm/lib/interactive_cli/add-script-package-json.js.map +0 -1
  186. package/dist/esm/lib/interactive_cli/cli-options-interface.js.map +0 -1
  187. package/dist/esm/lib/interactive_cli/cli.js.map +0 -1
  188. package/dist/esm/lib/interactive_cli/create-example-project.js.map +0 -1
  189. package/dist/esm/lib/interactive_cli/index.js.map +0 -1
  190. package/dist/esm/lib/libfuse-error.js.map +0 -1
  191. package/dist/esm/lib/logger.js.map +0 -1
  192. package/dist/esm/lib/timeout-error.js.map +0 -1
  193. package/dist/esm/lib/ui-controller-args.js.map +0 -1
  194. package/dist/esm/lib/ui-controller-darwin.js.map +0 -1
  195. package/dist/esm/lib/ui-controller-facade.js.map +0 -1
  196. package/dist/esm/lib/ui-controller-linux.js.map +0 -1
  197. package/dist/esm/lib/ui-controller-win32.js.map +0 -1
  198. package/dist/esm/lib/ui-controller.js.map +0 -1
  199. package/dist/esm/lib/unkown-error.js.map +0 -1
  200. package/dist/esm/lib/wayland-error.js.map +0 -1
  201. package/dist/esm/main.js.map +0 -1
  202. package/dist/esm/shared/index.js.map +0 -1
  203. package/dist/esm/shared/log-levels.js.map +0 -1
  204. package/dist/esm/shared/proxy-agent-args.js.map +0 -1
  205. package/dist/esm/utils/analytics/analytics-interface.js.map +0 -1
  206. package/dist/esm/utils/analytics/analytics.js.map +0 -1
  207. package/dist/esm/utils/analytics/index.js.map +0 -1
  208. package/dist/esm/utils/analytics/installation-timestamp-create-error.js.map +0 -1
  209. package/dist/esm/utils/analytics/installation-timestamp-get-error.js.map +0 -1
  210. package/dist/esm/utils/analytics/installation-timestamp.js.map +0 -1
  211. package/dist/esm/utils/analytics/user-identifier-interface.js.map +0 -1
  212. package/dist/esm/utils/analytics/user-identifier.js.map +0 -1
  213. package/dist/esm/utils/base_64_image/base-64-image-error.js.map +0 -1
  214. package/dist/esm/utils/base_64_image/base-64-image-string-error.js.map +0 -1
  215. package/dist/esm/utils/base_64_image/base-64-image.js.map +0 -1
  216. package/dist/esm/utils/base_64_image/sharp.js.map +0 -1
  217. package/dist/esm/utils/http/credentials.js.map +0 -1
  218. package/dist/esm/utils/http/custom-errors/authentication-http-client-error.js.map +0 -1
  219. package/dist/esm/utils/http/custom-errors/client-http-client-error.js.map +0 -1
  220. package/dist/esm/utils/http/custom-errors/general-http-client-error.js.map +0 -1
  221. package/dist/esm/utils/http/custom-errors/http-client-error.js.map +0 -1
  222. package/dist/esm/utils/http/custom-errors/index.js.map +0 -1
  223. package/dist/esm/utils/http/custom-errors/server-http-client-error.js.map +0 -1
  224. package/dist/esm/utils/http/custom-errors/unkown-http-client-error.js.map +0 -1
  225. package/dist/esm/utils/http/http-client-got.js.map +0 -1
  226. package/dist/esm/utils/http/index.js.map +0 -1
  227. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js.map +0 -1
  228. package/dist/esm/utils/image-resize-errors/index.js.map +0 -1
  229. package/dist/esm/utils/path.js.map +0 -1
  230. package/dist/esm/utils/proxy/proxy-builder.js.map +0 -1
  231. package/dist/esm/utils/resized-image-interface.js.map +0 -1
  232. package/dist/esm/utils/transformations.js.map +0 -1
  233. package/dist/example_projects_templates/configs/jasmine.config.json +0 -12
@@ -1 +1 @@
1
- export { UiControlClient } from './ui-control-client';
1
+ export { UiControlClient, RelationsForConvenienceMethods } from './ui-control-client';
@@ -5,6 +5,7 @@ import { Annotation } from '../core/annotation/annotation';
5
5
  import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
6
6
  import { DetectedElement } from '../core/model/annotation-result/detected-element';
7
7
  import { ClientArgs } from './ui-controller-client-interface';
8
+ export declare type RelationsForConvenienceMethods = 'nearestTo' | 'leftOf' | 'above' | 'rightOf' | 'below' | 'contains';
8
9
  export declare class UiControlClient extends ApiCommands {
9
10
  private executionRuntime;
10
11
  private stepReporter;
@@ -108,12 +109,6 @@ export declare class UiControlClient extends ApiCommands {
108
109
  * @param {PC_AND_MODIFIER_KEY[]} keys
109
110
  */
110
111
  pressKeys(keys: PC_AND_MODIFIER_KEY[]): Promise<void>;
111
- /**
112
- * Searches for a text element and clicks it when found.
113
- *
114
- * @param {string} text - A text to be searched.
115
- */
116
- clickText(text: string): Promise<void>;
117
112
  /**
118
113
  * Searches for text elements and clicks them
119
114
  * one after another when found.
@@ -121,13 +116,6 @@ export declare class UiControlClient extends ApiCommands {
121
116
  * @param {string[]} texts - An array of texts to be searched.
122
117
  */
123
118
  clickTexts(texts: string[]): Promise<void>;
124
- /**
125
- * Searches for an element of type button
126
- * with a label and clicks it when found.
127
- *
128
- * @param {string} label - The buttons label.
129
- */
130
- clickButton(label: string): Promise<void>;
131
119
  /**
132
120
  * Searches for an element of type textfield with a specific placeholder text.
133
121
  * If found, clicks it.
@@ -162,4 +150,157 @@ export declare class UiControlClient extends ApiCommands {
162
150
  * @param {number} waitTime - Time in milliseconds
163
151
  */
164
152
  waitUntil(AskUICommand: Executable, maxTry?: number, waitTime?: number): Promise<void>;
153
+ private evaluateRelation;
154
+ /**
155
+ * Click a button with a specific label.
156
+ * Optional relation identifies the button in relation to another element.
157
+ *
158
+ * **Examples:**
159
+ * ```typescript
160
+ * await aui.clickButton({})
161
+ * await aui.clickButton({label: 'Checkout here'})
162
+ * await aui.clickButton({relation: {type: 'leftOf', text: 'Choose a ticket'}})
163
+ * await aui.clickButton({label: 'Click', {relation: {type: 'leftOf', text: 'Choose a ticket'}})
164
+ * ```
165
+ *
166
+ * @param {Object} params - Object containing properties.
167
+ * @property {string} [params.label] - The text label of the button. Defaults to an empty string.
168
+ * @property {Object} [params.relation] - Object describing the relationship between
169
+ * the clicked button and another element.
170
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
171
+ * @property {string} params.relation.text - The text element the relation is based on.
172
+ */
173
+ clickButton(params: {
174
+ label?: string;
175
+ relation?: {
176
+ type: RelationsForConvenienceMethods;
177
+ text: string;
178
+ };
179
+ }): Promise<void>;
180
+ /**
181
+ * Click a checkbox with a specific label.
182
+ * You can also specify where the label is placed relationally.
183
+ *
184
+ * **Examples:**
185
+ * ```typescript
186
+ * await aui.clickCheckbox({label: 'Toggle'})
187
+ * await aui.clickCheckbox({label: 'Toggle', relation: {type: 'leftOf'}})
188
+ * ```
189
+ *
190
+ * @param {Object} params - Object containing required `label` property and
191
+ * optional `relation` property.
192
+ * @property {string} params.label - The label for the checkbox.
193
+ * @property {Object} params.relation - Object describing the relationship between
194
+ * the clicked checkbox and another element.
195
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
196
+ */
197
+ clickCheckbox(params: {
198
+ label: string;
199
+ relation?: {
200
+ type: RelationsForConvenienceMethods;
201
+ };
202
+ }): Promise<void>;
203
+ /**
204
+ * Click a switch with a specific label.
205
+ * You can also specify where the label is placed relationally.
206
+ *
207
+ * **Examples:**
208
+ * ```typescript
209
+ * await aui.clickSwitch({label: 'Toggle'})
210
+ * await aui.clickSwitch({label: 'Toggle', relation: {type: 'leftOf'}})
211
+ * ```
212
+ *
213
+ * @param {Object} params - Object containing required `label` property and
214
+ * optional `relation` property.
215
+ * @property {string} params.label - The label for the checkbox.
216
+ * @property {Object} params.relation - Object describing the relationship between
217
+ * the clicked checkbox and another element.
218
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
219
+ */
220
+ clickSwitch(params: {
221
+ label: string;
222
+ relation?: {
223
+ type: RelationsForConvenienceMethods;
224
+ };
225
+ }): Promise<void>;
226
+ /**
227
+ * Types a given text into a textfield.
228
+ * Use a relation to specify how to find
229
+ * the textfield in relation to a specific label.
230
+ *
231
+ * **Examples:**
232
+ * ```typescript
233
+ * // Finds the textfield nearest to the label 'Email'
234
+ * await aui.typeIntoTextfield({textToWrite: 'Hello World', relation: {label: 'Email'}});
235
+ *
236
+ * // Finds the textfield above/below a label 'Password'
237
+ * await aui.typeIntoTextfield(
238
+ * {textToWrite: 'Hello World', relation: {type: 'above', label: 'Password'}}
239
+ * );
240
+ * await aui.typeIntoTextfield(
241
+ * {textToWrite: 'Hello World', relation: {type: 'below', label: 'Password'}}
242
+ * );
243
+ *
244
+ * // If there is no label but a placeholder, the label is contained in the textfield
245
+ * await aui.typeIntoTextfield(
246
+ * {textToWrite: 'Hello World', relation: {type: 'contains', label: 'Enter email'}}
247
+ * );
248
+ * ```
249
+ *
250
+ * @param {Object} params - Object containing required `textToWrite` property and
251
+ * optional `relation` property.
252
+ * @property {string} params.textToWrite - The text to be typed into the textfield.
253
+ * @property {Object} params.relation - Object describing the relationship between the
254
+ * textfield being interacted with and another element.
255
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of
256
+ * relation, optional.
257
+ * @property {string} params.relation.label - The label associated with the related
258
+ * element, optional.
259
+ */
260
+ typeIntoTextfield(params: {
261
+ textToWrite: string;
262
+ relation: {
263
+ type?: RelationsForConvenienceMethods;
264
+ label: string;
265
+ };
266
+ }): Promise<void>;
267
+ /**
268
+ * Click on a specific text.
269
+ * You can also use a RegEx or match the text exactly by specifyicing the specific flag.
270
+ * Use a relation to find the text in relation to a specific text.
271
+ *
272
+ * **Examples:**
273
+ * ```typescript
274
+ * // Click text that matches exactly
275
+ * await aui.clickText({text: 'askui', type: 'similar'})
276
+ *
277
+ * // Click text that contains 'pie' or 'cake' or 'Pie' or 'Cake'
278
+ * await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*', type: 'regex'})
279
+ *
280
+ * // Click the text 'TERMINAL' that is left of the text 'Ports'
281
+ * await aui.clickText({
282
+ * text: 'TERMINAL',
283
+ * type: "exact",
284
+ * relation: { type: 'leftOf', text: 'PORTS' }
285
+ * })
286
+ * ```
287
+ * @param {Object} params - Object containing required `text` property and optional properties
288
+ * for regular expression matching and relation.
289
+ * @property {string} params.text - The text to be clicked.
290
+ * @property {string} params.type - Whether the text is matched using similarity,
291
+ * exact match or a regular expression.
292
+ * @property {Object} params.relation - Object describing the relationship between the
293
+ * clicked text and another element.
294
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
295
+ * @property {string} params.relation.text - The label or text associated with the
296
+ * related element or state.
297
+ */
298
+ clickText(params: {
299
+ text: string;
300
+ type: 'similar' | 'exact' | 'regex';
301
+ relation?: {
302
+ type: RelationsForConvenienceMethods;
303
+ text: string;
304
+ };
305
+ }): Promise<void>;
165
306
  }
@@ -8,8 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.UiControlClient = void 0;
16
+ const ValidationError_1 = __importDefault(require("yup/lib/ValidationError"));
13
17
  const custom_element_1 = require("../core/model/custom-element");
14
18
  const dsl_1 = require("./dsl");
15
19
  const annotation_writer_1 = require("../core/annotation/annotation-writer");
@@ -249,16 +253,6 @@ class UiControlClient extends dsl_1.ApiCommands {
249
253
  }
250
254
  });
251
255
  }
252
- /**
253
- * Searches for a text element and clicks it when found.
254
- *
255
- * @param {string} text - A text to be searched.
256
- */
257
- clickText(text) {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- yield this.click().text(text).exec();
260
- });
261
- }
262
256
  /**
263
257
  * Searches for text elements and clicks them
264
258
  * one after another when found.
@@ -273,17 +267,6 @@ class UiControlClient extends dsl_1.ApiCommands {
273
267
  }
274
268
  });
275
269
  }
276
- /**
277
- * Searches for an element of type button
278
- * with a label and clicks it when found.
279
- *
280
- * @param {string} label - The buttons label.
281
- */
282
- clickButton(label) {
283
- return __awaiter(this, void 0, void 0, function* () {
284
- yield this.click().button().withText(label).exec();
285
- });
286
- }
287
270
  /**
288
271
  * Searches for an element of type textfield with a specific placeholder text.
289
272
  * If found, clicks it.
@@ -346,5 +329,220 @@ class UiControlClient extends dsl_1.ApiCommands {
346
329
  }
347
330
  });
348
331
  }
332
+ // eslint-disable-next-line class-methods-use-this
333
+ evaluateRelation(command, relation, text) {
334
+ let commando = command;
335
+ switch (relation) {
336
+ case 'nearestTo':
337
+ commando = command.nearestTo().text(text);
338
+ break;
339
+ case 'leftOf':
340
+ commando = command.leftOf().text(text);
341
+ break;
342
+ case 'above':
343
+ commando = command.above().text(text);
344
+ break;
345
+ case 'rightOf':
346
+ commando = command.rightOf().text(text);
347
+ break;
348
+ case 'below':
349
+ commando = command.below().text(text);
350
+ break;
351
+ case 'contains':
352
+ commando = command.contains().text(text);
353
+ break;
354
+ default:
355
+ throw new ValidationError_1.default('No valid Relation.Type was passed.');
356
+ }
357
+ return commando;
358
+ }
359
+ /**
360
+ * Click a button with a specific label.
361
+ * Optional relation identifies the button in relation to another element.
362
+ *
363
+ * **Examples:**
364
+ * ```typescript
365
+ * await aui.clickButton({})
366
+ * await aui.clickButton({label: 'Checkout here'})
367
+ * await aui.clickButton({relation: {type: 'leftOf', text: 'Choose a ticket'}})
368
+ * await aui.clickButton({label: 'Click', {relation: {type: 'leftOf', text: 'Choose a ticket'}})
369
+ * ```
370
+ *
371
+ * @param {Object} params - Object containing properties.
372
+ * @property {string} [params.label] - The text label of the button. Defaults to an empty string.
373
+ * @property {Object} [params.relation] - Object describing the relationship between
374
+ * the clicked button and another element.
375
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
376
+ * @property {string} params.relation.text - The text element the relation is based on.
377
+ */
378
+ clickButton(params) {
379
+ return __awaiter(this, void 0, void 0, function* () {
380
+ let command = this.click().button();
381
+ if (params.label) {
382
+ command = command.withText(params.label);
383
+ }
384
+ if (params.relation) {
385
+ command = this.evaluateRelation(command, params.relation.type, params.relation.text);
386
+ }
387
+ yield command.exec();
388
+ });
389
+ }
390
+ /**
391
+ * Click a checkbox with a specific label.
392
+ * You can also specify where the label is placed relationally.
393
+ *
394
+ * **Examples:**
395
+ * ```typescript
396
+ * await aui.clickCheckbox({label: 'Toggle'})
397
+ * await aui.clickCheckbox({label: 'Toggle', relation: {type: 'leftOf'}})
398
+ * ```
399
+ *
400
+ * @param {Object} params - Object containing required `label` property and
401
+ * optional `relation` property.
402
+ * @property {string} params.label - The label for the checkbox.
403
+ * @property {Object} params.relation - Object describing the relationship between
404
+ * the clicked checkbox and another element.
405
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
406
+ */
407
+ clickCheckbox(params) {
408
+ return __awaiter(this, void 0, void 0, function* () {
409
+ let command = this.click().checkbox();
410
+ if (!params.relation) {
411
+ command = command.nearestTo().text(params.label);
412
+ }
413
+ else {
414
+ command = this.evaluateRelation(command, params.relation.type, params.label);
415
+ }
416
+ yield command.exec();
417
+ });
418
+ }
419
+ /**
420
+ * Click a switch with a specific label.
421
+ * You can also specify where the label is placed relationally.
422
+ *
423
+ * **Examples:**
424
+ * ```typescript
425
+ * await aui.clickSwitch({label: 'Toggle'})
426
+ * await aui.clickSwitch({label: 'Toggle', relation: {type: 'leftOf'}})
427
+ * ```
428
+ *
429
+ * @param {Object} params - Object containing required `label` property and
430
+ * optional `relation` property.
431
+ * @property {string} params.label - The label for the checkbox.
432
+ * @property {Object} params.relation - Object describing the relationship between
433
+ * the clicked checkbox and another element.
434
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
435
+ */
436
+ clickSwitch(params) {
437
+ return __awaiter(this, void 0, void 0, function* () {
438
+ let command = this.click().switch();
439
+ if (!params.relation) {
440
+ command = command.nearestTo().text(params.label);
441
+ }
442
+ else {
443
+ command = this.evaluateRelation(command, params.relation.type, params.label);
444
+ }
445
+ yield command.exec();
446
+ });
447
+ }
448
+ /**
449
+ * Types a given text into a textfield.
450
+ * Use a relation to specify how to find
451
+ * the textfield in relation to a specific label.
452
+ *
453
+ * **Examples:**
454
+ * ```typescript
455
+ * // Finds the textfield nearest to the label 'Email'
456
+ * await aui.typeIntoTextfield({textToWrite: 'Hello World', relation: {label: 'Email'}});
457
+ *
458
+ * // Finds the textfield above/below a label 'Password'
459
+ * await aui.typeIntoTextfield(
460
+ * {textToWrite: 'Hello World', relation: {type: 'above', label: 'Password'}}
461
+ * );
462
+ * await aui.typeIntoTextfield(
463
+ * {textToWrite: 'Hello World', relation: {type: 'below', label: 'Password'}}
464
+ * );
465
+ *
466
+ * // If there is no label but a placeholder, the label is contained in the textfield
467
+ * await aui.typeIntoTextfield(
468
+ * {textToWrite: 'Hello World', relation: {type: 'contains', label: 'Enter email'}}
469
+ * );
470
+ * ```
471
+ *
472
+ * @param {Object} params - Object containing required `textToWrite` property and
473
+ * optional `relation` property.
474
+ * @property {string} params.textToWrite - The text to be typed into the textfield.
475
+ * @property {Object} params.relation - Object describing the relationship between the
476
+ * textfield being interacted with and another element.
477
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of
478
+ * relation, optional.
479
+ * @property {string} params.relation.label - The label associated with the related
480
+ * element, optional.
481
+ */
482
+ typeIntoTextfield(params) {
483
+ return __awaiter(this, void 0, void 0, function* () {
484
+ let command = this.typeIn(params.textToWrite).textfield();
485
+ if (!params.relation.type) {
486
+ command = command.nearestTo().text(params.relation.label);
487
+ }
488
+ else {
489
+ command = this.evaluateRelation(command, params.relation.type, params.relation.label);
490
+ }
491
+ yield command.exec();
492
+ });
493
+ }
494
+ /**
495
+ * Click on a specific text.
496
+ * You can also use a RegEx or match the text exactly by specifyicing the specific flag.
497
+ * Use a relation to find the text in relation to a specific text.
498
+ *
499
+ * **Examples:**
500
+ * ```typescript
501
+ * // Click text that matches exactly
502
+ * await aui.clickText({text: 'askui', type: 'similar'})
503
+ *
504
+ * // Click text that contains 'pie' or 'cake' or 'Pie' or 'Cake'
505
+ * await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*', type: 'regex'})
506
+ *
507
+ * // Click the text 'TERMINAL' that is left of the text 'Ports'
508
+ * await aui.clickText({
509
+ * text: 'TERMINAL',
510
+ * type: "exact",
511
+ * relation: { type: 'leftOf', text: 'PORTS' }
512
+ * })
513
+ * ```
514
+ * @param {Object} params - Object containing required `text` property and optional properties
515
+ * for regular expression matching and relation.
516
+ * @property {string} params.text - The text to be clicked.
517
+ * @property {string} params.type - Whether the text is matched using similarity,
518
+ * exact match or a regular expression.
519
+ * @property {Object} params.relation - Object describing the relationship between the
520
+ * clicked text and another element.
521
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
522
+ * @property {string} params.relation.text - The label or text associated with the
523
+ * related element or state.
524
+ */
525
+ clickText(params) {
526
+ return __awaiter(this, void 0, void 0, function* () {
527
+ let command = this.click().text();
528
+ switch (params.type) {
529
+ case 'similar':
530
+ command = command.withText(params.text);
531
+ break;
532
+ case 'exact':
533
+ command = command.withExactText(params.text);
534
+ break;
535
+ case 'regex':
536
+ command = command.withTextRegex(params.text);
537
+ break;
538
+ default:
539
+ throw new ValidationError_1.default('"type" must be "similar", "exact" or "regex"');
540
+ }
541
+ if (params.relation) {
542
+ command = this.evaluateRelation(command, params.relation.type, params.relation.text);
543
+ }
544
+ yield command.exec();
545
+ });
546
+ }
349
547
  }
350
548
  exports.UiControlClient = UiControlClient;
@@ -188,7 +188,7 @@ class CreateExampleProject {
188
188
  return __awaiter(this, void 0, void 0, function* () {
189
189
  const runCommand = (0, util_1.promisify)(child_process_1.exec);
190
190
  const frameworkDependencies = {
191
- jest: 'npm i -D @askui/askui-reporters typescript ts-node @types/jest ts-jest jest @askui/jest-allure-circus eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui hpagent',
191
+ jest: 'npm i -D @askui/askui-reporters typescript ts-node @types/jest ts-jest jest @askui/jest-allure-circus eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import @askui/eslint-plugin-askui hpagent',
192
192
  };
193
193
  yield runCommand(frameworkDependencies.jest);
194
194
  });
@@ -1,5 +1,5 @@
1
1
  export { UiController } from './lib';
2
- export { UiControlClient } from './execution';
2
+ export { UiControlClient, RelationsForConvenienceMethods } from './execution';
3
3
  export { Instruction, Reporter, ReporterConfig, Snapshot, SnapshotDetailLevel, Step, StepStatus, StepStatusEnd, } from './core/reporting';
4
4
  export { Annotation } from './core/annotation/annotation';
5
5
  export { DetectedElement } from './core/model/annotation-result/detected-element';
@@ -1 +1 @@
1
- export { UiControlClient } from './ui-control-client';
1
+ export { UiControlClient, RelationsForConvenienceMethods } from './ui-control-client';
@@ -5,6 +5,7 @@ import { Annotation } from '../core/annotation/annotation';
5
5
  import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
6
6
  import { DetectedElement } from '../core/model/annotation-result/detected-element';
7
7
  import { ClientArgs } from './ui-controller-client-interface';
8
+ export declare type RelationsForConvenienceMethods = 'nearestTo' | 'leftOf' | 'above' | 'rightOf' | 'below' | 'contains';
8
9
  export declare class UiControlClient extends ApiCommands {
9
10
  private executionRuntime;
10
11
  private stepReporter;
@@ -108,12 +109,6 @@ export declare class UiControlClient extends ApiCommands {
108
109
  * @param {PC_AND_MODIFIER_KEY[]} keys
109
110
  */
110
111
  pressKeys(keys: PC_AND_MODIFIER_KEY[]): Promise<void>;
111
- /**
112
- * Searches for a text element and clicks it when found.
113
- *
114
- * @param {string} text - A text to be searched.
115
- */
116
- clickText(text: string): Promise<void>;
117
112
  /**
118
113
  * Searches for text elements and clicks them
119
114
  * one after another when found.
@@ -121,13 +116,6 @@ export declare class UiControlClient extends ApiCommands {
121
116
  * @param {string[]} texts - An array of texts to be searched.
122
117
  */
123
118
  clickTexts(texts: string[]): Promise<void>;
124
- /**
125
- * Searches for an element of type button
126
- * with a label and clicks it when found.
127
- *
128
- * @param {string} label - The buttons label.
129
- */
130
- clickButton(label: string): Promise<void>;
131
119
  /**
132
120
  * Searches for an element of type textfield with a specific placeholder text.
133
121
  * If found, clicks it.
@@ -162,4 +150,157 @@ export declare class UiControlClient extends ApiCommands {
162
150
  * @param {number} waitTime - Time in milliseconds
163
151
  */
164
152
  waitUntil(AskUICommand: Executable, maxTry?: number, waitTime?: number): Promise<void>;
153
+ private evaluateRelation;
154
+ /**
155
+ * Click a button with a specific label.
156
+ * Optional relation identifies the button in relation to another element.
157
+ *
158
+ * **Examples:**
159
+ * ```typescript
160
+ * await aui.clickButton({})
161
+ * await aui.clickButton({label: 'Checkout here'})
162
+ * await aui.clickButton({relation: {type: 'leftOf', text: 'Choose a ticket'}})
163
+ * await aui.clickButton({label: 'Click', {relation: {type: 'leftOf', text: 'Choose a ticket'}})
164
+ * ```
165
+ *
166
+ * @param {Object} params - Object containing properties.
167
+ * @property {string} [params.label] - The text label of the button. Defaults to an empty string.
168
+ * @property {Object} [params.relation] - Object describing the relationship between
169
+ * the clicked button and another element.
170
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
171
+ * @property {string} params.relation.text - The text element the relation is based on.
172
+ */
173
+ clickButton(params: {
174
+ label?: string;
175
+ relation?: {
176
+ type: RelationsForConvenienceMethods;
177
+ text: string;
178
+ };
179
+ }): Promise<void>;
180
+ /**
181
+ * Click a checkbox with a specific label.
182
+ * You can also specify where the label is placed relationally.
183
+ *
184
+ * **Examples:**
185
+ * ```typescript
186
+ * await aui.clickCheckbox({label: 'Toggle'})
187
+ * await aui.clickCheckbox({label: 'Toggle', relation: {type: 'leftOf'}})
188
+ * ```
189
+ *
190
+ * @param {Object} params - Object containing required `label` property and
191
+ * optional `relation` property.
192
+ * @property {string} params.label - The label for the checkbox.
193
+ * @property {Object} params.relation - Object describing the relationship between
194
+ * the clicked checkbox and another element.
195
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
196
+ */
197
+ clickCheckbox(params: {
198
+ label: string;
199
+ relation?: {
200
+ type: RelationsForConvenienceMethods;
201
+ };
202
+ }): Promise<void>;
203
+ /**
204
+ * Click a switch with a specific label.
205
+ * You can also specify where the label is placed relationally.
206
+ *
207
+ * **Examples:**
208
+ * ```typescript
209
+ * await aui.clickSwitch({label: 'Toggle'})
210
+ * await aui.clickSwitch({label: 'Toggle', relation: {type: 'leftOf'}})
211
+ * ```
212
+ *
213
+ * @param {Object} params - Object containing required `label` property and
214
+ * optional `relation` property.
215
+ * @property {string} params.label - The label for the checkbox.
216
+ * @property {Object} params.relation - Object describing the relationship between
217
+ * the clicked checkbox and another element.
218
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
219
+ */
220
+ clickSwitch(params: {
221
+ label: string;
222
+ relation?: {
223
+ type: RelationsForConvenienceMethods;
224
+ };
225
+ }): Promise<void>;
226
+ /**
227
+ * Types a given text into a textfield.
228
+ * Use a relation to specify how to find
229
+ * the textfield in relation to a specific label.
230
+ *
231
+ * **Examples:**
232
+ * ```typescript
233
+ * // Finds the textfield nearest to the label 'Email'
234
+ * await aui.typeIntoTextfield({textToWrite: 'Hello World', relation: {label: 'Email'}});
235
+ *
236
+ * // Finds the textfield above/below a label 'Password'
237
+ * await aui.typeIntoTextfield(
238
+ * {textToWrite: 'Hello World', relation: {type: 'above', label: 'Password'}}
239
+ * );
240
+ * await aui.typeIntoTextfield(
241
+ * {textToWrite: 'Hello World', relation: {type: 'below', label: 'Password'}}
242
+ * );
243
+ *
244
+ * // If there is no label but a placeholder, the label is contained in the textfield
245
+ * await aui.typeIntoTextfield(
246
+ * {textToWrite: 'Hello World', relation: {type: 'contains', label: 'Enter email'}}
247
+ * );
248
+ * ```
249
+ *
250
+ * @param {Object} params - Object containing required `textToWrite` property and
251
+ * optional `relation` property.
252
+ * @property {string} params.textToWrite - The text to be typed into the textfield.
253
+ * @property {Object} params.relation - Object describing the relationship between the
254
+ * textfield being interacted with and another element.
255
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of
256
+ * relation, optional.
257
+ * @property {string} params.relation.label - The label associated with the related
258
+ * element, optional.
259
+ */
260
+ typeIntoTextfield(params: {
261
+ textToWrite: string;
262
+ relation: {
263
+ type?: RelationsForConvenienceMethods;
264
+ label: string;
265
+ };
266
+ }): Promise<void>;
267
+ /**
268
+ * Click on a specific text.
269
+ * You can also use a RegEx or match the text exactly by specifyicing the specific flag.
270
+ * Use a relation to find the text in relation to a specific text.
271
+ *
272
+ * **Examples:**
273
+ * ```typescript
274
+ * // Click text that matches exactly
275
+ * await aui.clickText({text: 'askui', type: 'similar'})
276
+ *
277
+ * // Click text that contains 'pie' or 'cake' or 'Pie' or 'Cake'
278
+ * await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*', type: 'regex'})
279
+ *
280
+ * // Click the text 'TERMINAL' that is left of the text 'Ports'
281
+ * await aui.clickText({
282
+ * text: 'TERMINAL',
283
+ * type: "exact",
284
+ * relation: { type: 'leftOf', text: 'PORTS' }
285
+ * })
286
+ * ```
287
+ * @param {Object} params - Object containing required `text` property and optional properties
288
+ * for regular expression matching and relation.
289
+ * @property {string} params.text - The text to be clicked.
290
+ * @property {string} params.type - Whether the text is matched using similarity,
291
+ * exact match or a regular expression.
292
+ * @property {Object} params.relation - Object describing the relationship between the
293
+ * clicked text and another element.
294
+ * @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
295
+ * @property {string} params.relation.text - The label or text associated with the
296
+ * related element or state.
297
+ */
298
+ clickText(params: {
299
+ text: string;
300
+ type: 'similar' | 'exact' | 'regex';
301
+ relation?: {
302
+ type: RelationsForConvenienceMethods;
303
+ text: string;
304
+ };
305
+ }): Promise<void>;
165
306
  }