askui 0.13.0 → 0.14.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 (65) hide show
  1. package/dist/cjs/execution/ui-control-client.d.ts +86 -5
  2. package/dist/cjs/execution/ui-control-client.js +141 -0
  3. package/dist/cjs/lib/interactive_cli/create-example-project.d.ts +1 -1
  4. package/dist/cjs/lib/interactive_cli/create-example-project.js +6 -4
  5. package/dist/esm/execution/ui-control-client.d.ts +86 -5
  6. package/dist/esm/execution/ui-control-client.js +141 -0
  7. package/dist/esm/lib/interactive_cli/create-example-project.d.ts +1 -1
  8. package/dist/esm/lib/interactive_cli/create-example-project.js +6 -4
  9. package/package.json +4 -4
  10. package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +0 -75
  11. package/dist/cjs/core/model/test-case-dto/custom-element-json.js +0 -2
  12. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +0 -21
  13. package/dist/cjs/core/model/test-case-dto/custom-element.js +0 -54
  14. package/dist/cjs/core/model/test-case-dto/index.d.ts +0 -3
  15. package/dist/cjs/core/model/test-case-dto/index.js +0 -5
  16. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +0 -6
  17. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -2
  18. package/dist/cjs/core/model/test-case-result-dto/index.d.ts +0 -2
  19. package/dist/cjs/core/model/test-case-result-dto/index.js +0 -7
  20. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
  21. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +0 -16
  22. package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
  23. package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +0 -8
  24. package/dist/cjs/core/reporting/default-reporter.d.ts +0 -10
  25. package/dist/cjs/core/reporting/default-reporter.js +0 -12
  26. package/dist/cjs/execution/annotation-level.d.ts +0 -5
  27. package/dist/cjs/execution/annotation-level.js +0 -9
  28. package/dist/cjs/execution/ui-control-client-error.d.ts +0 -2
  29. package/dist/cjs/execution/ui-control-client-error.js +0 -6
  30. package/dist/cjs/lib/copy-example-project.d.ts +0 -2
  31. package/dist/cjs/lib/copy-example-project.js +0 -65
  32. package/dist/cjs/lib/interactive_cli/replace-string-in-file.d.ts +0 -1
  33. package/dist/cjs/lib/interactive_cli/replace-string-in-file.js +0 -31
  34. package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +0 -75
  35. package/dist/esm/core/model/test-case-dto/custom-element-json.js +0 -1
  36. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +0 -21
  37. package/dist/esm/core/model/test-case-dto/custom-element.js +0 -50
  38. package/dist/esm/core/model/test-case-dto/index.d.ts +0 -3
  39. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  40. package/dist/esm/core/model/test-case-dto/test-step.d.ts +0 -6
  41. package/dist/esm/core/model/test-case-dto/test-step.js +0 -1
  42. package/dist/esm/core/model/test-case-result-dto/index.d.ts +0 -2
  43. package/dist/esm/core/model/test-case-result-dto/index.js +0 -2
  44. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
  45. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +0 -12
  46. package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
  47. package/dist/esm/core/model/test-case-result-dto/test-step-state.js +0 -5
  48. package/dist/esm/core/reporting/default-reporter.d.ts +0 -10
  49. package/dist/esm/core/reporting/default-reporter.js +0 -9
  50. package/dist/esm/execution/annotation-level.d.ts +0 -5
  51. package/dist/esm/execution/annotation-level.js +0 -6
  52. package/dist/esm/execution/ui-control-client-error.d.ts +0 -2
  53. package/dist/esm/execution/ui-control-client-error.js +0 -2
  54. package/dist/esm/lib/copy-example-project.d.ts +0 -2
  55. package/dist/esm/lib/copy-example-project.js +0 -58
  56. package/dist/esm/lib/interactive_cli/replace-string-in-file.d.ts +0 -1
  57. package/dist/esm/lib/interactive_cli/replace-string-in-file.js +0 -24
  58. package/dist/example_projects_templates/typescript/.eslintignore +0 -1
  59. package/dist/example_projects_templates/typescript/.eslintrc.json +0 -20
  60. package/dist/example_projects_templates/typescript/askui_example/helpers/askui-helper.ts +0 -39
  61. package/dist/example_projects_templates/typescript_jest/test/README.md +0 -21
  62. package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +0 -51
  63. package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +0 -13
  64. package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +0 -21
  65. package/dist/example_projects_templates/typescript_jest/tsconfig.json +0 -7
