askui 0.2.0 → 0.2.3

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 (79) hide show
  1. package/README.md +2 -2
  2. package/bin/askui-postinstall +35 -0
  3. package/dist/cjs/core/model/test-case-dto/index.js +1 -3
  4. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +3 -7
  5. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -12
  6. package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -0
  7. package/dist/cjs/core/ui-control-commands/control-command.js +5 -0
  8. package/dist/cjs/core/ui-control-commands/input-event.d.ts +1 -2
  9. package/dist/cjs/core/ui-control-commands/input-event.js +0 -1
  10. package/dist/cjs/execution/dsl.d.ts +51 -1
  11. package/dist/cjs/execution/dsl.js +67 -10
  12. package/dist/cjs/execution/execution-runtime.d.ts +2 -0
  13. package/dist/cjs/execution/execution-runtime.js +27 -15
  14. package/dist/cjs/execution/inference-client.d.ts +1 -1
  15. package/dist/cjs/execution/inference-client.js +1 -1
  16. package/dist/cjs/execution/read-environment-credentials.js +4 -4
  17. package/dist/cjs/execution/read-environment-credentials.spec.js +2 -2
  18. package/dist/cjs/execution/ui-control-client.d.ts +46 -1
  19. package/dist/cjs/execution/ui-control-client.js +56 -6
  20. package/dist/cjs/execution/ui-controller-client-interface.d.ts +1 -1
  21. package/dist/cjs/lib/copy-example-project.js +2 -1
  22. package/dist/cjs/lib/download-binaries.js +2 -1
  23. package/dist/cjs/lib/ui-controller-facade.js +1 -1
  24. package/dist/cjs/lib/ui-controller-linux.js +2 -2
  25. package/dist/cjs/utils/analytics/analytics.js +7 -1
  26. package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  27. package/dist/cjs/utils/analytics/installation-timestamp-create-error.js +9 -0
  28. package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  29. package/dist/cjs/utils/analytics/installation-timestamp-get-error.js +9 -0
  30. package/dist/cjs/utils/analytics/installation-timestamp.d.ts +7 -0
  31. package/dist/cjs/utils/analytics/installation-timestamp.js +68 -0
  32. package/dist/cjs/utils/http/credentials.d.ts +1 -1
  33. package/dist/cjs/utils/http/credentials.js +1 -1
  34. package/dist/cjs/utils/http/credentials.spec.js +2 -2
  35. package/dist/cjs/utils/path.d.ts +1 -0
  36. package/dist/cjs/utils/path.js +11 -0
  37. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  38. package/dist/esm/core/model/test-case-dto/test-step.d.ts +3 -7
  39. package/dist/esm/core/model/test-case-dto/test-step.js +1 -10
  40. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -0
  41. package/dist/esm/core/ui-control-commands/control-command.js +5 -0
  42. package/dist/esm/core/ui-control-commands/input-event.d.ts +1 -2
  43. package/dist/esm/core/ui-control-commands/input-event.js +0 -1
  44. package/dist/esm/execution/dsl.d.ts +51 -1
  45. package/dist/esm/execution/dsl.js +67 -10
  46. package/dist/esm/execution/execution-runtime.d.ts +2 -0
  47. package/dist/esm/execution/execution-runtime.js +27 -15
  48. package/dist/esm/execution/inference-client.d.ts +1 -1
  49. package/dist/esm/execution/inference-client.js +1 -1
  50. package/dist/esm/execution/read-environment-credentials.js +4 -4
  51. package/dist/esm/execution/read-environment-credentials.spec.js +2 -2
  52. package/dist/esm/execution/ui-control-client.d.ts +46 -1
  53. package/dist/esm/execution/ui-control-client.js +57 -7
  54. package/dist/esm/execution/ui-controller-client-interface.d.ts +1 -1
  55. package/dist/esm/lib/copy-example-project.js +2 -1
  56. package/dist/esm/lib/download-binaries.js +2 -1
  57. package/dist/esm/lib/ui-controller-facade.js +1 -1
  58. package/dist/esm/lib/ui-controller-linux.js +2 -2
  59. package/dist/esm/utils/analytics/analytics.js +7 -1
  60. package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  61. package/dist/esm/utils/analytics/installation-timestamp-create-error.js +5 -0
  62. package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  63. package/dist/esm/utils/analytics/installation-timestamp-get-error.js +5 -0
  64. package/dist/esm/utils/analytics/installation-timestamp.d.ts +7 -0
  65. package/dist/esm/utils/analytics/installation-timestamp.js +61 -0
  66. package/dist/esm/utils/http/credentials.d.ts +1 -1
  67. package/dist/esm/utils/http/credentials.js +1 -1
  68. package/dist/esm/utils/http/credentials.spec.js +2 -2
  69. package/dist/esm/utils/path.d.ts +1 -0
  70. package/dist/esm/utils/path.js +4 -0
  71. package/package.json +12 -4
  72. package/dist/cjs/utils/base_64_image/base-64-image-path-error.d.ts +0 -4
  73. package/dist/cjs/utils/base_64_image/base-64-image-path-error.js +0 -11
  74. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  75. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.js +0 -7
  76. package/dist/esm/utils/base_64_image/base-64-image-path-error.d.ts +0 -4
  77. package/dist/esm/utils/base_64_image/base-64-image-path-error.js +0 -7
  78. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  79. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.js +0 -3