@@ -1,5 +1,5 @@
1
1
  import { CustomElementJson } from '../core/model/custom-element-json';
2
- import { Exec, Executable, FluentFilters, ApiCommands } from './dsl';
2
+ import { Exec, Executable, FluentFilters, ApiCommands, PC_AND_MODIFIER_KEY } from './dsl';
3
3
  import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
4
4
  import { Annotation } from '../core/annotation/annotation';
5
5
  import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
@@ -56,8 +56,8 @@ export declare class UiControlClient extends ApiCommands {
56
56
  * @return {FluentFilters}
57
57
  */
58
58
  typeIn(text: string, { isSecret, secretMask }?: {
59
- isSecret?: boolean | undefined;
60
- secretMask?: string | undefined;
59
+ isSecret?: boolean;
60
+ secretMask?: string;
61
61
  }): FluentFilters;
62
62
  /**
63
63
  * Types a text at the current position.
@@ -78,8 +78,8 @@ export declare class UiControlClient extends ApiCommands {
78
78
  * @return {Exec}
79
79
  */
80
80
  type(text: string, { isSecret, secretMask }?: {
81
- isSecret?: boolean | undefined;
82
- secretMask?: string | undefined;
81
+ isSecret?: boolean;
82
+ secretMask?: string;
83
83
  }): Exec;
84
84
  /**
85
85
  * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
@@ -90,4 +90,85 @@ export declare class UiControlClient extends ApiCommands {
90
90
  * @return {Executable}
91
91
  */
92
92
  waitFor(delayInMs: number): Executable;
93
+ /**
94
+ * Press a key multiple times. At least two times.
95
+ *
96
+ * @param {PC_AND_MODIFIER_KEY} key
97
+ *
98
+ * @param {number} times
99
+ */
100
+ pressKeyNTimes(key: PC_AND_MODIFIER_KEY, times?: number): Promise<void>;
101
+ /**
102
+ * Press an array of keys one after another.
103
+ *
104
+ * For example press the following keys: right, left, enter.
105
+ *
106
+ * pressKeys(['right', 'left', 'enter'])
107
+ *
108
+ * @param {PC_AND_MODIFIER_KEY[]} keys
109
+ */
110
+ 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
+ /**
118
+ * Searches for text elements and clicks them
119
+ * one after another when found.
120
+ *
121
+ * @param {string[]} texts - An array of texts to be searched.
122
+ */
123
+ 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
+ /**
132
+ * Searches for an element of type textfield with a specific placeholder text.
133
+ * If found, clicks it.
134
+ *
135
+ * @param {string} placeholder - The textfields placeholder text.
136
+ */
137
+ clickTextfield(placeholder: string): Promise<void>;
138
+ /**
139
+ * Clicks an icon based on a description.
140
+ *
141
+ * @param {string} description
142
+ */
143
+ clickIcon(description: string): Promise<void>;
144
+ /**
145
+ * Drags element1 to element2.
146
+ *
147
+ * Both must be a `moveMouse()` or `moveMouseTo()`
148
+ * instruction as in the example below.
149
+ *
150
+ * Usage example:
151
+ * dragTo(
152
+ * aui.moveMouseTo().text('AskUI'),
153
+ * aui.moveMouseTo().text('UI Automation')
154
+ * )
155
+ *
156
+ * @param {Executable} element1
157
+ * @param {Executable} element2
158
+ */
159
+ dragTo(element1: Executable, element2: Executable): Promise<void>;
160
+ /**
161
+ * Wait until an AskUICommand does not fail.
162
+ *
163
+ * Use it to wait for an element to appear like this:
164
+ *
165
+ * await waitUntil(
166
+ * aui.expect().text('Github').exists()
167
+ * );
168
+ *
169
+ * @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
170
+ * @param {number} maxTry - Number of maximum retries
171
+ * @param {number} waitTime - Time in milliseconds
172
+ */
173
+ waitUntil(AskUICommand: Executable, maxTry?: number, waitTime?: number): Promise<void>;
93
174
  }
@@ -217,5 +217,146 @@ class UiControlClient extends dsl_1.ApiCommands {
217
217
  },
218
218
  };
219
219
  }
220
+ /**
221
+ * Press a key multiple times. At least two times.
222
+ *
223
+ * @param {PC_AND_MODIFIER_KEY} key
224
+ *
225
+ * @param {number} times
226
+ */
227
+ pressKeyNTimes(key, times = 2) {
228
+ return __awaiter(this, void 0, void 0, function* () {
229
+ /* eslint-disable no-await-in-loop */
230
+ for (let i = 0; i < times; i += 1) {
231
+ yield this.pressKey(key).exec();
232
+ }
233
+ });
234
+ }
235
+ /**
236
+ * Press an array of keys one after another.
237
+ *
238
+ * For example press the following keys: right, left, enter.
239
+ *
240
+ * pressKeys(['right', 'left', 'enter'])
241
+ *
242
+ * @param {PC_AND_MODIFIER_KEY[]} keys
243
+ */
244
+ pressKeys(keys) {
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ /* eslint-disable no-await-in-loop */
247
+ for (let i = 0; i < keys.length; i += 1) {
248
+ yield this.pressKey(keys[i]).exec();
249
+ }
250
+ });
251
+ }
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
+ /**
263
+ * Searches for text elements and clicks them
264
+ * one after another when found.
265
+ *
266
+ * @param {string[]} texts - An array of texts to be searched.
267
+ */
268
+ clickTexts(texts) {
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ /* eslint-disable no-await-in-loop */
271
+ for (let i = 0; i < texts.length; i += 1) {
272
+ yield this.click().text(texts[i]).exec();
273
+ }
274
+ });
275
+ }
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
+ /**
288
+ * Searches for an element of type textfield with a specific placeholder text.
289
+ * If found, clicks it.
290
+ *
291
+ * @param {string} placeholder - The textfields placeholder text.
292
+ */
293
+ clickTextfield(placeholder) {
294
+ return __awaiter(this, void 0, void 0, function* () {
295
+ yield this.click().textfield().contains().text()
296
+ .withText(placeholder)
297
+ .exec();
298
+ });
299
+ }
300
+ /**
301
+ * Clicks an icon based on a description.
302
+ *
303
+ * @param {string} description
304
+ */
305
+ clickIcon(description) {
306
+ return __awaiter(this, void 0, void 0, function* () {
307
+ yield this.click().icon().matching(description).exec();
308
+ });
309
+ }
310
+ /**
311
+ * Drags element1 to element2.
312
+ *
313
+ * Both must be a `moveMouse()` or `moveMouseTo()`
314
+ * instruction as in the example below.
315
+ *
316
+ * Usage example:
317
+ * dragTo(
318
+ * aui.moveMouseTo().text('AskUI'),
319
+ * aui.moveMouseTo().text('UI Automation')
320
+ * )
321
+ *
322
+ * @param {Executable} element1
323
+ * @param {Executable} element2
324
+ */
325
+ dragTo(element1, element2) {
326
+ return __awaiter(this, void 0, void 0, function* () {
327
+ yield element1.exec();
328
+ yield this.mouseLeftClick().exec();
329
+ yield this.mouseToggleDown().exec();
330
+ yield element2.exec();
331
+ yield this.mouseToggleUp().exec();
332
+ });
333
+ }
334
+ /**
335
+ * Wait until an AskUICommand does not fail.
336
+ *
337
+ * Use it to wait for an element to appear like this:
338
+ *
339
+ * await waitUntil(
340
+ * aui.expect().text('Github').exists()
341
+ * );
342
+ *
343
+ * @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
344
+ * @param {number} maxTry - Number of maximum retries
345
+ * @param {number} waitTime - Time in milliseconds
346
+ */
347
+ waitUntil(AskUICommand, maxTry = 5, waitTime = 2000) {
348
+ return __awaiter(this, void 0, void 0, function* () {
349
+ try {
350
+ yield AskUICommand.exec();
351
+ }
352
+ catch (error) {
353
+ if (maxTry === 0) {
354
+ throw error;
355
+ }
356
+ yield this.waitFor(waitTime).exec();
357
+ yield this.waitUntil(AskUICommand, maxTry - 1);
358
+ }
359
+ });
360
+ }
220
361
  }