@@ -23,12 +23,13 @@ const annotation_level_1 = require("./annotation-level");
23
23
  const ui_control_client_error_1 = require("./ui-control-client-error");
24
24
  const read_environment_credentials_1 = require("./read-environment-credentials");
25
25
  const analytics_1 = require("../utils/analytics");
26
- const getClientArgsWithDefaults = (clientArgs = {}) => (Object.assign({ uiControllerUrl: 'http://localhost:6769', inferenceServerUrl: 'https://inference.askui.com', annotationLevel: annotation_level_1.AnnotationLevel.DISABLED }, clientArgs));
26
+ const getClientArgsWithDefaults = (clientArgs = {}) => (Object.assign({ uiControllerUrl: 'http://127.0.0.1:6769', inferenceServerUrl: 'https://inference.askui.com', annotationLevel: annotation_level_1.AnnotationLevel.DISABLED }, clientArgs));
27
27
  class UiControlClient extends dsl_1.FluentCommand {
28
28
  constructor(httpClient, clientArgs) {
29
29
  super();
30
30
  this.httpClient = httpClient;
31
31
  this.clientArgs = clientArgs;
32
+ this.secretText = undefined;
32
33
  }
33
34
  static build(clientArgs) {
34
35
  return __awaiter(this, void 0, void 0, function* () {
@@ -88,16 +89,15 @@ class UiControlClient extends dsl_1.FluentCommand {
88
89
  }
89
90
  });
90
91
  }
91
- exec(instruction, customElementJson) {
92
+ exec(instruction, customElementJson = []) {
92
93
  return __awaiter(this, void 0, void 0, function* () {
93
- let customElements = [];
94
- if (customElementJson !== undefined) {
95
- customElements = yield test_case_dto_1.CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
96
- }
94
+ const customElements = yield test_case_dto_1.CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
95
+ const { secretText } = this;
97
96
  try {
98
97
  yield this.executionRuntime.executeTestStep({
99
98
  instruction,
100
99
  customElements,
100
+ secretText,
101
101
  });
102
102
  yield this.annotateByDefault(test_case_result_dto_1.TestStepState.PASSED, customElements);
103
103
  return yield Promise.resolve();
@@ -108,6 +108,56 @@ class UiControlClient extends dsl_1.FluentCommand {
108
108
  }
109
109
  });
110
110
  }
111
+ /**
112
+ * Types a text inside the filtered element.
113
+ *
114
+ * By default, the `text` is included in the logs and sent over to the askui Inference server to
115
+ * predict in which context the typing has to occur. You can exclude the `text` from the logs
116
+ * and the request to the askui Inference server setting `options.isSecret` to `true`.
117
+ * This should not change the quality of the prediction of the askui Inference server. In this
118
+ * case, `options.secretMask` is included in logs and sent over instead of the `text`.
119
+ *
120
+ * @param {string} text - A text to type.
121
+ * @param {Object} [options]
122
+ * @param {boolean} [options.isSecret = false] - If set to `true`, `text` is neither included in
123
+ * logs of askui nor sent over to askui Inference for prediction.
124
+ * @param {string} [options.secretMask = '****'] - If `options.isSecret` is set to `true`, this
125
+ * is included in logs and sent over to askui Inference for prediction instead of the `text`.
126
+ *
127
+ * @return {FluentFilters}
128
+ */
129
+ typeIn(text, { isSecret = false, secretMask = '****' } = {}) {
130
+ if (isSecret) {
131
+ this.secretText = text;
132
+ return super.typeIn(secretMask);
133
+ }
134
+ return super.typeIn(text);
135
+ }
136
+ /**
137
+ * Types a text at the current position.
138
+ *
139
+ * By default, the `text` is included in the logs and sent over to the askui Inference server to
140
+ * predict in which context the typing has to occur. You can exclude the `text` from the logs
141
+ * and the request to the askui Inference server setting `options.isSecret` to `true`.
142
+ * This should not change the quality of the prediction of the askui Inference server. In this
143
+ * case, `options.secretMask` is included in logs and sent over instead of the `text`.
144
+ *
145
+ * @param {string} text - A text to type.
146
+ * @param {Object} options
147
+ * @param {boolean} [options.isSecret = false] - If set to `true`, `text` is neither included in
148
+ * logs of askui nor sent over to askui Inference for prediction.
149
+ * @param {string} [options.secretMask = '****'] - If `options.isSecret` is set to `true`, this
150
+ * is included in logs and sent over to askui Inference for prediction instead of the `text`.
151
+ *
152
+ * @return {Exec}
153
+ */
154
+ type(text, { isSecret = false, secretMask = '****' } = {}) {
155
+ if (isSecret) {
156
+ this.secretText = text;
157
+ return super.type(secretMask);
158
+ }
159
+ return super.type(text);
160
+ }
111
161
  /**
112
162
  * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
113
163
  * than `<delayInMs>` but never shorter than that.
@@ -3,7 +3,7 @@ import { AnnotationLevel } from './annotation-level';
3
3
  /**
4
4
  * Configuration options for the askui UI Control Client
5
5
  *
6
- * @param {string} uiControllerUrl - Default: http://localhost:6769
6
+ * @param {string} uiControllerUrl - Default: http://127.0.0.1:6769
7
7
  * The adress of the askui UI Controller server.
8
8
  * @param {string} inferenceClientUrl - Default: https://inference.askui.com`
9
9
  * Address of the askui Inference server.
@@ -7,6 +7,7 @@ exports.init = void 0;
7
7
  const commander_1 = require("commander");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const path_2 = require("../utils/path");
10
11
  const createProgram = () => {
11
12
  const program = new commander_1.Command('askui');
12
13
  program.usage('<command> [options]');
@@ -14,7 +15,7 @@ const createProgram = () => {
14
15
  };
15
16
  function copyExampleProject() {
16
17
  const exampleProjectPath = path_1.default.join('example_projects_templates', 'typescript_jest');
17
- fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', '..', exampleProjectPath), '.');
18
+ fs_extra_1.default.copySync(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), exampleProjectPath), '.');
18
19
  }
19
20
  function init(argv) {
20
21
  const args = argv || process.argv;
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const got_1 = __importDefault(require("got"));
9
9
  const os_1 = __importDefault(require("os"));
10
10
  const path_1 = __importDefault(require("path"));
11
+ const path_2 = require("../utils/path");
11
12
  const logger_1 = require("./logger");
12
13
  var SupportedPlatform;
13
14
  (function (SupportedPlatform) {
@@ -35,7 +36,7 @@ function buildBinaryNotAvailbleError(binaryVersion) {
35
36
  return new Error(`It seems that the UI Controller version "${binaryVersion}" for your system "${platform()} ${os_1.default.arch}" is not availble, Please contact as at info@askui.com for more information`);
36
37
  }
37
38
  function getBinaryPath(version) {
38
- return path_1.default.join(__dirname, '..', '..', 'release', version, ...binarySubPathsByPlatform[platform()]);
39
+ return path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'release', version, ...binarySubPathsByPlatform[platform()]);
39
40
  }
40
41
  exports.getBinaryPath = getBinaryPath;
41
42
  function getBinaryDownloadUrl(binaryVersion) {
@@ -129,7 +129,7 @@ class UiControllerFacade {
129
129
  }
130
130
  catch (err) {
131
131
  throw new Error(`The UI Controller could not be started. Log file : ${this.serverLogFile}. ErrorReason: ${err}
132
- Check this website for more information: https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller-starting-problems`);
132
+ Check this website for more information: https://docs.askui.com/docs/general/Troubleshooting`);
133
133
  }
134
134
  });
135
135
  }
@@ -27,7 +27,7 @@ class UiControllerLinux extends ui_controller_facade_1.UiControllerFacade {
27
27
  const runCommand = (0, util_1.promisify)(child_process_1.exec);
28
28
  const waylandStatus = yield runCommand('echo $WAYLAND_DISPLAY');
29
29
  if (waylandStatus.stdout.trim().includes('wayland')) {
30
- throw new wayland_error_1.WaylandError('Wayland is not supported: https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller-starting-problems#wayland');
30
+ throw new wayland_error_1.WaylandError('Wayland is not supported: https://docs.askui.com/docs/general/Troubleshooting/linux#wayland');
31
31
  }
32
32
  /* First we want to check if the user is using a debian distribution.
33
33
  * and in the following if libfuse2 is installed.
@@ -44,7 +44,7 @@ class UiControllerLinux extends ui_controller_facade_1.UiControllerFacade {
44
44
  yield runCommand('dpkg -s libfuse2 | grep Status');
45
45
  }
46
46
  catch (_a) {
47
- throw new libfuse_error_1.LibfuseError('Libfuse2 package is missing: https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller-starting-problems#libfuse2');
47
+ throw new libfuse_error_1.LibfuseError('Libfuse2 package is missing: https://docs.askui.com/docs/general/Troubleshooting/linux#libfuse2');
48
48
  }
49
49
  });
50
50
  }
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Analytics = void 0;
16
16
  const os_1 = __importDefault(require("os"));
17
17
  const user_identifier_1 = require("./user-identifier");
18
+ const installation_timestamp_1 = require("./installation-timestamp");
18
19
  class Analytics {
19
20
  constructor() {
20
21
  this.userIdentifier = new user_identifier_1.UserIdentifier();
@@ -22,10 +23,15 @@ class Analytics {
22
23
  getAnalyticsHeaders() {
23
24
  return __awaiter(this, void 0, void 0, function* () {
24
25
  const userID = yield this.userIdentifier.userId();
25
- return {
26
+ const headers = {
26
27
  'askui-user-id': userID,
27
28
  'askui-user-agent': `os:${os_1.default.platform()};arch:${os_1.default.arch()}`,
28
29
  };
30
+ const askuiInstalledAt = yield installation_timestamp_1.InstallationTimestamp.get();
31
+ if (askuiInstalledAt) {
32
+ headers['askui-installed-at'] = askuiInstalledAt.toISOString();
33
+ }
34
+ return headers;
29
35
  });
30
36
  }
31
37
  }
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ export declare class InstallationTimestampCreateError extends Error {
3
+ constructor(err: NodeJS.ErrnoException);
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstallationTimestampCreateError = void 0;
4
+ class InstallationTimestampCreateError extends Error {
5
+ constructor(err) {
6
+ super(`Installation timestamp could not be created. \n${err.message}`);
7
+ }
8
+ }
9
+ exports.InstallationTimestampCreateError = InstallationTimestampCreateError;
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ export declare class InstallationTimestampGetError extends Error {
3
+ constructor(err: NodeJS.ErrnoException);
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstallationTimestampGetError = void 0;
4
+ class InstallationTimestampGetError extends Error {
5
+ constructor(err) {
6
+ super(`Installation timestamp does not exist. Try reinstalling the lib to create it. \n${err.message}`);
7
+ }
8
+ }
9
+ exports.InstallationTimestampGetError = InstallationTimestampGetError;
@@ -0,0 +1,7 @@
1
+ export declare abstract class InstallationTimestamp {
2
+ private static fileName;
3
+ private static value?;
4
+ static create(): Promise<void>;
5
+ static get(): Promise<Date | null>;
6
+ private static getFromFile;
7
+ }
@@ -0,0 +1,68 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.InstallationTimestamp = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const lib_1 = require("../../lib");
19
+ const installation_timestamp_create_error_1 = require("./installation-timestamp-create-error");
20
+ const installation_timestamp_get_error_1 = require("./installation-timestamp-get-error");
21
+ const path_2 = require("../path");
22
+ class InstallationTimestamp {
23
+ static create() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const timestamp = new Date().toISOString();
26
+ return new Promise((resolve, reject) => {
27
+ fs_1.default.writeFile(InstallationTimestamp.fileName, timestamp, { encoding: 'utf-8' }, (err) => {
28
+ if (err) {
29
+ reject(new installation_timestamp_create_error_1.InstallationTimestampCreateError(err));
30
+ }
31
+ else {
32
+ resolve();
33
+ }
34
+ });
35
+ });
36
+ });
37
+ }
38
+ static get() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (InstallationTimestamp.value === undefined) {
41
+ try {
42
+ InstallationTimestamp.value = yield this.getFromFile();
43
+ }
44
+ catch (err) {
45
+ InstallationTimestamp.value = null;
46
+ lib_1.logger.warn(err.message);
47
+ }
48
+ }
49
+ return InstallationTimestamp.value;
50
+ });
51
+ }
52
+ static getFromFile() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return new Promise((resolve, reject) => {
55
+ fs_1.default.readFile(InstallationTimestamp.fileName, 'utf-8', (err, isoDateStr) => {
56
+ if (err) {
57
+ reject(new installation_timestamp_get_error_1.InstallationTimestampGetError(err));
58
+ }
59
+ else {
60
+ resolve(new Date(isoDateStr));
61
+ }
62
+ });
63
+ });
64
+ });
65
+ }
66
+ }
67
+ exports.InstallationTimestamp = InstallationTimestamp;
68
+ InstallationTimestamp.fileName = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'install-timestamp');
@@ -1,5 +1,5 @@
1
1
  export interface CredentialArgs {
2
- tenant: string;
2
+ workspaceId: string;
3
3
  email: string;
4
4
  token: string;
5
5
  }
@@ -12,7 +12,7 @@ class Credentials {
12
12
  return Buffer.from(`${this.userName}:${this.credentials.token}`);
13
13
  }
14
14
  get userName() {
15
- return `${this.credentials.tenant}|${this.credentials.email}`;
15
+ return `${this.credentials.workspaceId}|${this.credentials.email}`;
16
16
  }
17
17
  }
18
18
  exports.Credentials = Credentials;
@@ -4,8 +4,8 @@ const credentials_1 = require("./credentials");
4
4
  describe('Credentials', () => {
5
5
  describe('base64Encoded()', () => {
6
6
  test('should return base64-encoded credentials', () => {
7
- const credentials = new credentials_1.Credentials({ tenant: 'tenant', email: 'name@tenant.com', token: 'password' });
8
- expect(credentials.base64Encoded).toBe('dGVuYW50fG5hbWVAdGVuYW50LmNvbTpwYXNzd29yZA==');
7
+ const credentials = new credentials_1.Credentials({ workspaceId: 'id123', email: 'name@tenant.com', token: 'password' });
8
+ expect(credentials.base64Encoded).toBe('aWQxMjN8bmFtZUB0ZW5hbnQuY29tOnBhc3N3b3Jk');
9
9
  });
10
10
  });
11
11
  });
@@ -0,0 +1 @@
1
+ export declare function getPathToNodeModulesRoot(): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPathToNodeModulesRoot = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ function getPathToNodeModulesRoot() {
9
+ return path_1.default.join(__dirname, '..', '..');
10
+ }
11
+ exports.getPathToNodeModulesRoot = getPathToNodeModulesRoot;
@@ -1,2 +1 @@
1
1
  export { CustomElement } from './custom-element';
2
- export { TestStep } from './test-step';
@@ -1,10 +1,6 @@
1
1
  import { CustomElement } from './custom-element';
2
- import { CustomElementJson } from './custom-element-json';
3
- export declare class TestStep {
2
+ export interface TestStep {
4
3
  instruction: string;
5
- customElements: CustomElement[];
6
- constructor(instruction: string, customElements?: CustomElement[]);
7
- static fromJson(step: TestStep & {
8
- customElements: CustomElementJson[];
9
- }): TestStep;
4
+ customElements?: CustomElement[];
5
+ secretText?: string | undefined;
10
6
  }
@@ -1,10 +1 @@
1
- import { CustomElement } from './custom-element';
2
- export class TestStep {
3
- constructor(instruction, customElements = []) {
4
- this.instruction = instruction;
5
- this.customElements = customElements;
6
- }
7
- static fromJson(step) {
8
- return new TestStep(step.instruction, (step.customElements || []).map((customELement) => CustomElement.fromJson(customELement)));
9
- }
10
- }
1
+ export {};
@@ -6,4 +6,5 @@ export declare class ControlCommand {
6
6
  tryToRepeat: boolean;
7
7
  constructor(code: ControlCommandCode, actions: Action[], tryToRepeat?: boolean);
8
8
  static fromJson(json: ControlCommand, resizeRatio?: number): ControlCommand;
9
+ setTextToBeTyped(text: string): void;
9
10
  }
@@ -1,5 +1,6 @@
1
1
  import { Action } from './action';
2
2
  import { ControlCommandCode } from './control-command-code';
3
+ import { InputEvent } from './input-event';
3
4
  export class ControlCommand {
4
5
  constructor(code, actions, tryToRepeat = false) {
5
6
  this.code = code;
@@ -9,4 +10,8 @@ export class ControlCommand {
9
10
  static fromJson(json, resizeRatio = 1) {
10
11
  return new ControlCommand(ControlCommandCode[json.code], json.actions.map((action) => Action.fromJson(action, resizeRatio)), json.tryToRepeat);
11
12
  }
13
+ setTextToBeTyped(text) {
14
+ this.actions = this.actions.map((action) => ([InputEvent.TYPE, InputEvent.TYPE_TEXT].includes(action.inputEvent)
15
+ ? new Action(action.inputEvent, action.position, text) : action));
16
+ }
12
17
  }
@@ -16,6 +16,5 @@ export declare enum InputEvent {
16
16
  MOUSE_MOVE = "MOUSE_MOVE",
17
17
  MOUSE_DOWN = "MOUSE_DOWN",
18
18
  MOUSE_UP = "MOUSE_UP",
19
- EXECUTE_COMMAND = "EXECUTE_COMMAND",
20
- WAIT = "WAIT"
19
+ EXECUTE_COMMAND = "EXECUTE_COMMAND"
21
20
  }
@@ -18,5 +18,4 @@ export var InputEvent;
18
18
  InputEvent["MOUSE_DOWN"] = "MOUSE_DOWN";
19
19
  InputEvent["MOUSE_UP"] = "MOUSE_UP";
20
20
  InputEvent["EXECUTE_COMMAND"] = "EXECUTE_COMMAND";
21
- InputEvent["WAIT"] = "WAIT";
22
21
  })(InputEvent || (InputEvent = {}));
@@ -426,6 +426,15 @@ export declare class FluentFilters extends FluentBase {
426
426
  /**
427
427
  * Filters for an UI element 'icon'.
428
428
  *
429
+ * You can combine it with the 'withText' command to look for a specific icon.
430
+ *
431
+ * **Examples:**
432
+ * ```typescript
433
+ * icon().withText('plus')
434
+ * ```
435
+ *
436
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
437
+ *
429
438
  * @return {FluentFiltersOrRelations}
430
439
  */
431
440
  icon(): FluentFiltersOrRelations;
@@ -461,6 +470,22 @@ export declare class FluentFilters extends FluentBase {
461
470
  * @return {FluentFiltersOrRelations}
462
471
  */
463
472
  withText(text: string): FluentFiltersOrRelations;
473
+ /**
474
+ * Filters for texts, which match the regex pattern.
475
+ *
476
+ * **Examples:**
477
+ *
478
+ * ```typescript
479
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
480
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
481
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
482
+ * ```
483
+ *
484
+ * @param {string} regex_pattern - An regex pattern
485
+ *
486
+ * @return {FluentFiltersOrRelations}
487
+ */
488
+ withTextRegex(regex_pattern: string): FluentFiltersOrRelations;
464
489
  /**
465
490
  * Filters for equal text.
466
491
  *
@@ -1060,6 +1085,15 @@ export declare class FluentFiltersCondition extends FluentBase {
1060
1085
  /**
1061
1086
  * Filters for an UI element 'icon'.
1062
1087
  *
1088
+ * You can combine it with the 'withText' command to look for a specific icon.
1089
+ *
1090
+ * **Examples:**
1091
+ * ```typescript
1092
+ * icon().withText('plus')
1093
+ * ```
1094
+ *
1095
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
1096
+ *
1063
1097
  * @return {FluentFiltersOrRelationsCondition}
1064
1098
  */
1065
1099
  icon(): FluentFiltersOrRelationsCondition;
@@ -1095,6 +1129,22 @@ export declare class FluentFiltersCondition extends FluentBase {
1095
1129
  * @return {FluentFiltersOrRelationsCondition}
1096
1130
  */
1097
1131
  withText(text: string): FluentFiltersOrRelationsCondition;
1132
+ /**
1133
+ * Filters for texts, which match the regex pattern.
1134
+ *
1135
+ * **Examples:**
1136
+ *
1137
+ * ```typescript
1138
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
1139
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
1140
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
1141
+ * ```
1142
+ *
1143
+ * @param {string} regex_pattern - An regex pattern
1144
+ *
1145
+ * @return {FluentFiltersOrRelationsCondition}
1146
+ */
1147
+ withTextRegex(regex_pattern: string): FluentFiltersOrRelationsCondition;
1098
1148
  /**
1099
1149
  * Filters for equal text.
1100
1150
  *
@@ -1331,7 +1381,7 @@ export declare abstract class FluentCommand extends FluentBase {
1331
1381
  */
1332
1382
  typeIn(text: string): FluentFilters;
1333
1383
  /**
1334
- * Moves mouse to the filtered element and scrolls in the x and y direction
1384
+ * Moves mouse to the filtered element and scrolls in the x and y direction.
1335
1385
  *
1336
1386
  * @param {number} x_offset - A (positive/negative) x direction.
1337
1387
  * @param {number} y_offset - A (positive/negative) y direction.