221
362
  exports.UiControlClient = UiControlClient;
@@ -17,7 +17,7 @@ export declare class CreateExampleProject {
17
17
  private createAskUIHelperFromTemplate;
18
18
  private setupTestFrameWork;
19
19
  private installTestFrameworkPackages;
20
- private addUserCredentails;
20
+ private addUserCredentials;
21
21
  private copyESLintConfigFiles;
22
22
  private copyTsConfigFile;
23
23
  private installProxy;
@@ -129,7 +129,9 @@ class CreateExampleProject {
129
129
  nunjucks_1.default.configure(askuiHelperTemplateFilePath, { autoescape: false });
130
130
  const result = nunjucks_1.default.render(templateFileName, this.helperTemplateConfig);
131
131
  const filePath = path_1.default.join(this.distexampleFolderPath, 'helpers', 'askui-helper.ts');
132
- yield fs_extra_1.default.mkdir(path_1.default.join(this.distexampleFolderPath, 'helpers'));
132
+ if (!fs_extra_1.default.existsSync(path_1.default.join(this.distexampleFolderPath, 'helpers'))) {
133
+ yield fs_extra_1.default.mkdir(path_1.default.join(this.distexampleFolderPath, 'helpers'));
134
+ }
133
135
  yield fs_extra_1.default.writeFile(filePath, result, 'utf8');
134
136
  }),
135
137
  },
@@ -183,10 +185,10 @@ class CreateExampleProject {
183
185
  yield runCommand(frameworkDepencies[this.cliOptions.testFramework]);
184
186
  });
185
187
  }
186
- addUserCredentails() {
188
+ addUserCredentials() {
187
189
  return __awaiter(this, void 0, void 0, function* () {
188
190
  return [{
189
- title: 'Add user credentails',
191
+ title: 'Add user credentials',
190
192
  task: () => __awaiter(this, void 0, void 0, function* () {
191
193
  return new listr_1.default([
192
194
  {
@@ -270,7 +272,7 @@ class CreateExampleProject {
270
272
  ...yield this.setupTestFrameWork(),
271
273
  ...yield this.copyESLintConfigFiles(),
272
274
  ...yield this.copyTsConfigFile(),
273
- ...yield this.addUserCredentails(),
275
+ ...yield this.addUserCredentials(),
274
276
  ...yield this.createAskUIHelperFromTemplate(),
275
277
  ...yield this.installProxy(),
276
278
  ]);
@@ -1,5 +1,5 @@
1
1
  import { CustomElementJson } from '../core/model/custom-element-json';
2
- import { Exec, Executable, FluentFilters, ApiCommands } from './dsl';
2
+ import { Exec, Executable, FluentFilters, ApiCommands, PC_AND_MODIFIER_KEY } from './dsl';
3
3
  import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
4
4
  import { Annotation } from '../core/annotation/annotation';
5
5
  import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
@@ -56,8 +56,8 @@ export declare class UiControlClient extends ApiCommands {
56
56
  * @return {FluentFilters}
57
57
  */
58
58
  typeIn(text: string, { isSecret, secretMask }?: {
59
- isSecret?: boolean | undefined;
60
- secretMask?: string | undefined;
59
+ isSecret?: boolean;
60
+ secretMask?: string;
61
61
  }): FluentFilters;
62
62
  /**
63
63
  * Types a text at the current position.
@@ -78,8 +78,8 @@ export declare class UiControlClient extends ApiCommands {
78
78
  * @return {Exec}
79
79
  */
80
80
  type(text: string, { isSecret, secretMask }?: {
81
- isSecret?: boolean | undefined;
82
- secretMask?: string | undefined;
81
+ isSecret?: boolean;
82
+ secretMask?: string;
83
83
  }): Exec;
84
84
  /**
85
85
  * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
@@ -90,4 +90,85 @@ export declare class UiControlClient extends ApiCommands {
90
90
  * @return {Executable}
91
91
  */
92
92
  waitFor(delayInMs: number): Executable;
93
+ /**
94
+ * Press a key multiple times. At least two times.
95
+ *
96
+ * @param {PC_AND_MODIFIER_KEY} key
97
+ *
98
+ * @param {number} times
99
+ */
100
+ pressKeyNTimes(key: PC_AND_MODIFIER_KEY, times?: number): Promise<void>;
101
+ /**
102
+ * Press an array of keys one after another.
103
+ *
104
+ * For example press the following keys: right, left, enter.
105
+ *
106
+ * pressKeys(['right', 'left', 'enter'])
107
+ *
108
+ * @param {PC_AND_MODIFIER_KEY[]} keys
109
+ */
110
+ 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
+ /**
118
+ * Searches for text elements and clicks them
119
+ * one after another when found.
120
+ *
121
+ * @param {string[]} texts - An array of texts to be searched.
122
+ */
123
+ 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
+ /**
132
+ * Searches for an element of type textfield with a specific placeholder text.
133
+ * If found, clicks it.
134
+ *
135
+ * @param {string} placeholder - The textfields placeholder text.
136
+ */
137
+ clickTextfield(placeholder: string): Promise<void>;
138
+ /**
139
+ * Clicks an icon based on a description.
140
+ *
141
+ * @param {string} description
142
+ */
143
+ clickIcon(description: string): Promise<void>;
144
+ /**
145
+ * Drags element1 to element2.
146
+ *
147
+ * Both must be a `moveMouse()` or `moveMouseTo()`
148
+ * instruction as in the example below.
149
+ *
150
+ * Usage example:
151
+ * dragTo(
152
+ * aui.moveMouseTo().text('AskUI'),
153
+ * aui.moveMouseTo().text('UI Automation')
154
+ * )
155
+ *
156
+ * @param {Executable} element1
157
+ * @param {Executable} element2
158
+ */
159
+ dragTo(element1: Executable, element2: Executable): Promise<void>;
160
+ /**
161
+ * Wait until an AskUICommand does not fail.
162
+ *
163
+ * Use it to wait for an element to appear like this:
164
+ *
165
+ * await waitUntil(
166
+ * aui.expect().text('Github').exists()
167
+ * );
168
+ *
169
+ * @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
170
+ * @param {number} maxTry - Number of maximum retries
171
+ * @param {number} waitTime - Time in milliseconds
172
+ */
173
+ waitUntil(AskUICommand: Executable, maxTry?: number, waitTime?: number): Promise<void>;
93
174
  }
@@ -214,4 +214,145 @@ export class UiControlClient extends ApiCommands {
214
214
  },
215
215
  };
216
216
  }
217
+ /**
218
+ * Press a key multiple times. At least two times.
219
+ *
220
+ * @param {PC_AND_MODIFIER_KEY} key
221
+ *
222
+ * @param {number} times
223
+ */
224
+ pressKeyNTimes(key, times = 2) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ /* eslint-disable no-await-in-loop */
227
+ for (let i = 0; i < times; i += 1) {
228
+ yield this.pressKey(key).exec();
229
+ }
230
+ });
231
+ }
232
+ /**
233
+ * Press an array of keys one after another.
234
+ *
235
+ * For example press the following keys: right, left, enter.
236
+ *
237
+ * pressKeys(['right', 'left', 'enter'])
238
+ *
239
+ * @param {PC_AND_MODIFIER_KEY[]} keys
240
+ */
241
+ pressKeys(keys) {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ /* eslint-disable no-await-in-loop */
244
+ for (let i = 0; i < keys.length; i += 1) {
245
+ yield this.pressKey(keys[i]).exec();
246
+ }
247
+ });
248
+ }
249
+ /**
250
+ * Searches for a text element and clicks it when found.
251
+ *
252
+ * @param {string} text - A text to be searched.
253
+ */
254
+ clickText(text) {
255
+ return __awaiter(this, void 0, void 0, function* () {
256
+ yield this.click().text(text).exec();
257
+ });
258
+ }
259
+ /**
260
+ * Searches for text elements and clicks them
261
+ * one after another when found.
262
+ *
263
+ * @param {string[]} texts - An array of texts to be searched.
264
+ */
265
+ clickTexts(texts) {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ /* eslint-disable no-await-in-loop */
268
+ for (let i = 0; i < texts.length; i += 1) {
269
+ yield this.click().text(texts[i]).exec();
270
+ }
271
+ });
272
+ }
273
+ /**
274
+ * Searches for an element of type button
275
+ * with a label and clicks it when found.
276
+ *
277
+ * @param {string} label - The buttons label.
278
+ */
279
+ clickButton(label) {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ yield this.click().button().withText(label).exec();
282
+ });
283
+ }
284
+ /**
285
+ * Searches for an element of type textfield with a specific placeholder text.
286
+ * If found, clicks it.
287
+ *
288
+ * @param {string} placeholder - The textfields placeholder text.
289
+ */
290
+ clickTextfield(placeholder) {
291
+ return __awaiter(this, void 0, void 0, function* () {
292
+ yield this.click().textfield().contains().text()
293
+ .withText(placeholder)
294
+ .exec();
295
+ });
296
+ }
297
+ /**
298
+ * Clicks an icon based on a description.
299
+ *
300
+ * @param {string} description
301
+ */
302
+ clickIcon(description) {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ yield this.click().icon().matching(description).exec();
305
+ });
306
+ }
307
+ /**
308
+ * Drags element1 to element2.
309
+ *
310
+ * Both must be a `moveMouse()` or `moveMouseTo()`
311
+ * instruction as in the example below.
312
+ *
313
+ * Usage example:
314
+ * dragTo(
315
+ * aui.moveMouseTo().text('AskUI'),
316
+ * aui.moveMouseTo().text('UI Automation')
317
+ * )
318
+ *
319
+ * @param {Executable} element1
320
+ * @param {Executable} element2
321
+ */
322
+ dragTo(element1, element2) {
323
+ return __awaiter(this, void 0, void 0, function* () {
324
+ yield element1.exec();
325
+ yield this.mouseLeftClick().exec();
326
+ yield this.mouseToggleDown().exec();
327
+ yield element2.exec();
328
+ yield this.mouseToggleUp().exec();
329
+ });
330
+ }
331
+ /**
332
+ * Wait until an AskUICommand does not fail.
333
+ *
334
+ * Use it to wait for an element to appear like this:
335
+ *
336
+ * await waitUntil(
337
+ * aui.expect().text('Github').exists()
338
+ * );
339
+ *
340
+ * @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
341
+ * @param {number} maxTry - Number of maximum retries
342
+ * @param {number} waitTime - Time in milliseconds
343
+ */
344
+ waitUntil(AskUICommand, maxTry = 5, waitTime = 2000) {
345
+ return __awaiter(this, void 0, void 0, function* () {
346
+ try {
347
+ yield AskUICommand.exec();
348
+ }
349
+ catch (error) {
350
+ if (maxTry === 0) {
351
+ throw error;
352
+ }
353
+ yield this.waitFor(waitTime).exec();
354
+ yield this.waitUntil(AskUICommand, maxTry - 1);
355
+ }
356
+ });
357
+ }
217
358
  }
@@ -17,7 +17,7 @@ export declare class CreateExampleProject {
17
17
  private createAskUIHelperFromTemplate;
18
18
  private setupTestFrameWork;
19
19
  private installTestFrameworkPackages;
20
- private addUserCredentails;
20
+ private addUserCredentials;
21
21
  private copyESLintConfigFiles;
22
22
  private copyTsConfigFile;
23
23
  private installProxy;
@@ -123,7 +123,9 @@ export class CreateExampleProject {
123
123
  nunjucks.configure(askuiHelperTemplateFilePath, { autoescape: false });
124
124
  const result = nunjucks.render(templateFileName, this.helperTemplateConfig);
125
125
  const filePath = path.join(this.distexampleFolderPath, 'helpers', 'askui-helper.ts');
126
- yield fs.mkdir(path.join(this.distexampleFolderPath, 'helpers'));
126
+ if (!fs.existsSync(path.join(this.distexampleFolderPath, 'helpers'))) {
127
+ yield fs.mkdir(path.join(this.distexampleFolderPath, 'helpers'));
128
+ }
127
129
  yield fs.writeFile(filePath, result, 'utf8');
128
130
  }),
129
131
  },
@@ -177,10 +179,10 @@ export class CreateExampleProject {
177
179
  yield runCommand(frameworkDepencies[this.cliOptions.testFramework]);
178
180
  });
179
181
  }
180
- addUserCredentails() {
182
+ addUserCredentials() {
181
183
  return __awaiter(this, void 0, void 0, function* () {
182
184
  return [{
183
- title: 'Add user credentails',
185
+ title: 'Add user credentials',
184
186
  task: () => __awaiter(this, void 0, void 0, function* () {
185
187
  return new Listr([
186
188
  {
@@ -264,7 +266,7 @@ export class CreateExampleProject {
264
266
  ...yield this.setupTestFrameWork(),
265
267
  ...yield this.copyESLintConfigFiles(),
266
268
  ...yield this.copyTsConfigFile(),
267
- ...yield this.addUserCredentails(),
269
+ ...yield this.addUserCredentials(),
268
270
  ...yield this.createAskUIHelperFromTemplate(),
269
271
  ...yield this.installProxy(),
270
272
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askui",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "license": "MIT",
5
5
  "author": "askui GmbH <info@askui.com> (http://www.askui.com/)",
6
6
  "description": "Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on",
@@ -62,10 +62,10 @@
62
62
  "nunjucks": "^3.2.4",
63
63
  "pino": "7.8.1",
64
64
  "pino-pretty": "7.5.3",
65
- "tough-cookie": "4.1.2",
65
+ "tough-cookie": "^4.1.3",
66
66
  "url-join": "4.0.1",
67
67
  "wait-port": "0.2.9",
68
- "ws": "7.4.4",
68
+ "ws": "^7.5.9",
69
69
  "yup": "0.32.11"
70
70
  },
71
71
  "devDependencies": {
@@ -84,7 +84,7 @@
84
84
  "jest": "28.1.1",
85
85
  "jest-extended": "^4.0.1",
86
86
  "proxy": "^1.0.2",
87
- "proxy-agent": "^5.0.0",
87
+ "proxy-agent": "^6.3.1",
88
88
  "shx": "0.3.4",
89
89
  "ts-jest": "28.0.4",
90
90
  "typescript": "4.5.4"