tomation 0.0.1
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.
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/.vite/manifest.json +8 -0
- package/dist/actions.d.ts +396 -0
- package/dist/automation.d.ts +116 -0
- package/dist/date-utils.d.ts +11 -0
- package/dist/main.cjs +1 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.js +1350 -0
- package/dist/ui-element-builder.d.ts +286 -0
- package/dist/ui-utils.d.ts +27 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Facundo Crego
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
## Tomation - Framework for automating tasks in browsers
|
|
2
|
+
|
|
3
|
+
Tomation is an innovative framework designed for streamlining the automation of tasks within a web browser environment.
|
|
4
|
+
|
|
5
|
+
The core concept behind Tomation is its seamless integration as a browser extension, offering an efficient solution for test management and execution log handling.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Clone project locally and link it to your project.
|
|
10
|
+
|
|
11
|
+
At `tomation` run
|
|
12
|
+
```bash
|
|
13
|
+
npm link
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
In your project run
|
|
17
|
+
```bash
|
|
18
|
+
npm link tomation
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
It's recommended to use Page Object Model (POM) to implement automated tests. Create a file to automate a login page for example.
|
|
24
|
+
login-page.ts
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { Task, Click, Type, TypePassword } from 'tomation'
|
|
28
|
+
|
|
29
|
+
// --- UI Elements ---
|
|
30
|
+
const loginButton = is.BUTTON
|
|
31
|
+
.where(innerTextIs('Login'))
|
|
32
|
+
.as('Login Button')
|
|
33
|
+
|
|
34
|
+
const usernameInput = is.INPUT
|
|
35
|
+
.where((elem: HTMLElement) => elem?.parentElement?.parentElement?.children[1]?.textContent?.trim() === 'Username')
|
|
36
|
+
.as('Username Input')
|
|
37
|
+
|
|
38
|
+
const passwordInput = is.INPUT
|
|
39
|
+
.where((elem: HTMLElement) => elem?.parentElement?.parentElement?.children[1]?.textContent?.trim() === 'Password')
|
|
40
|
+
.as('Password Input')
|
|
41
|
+
|
|
42
|
+
// --- UI Actions ---
|
|
43
|
+
const login = Task('Login task', (params: { username: string, password: string }) => {
|
|
44
|
+
Type(params.username).in(usernameInput)
|
|
45
|
+
TypePassword(params.password).in(passwordInput)
|
|
46
|
+
Click(loginButton)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
// UI Elements
|
|
51
|
+
loginButton,
|
|
52
|
+
usernameInput,
|
|
53
|
+
passwordInput,
|
|
54
|
+
// Actions
|
|
55
|
+
login,
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import LoginPage from '~/login-page'
|
|
61
|
+
|
|
62
|
+
function LoginTest() {
|
|
63
|
+
Test('Login', () => {
|
|
64
|
+
LoginPage.login({
|
|
65
|
+
username: 'admin',
|
|
66
|
+
password: '12345',
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
LoginTest
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
|
|
79
|
+
Pull requests are welcome. For major changes, please open an issue first
|
|
80
|
+
to discuss what you would like to change.
|
|
81
|
+
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { UIElement } from "./ui-element-builder";
|
|
2
|
+
interface ActionContext {
|
|
3
|
+
url: string;
|
|
4
|
+
beforeHTML: string;
|
|
5
|
+
beforeInputValues: Object;
|
|
6
|
+
afterHTML: string;
|
|
7
|
+
afterInputValues: Object;
|
|
8
|
+
startTimestamp: string;
|
|
9
|
+
endTimestamp: string;
|
|
10
|
+
}
|
|
11
|
+
declare enum ACTION_STATUS {
|
|
12
|
+
WAITING = "waiting",
|
|
13
|
+
RUNNING = "running",
|
|
14
|
+
STOPPED = "stopped",
|
|
15
|
+
PAUSED = "paused",
|
|
16
|
+
SUCCESS = "success",
|
|
17
|
+
ERROR = "error",
|
|
18
|
+
SKIPPED = "skipped"
|
|
19
|
+
}
|
|
20
|
+
declare abstract class AbstractAction {
|
|
21
|
+
status: ACTION_STATUS;
|
|
22
|
+
error: string;
|
|
23
|
+
id: string;
|
|
24
|
+
context: ActionContext;
|
|
25
|
+
constructor();
|
|
26
|
+
abstract getDescription(): string;
|
|
27
|
+
getJSON(): {
|
|
28
|
+
id: string;
|
|
29
|
+
description: string;
|
|
30
|
+
context: ActionContext;
|
|
31
|
+
status: ACTION_STATUS;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
34
|
+
protected abstract executeAction(): Promise<any>;
|
|
35
|
+
protected abstract resetAction(): void;
|
|
36
|
+
reset(): void;
|
|
37
|
+
private getInputValuesFromPage;
|
|
38
|
+
execute(): Promise<void>;
|
|
39
|
+
static notifyActionUpdated(action: AbstractAction): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
declare class Action extends AbstractAction {
|
|
42
|
+
name: string;
|
|
43
|
+
stepsFn: (params?: any) => void;
|
|
44
|
+
steps: Array<AbstractAction>;
|
|
45
|
+
params: any;
|
|
46
|
+
index: number;
|
|
47
|
+
constructor(name: string, steps: (params?: any) => void);
|
|
48
|
+
getDescription(): string;
|
|
49
|
+
compileSteps(): void;
|
|
50
|
+
stepsToJSON(): Object[];
|
|
51
|
+
getJSON(): {
|
|
52
|
+
type: string;
|
|
53
|
+
params: any;
|
|
54
|
+
steps: Object[];
|
|
55
|
+
id: string;
|
|
56
|
+
description: string;
|
|
57
|
+
context: ActionContext;
|
|
58
|
+
status: ACTION_STATUS;
|
|
59
|
+
error: string;
|
|
60
|
+
};
|
|
61
|
+
resetAction(): void;
|
|
62
|
+
continue(): Promise<void>;
|
|
63
|
+
executeAction(): Promise<void>;
|
|
64
|
+
setParams(params?: any): void;
|
|
65
|
+
addStep(action: AbstractAction): void;
|
|
66
|
+
}
|
|
67
|
+
declare abstract class ActionOnElement extends AbstractAction {
|
|
68
|
+
uiElement: UIElement;
|
|
69
|
+
element: HTMLElement | null;
|
|
70
|
+
tries: number;
|
|
71
|
+
constructor(uiElement: UIElement);
|
|
72
|
+
getElementName(): string;
|
|
73
|
+
updateTries(tries: number): void;
|
|
74
|
+
resetTries(): void;
|
|
75
|
+
getJSON(): {
|
|
76
|
+
id: string;
|
|
77
|
+
element: string;
|
|
78
|
+
description: string;
|
|
79
|
+
status: ACTION_STATUS;
|
|
80
|
+
error: string;
|
|
81
|
+
context: ActionContext;
|
|
82
|
+
tries: number;
|
|
83
|
+
};
|
|
84
|
+
protected abstract executeActionOnElement(): void;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param uiElement
|
|
88
|
+
* @param delay of each try. Defaults to 1 second
|
|
89
|
+
*/
|
|
90
|
+
static waitForElement(currentAction: ActionOnElement, uiElement: UIElement, delay?: number, maxTries?: number, untilRemoved?: boolean): Promise<HTMLElement | null>;
|
|
91
|
+
executeAction(): Promise<void>;
|
|
92
|
+
resetAction(): void;
|
|
93
|
+
}
|
|
94
|
+
declare class ClickAction extends ActionOnElement {
|
|
95
|
+
constructor(uiElement: UIElement);
|
|
96
|
+
protected executeActionOnElement(): void | undefined;
|
|
97
|
+
getDescription(): string;
|
|
98
|
+
getJSON(): {
|
|
99
|
+
type: string;
|
|
100
|
+
id: string;
|
|
101
|
+
element: string;
|
|
102
|
+
description: string;
|
|
103
|
+
status: ACTION_STATUS;
|
|
104
|
+
error: string;
|
|
105
|
+
context: ActionContext;
|
|
106
|
+
tries: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
declare class AssertTextIsAction extends ActionOnElement {
|
|
110
|
+
text: string;
|
|
111
|
+
constructor(uiElement: UIElement, text: string);
|
|
112
|
+
protected executeActionOnElement(): void;
|
|
113
|
+
getDescription(): string;
|
|
114
|
+
getJSON(): {
|
|
115
|
+
type: string;
|
|
116
|
+
value: string;
|
|
117
|
+
id: string;
|
|
118
|
+
element: string;
|
|
119
|
+
description: string;
|
|
120
|
+
status: ACTION_STATUS;
|
|
121
|
+
error: string;
|
|
122
|
+
context: ActionContext;
|
|
123
|
+
tries: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
declare class AssertContainsTextAction extends ActionOnElement {
|
|
127
|
+
text: string;
|
|
128
|
+
constructor(uiElement: UIElement, text: string);
|
|
129
|
+
protected executeActionOnElement(): void;
|
|
130
|
+
getDescription(): string;
|
|
131
|
+
getJSON(): {
|
|
132
|
+
type: string;
|
|
133
|
+
value: string;
|
|
134
|
+
id: string;
|
|
135
|
+
element: string;
|
|
136
|
+
description: string;
|
|
137
|
+
status: ACTION_STATUS;
|
|
138
|
+
error: string;
|
|
139
|
+
context: ActionContext;
|
|
140
|
+
tries: number;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
declare class AssertValueIsAction extends ActionOnElement {
|
|
144
|
+
value: string | boolean | number | Date;
|
|
145
|
+
constructor(uiElement: UIElement, value: string | boolean | number | Date);
|
|
146
|
+
protected executeActionOnElement(): void;
|
|
147
|
+
getDescription(): string;
|
|
148
|
+
getJSON(): {
|
|
149
|
+
type: string;
|
|
150
|
+
value: string | number | boolean | Date;
|
|
151
|
+
id: string;
|
|
152
|
+
element: string;
|
|
153
|
+
description: string;
|
|
154
|
+
status: ACTION_STATUS;
|
|
155
|
+
error: string;
|
|
156
|
+
context: ActionContext;
|
|
157
|
+
tries: number;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
declare class AssertExistsAction extends ActionOnElement {
|
|
161
|
+
constructor(uiElement: UIElement);
|
|
162
|
+
protected executeActionOnElement(): void;
|
|
163
|
+
getDescription(): string;
|
|
164
|
+
getJSON(): {
|
|
165
|
+
type: string;
|
|
166
|
+
id: string;
|
|
167
|
+
element: string;
|
|
168
|
+
description: string;
|
|
169
|
+
status: ACTION_STATUS;
|
|
170
|
+
error: string;
|
|
171
|
+
context: ActionContext;
|
|
172
|
+
tries: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
declare class AssertNotExistsAction extends ActionOnElement {
|
|
176
|
+
constructor(uiElement: UIElement);
|
|
177
|
+
executeAction(): Promise<void>;
|
|
178
|
+
protected executeActionOnElement(): void;
|
|
179
|
+
getDescription(): string;
|
|
180
|
+
getJSON(): {
|
|
181
|
+
type: string;
|
|
182
|
+
id: string;
|
|
183
|
+
element: string;
|
|
184
|
+
description: string;
|
|
185
|
+
status: ACTION_STATUS;
|
|
186
|
+
error: string;
|
|
187
|
+
context: ActionContext;
|
|
188
|
+
tries: number;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
declare class SelectAction extends ActionOnElement {
|
|
192
|
+
value: string;
|
|
193
|
+
constructor(uiElement: UIElement, value: string);
|
|
194
|
+
protected executeActionOnElement(): void;
|
|
195
|
+
getDescription(): string;
|
|
196
|
+
getJSON(): {
|
|
197
|
+
type: string;
|
|
198
|
+
value: string;
|
|
199
|
+
id: string;
|
|
200
|
+
element: string;
|
|
201
|
+
description: string;
|
|
202
|
+
status: ACTION_STATUS;
|
|
203
|
+
error: string;
|
|
204
|
+
context: ActionContext;
|
|
205
|
+
tries: number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
declare class TypeAction extends ActionOnElement {
|
|
209
|
+
value: string;
|
|
210
|
+
constructor(uiElement: UIElement, value: string);
|
|
211
|
+
protected executeActionOnElement(): void;
|
|
212
|
+
getDescription(): string;
|
|
213
|
+
getJSON(): {
|
|
214
|
+
type: string;
|
|
215
|
+
value: string;
|
|
216
|
+
id: string;
|
|
217
|
+
element: string;
|
|
218
|
+
description: string;
|
|
219
|
+
status: ACTION_STATUS;
|
|
220
|
+
error: string;
|
|
221
|
+
context: ActionContext;
|
|
222
|
+
tries: number;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
declare class TypePasswordAction extends ActionOnElement {
|
|
226
|
+
value: string;
|
|
227
|
+
constructor(uiElement: UIElement, value: string);
|
|
228
|
+
protected executeActionOnElement(): void;
|
|
229
|
+
getDescription(): string;
|
|
230
|
+
getJSON(): {
|
|
231
|
+
type: string;
|
|
232
|
+
value: string;
|
|
233
|
+
id: string;
|
|
234
|
+
element: string;
|
|
235
|
+
description: string;
|
|
236
|
+
status: ACTION_STATUS;
|
|
237
|
+
error: string;
|
|
238
|
+
context: ActionContext;
|
|
239
|
+
tries: number;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
declare class PressEscKeyAction extends ActionOnElement {
|
|
243
|
+
constructor(uiElement: UIElement);
|
|
244
|
+
protected executeActionOnElement(): void;
|
|
245
|
+
getDescription(): string;
|
|
246
|
+
getJSON(): {
|
|
247
|
+
type: string;
|
|
248
|
+
id: string;
|
|
249
|
+
element: string;
|
|
250
|
+
description: string;
|
|
251
|
+
status: ACTION_STATUS;
|
|
252
|
+
error: string;
|
|
253
|
+
context: ActionContext;
|
|
254
|
+
tries: number;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
declare class PressDownKeyAction extends ActionOnElement {
|
|
258
|
+
constructor(uiElement: UIElement);
|
|
259
|
+
protected executeActionOnElement(): void;
|
|
260
|
+
getDescription(): string;
|
|
261
|
+
getJSON(): {
|
|
262
|
+
type: string;
|
|
263
|
+
id: string;
|
|
264
|
+
element: string;
|
|
265
|
+
description: string;
|
|
266
|
+
status: ACTION_STATUS;
|
|
267
|
+
error: string;
|
|
268
|
+
context: ActionContext;
|
|
269
|
+
tries: number;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
declare class PressTabKeyAction extends ActionOnElement {
|
|
273
|
+
constructor(uiElement: UIElement);
|
|
274
|
+
protected executeActionOnElement(): void;
|
|
275
|
+
getDescription(): string;
|
|
276
|
+
getJSON(): {
|
|
277
|
+
type: string;
|
|
278
|
+
id: string;
|
|
279
|
+
element: string;
|
|
280
|
+
description: string;
|
|
281
|
+
status: ACTION_STATUS;
|
|
282
|
+
error: string;
|
|
283
|
+
context: ActionContext;
|
|
284
|
+
tries: number;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
declare class UploadFileAction extends ActionOnElement {
|
|
288
|
+
file: File;
|
|
289
|
+
constructor(uiElement: UIElement, file: File);
|
|
290
|
+
protected executeActionOnElement(): void;
|
|
291
|
+
getDescription(): string;
|
|
292
|
+
getJSON(): {
|
|
293
|
+
type: string;
|
|
294
|
+
id: string;
|
|
295
|
+
element: string;
|
|
296
|
+
description: string;
|
|
297
|
+
status: ACTION_STATUS;
|
|
298
|
+
error: string;
|
|
299
|
+
context: ActionContext;
|
|
300
|
+
tries: number;
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
declare class SaveValueAction extends ActionOnElement {
|
|
304
|
+
memorySlotName: string;
|
|
305
|
+
constructor(uiElement: UIElement, memorySlotName: string);
|
|
306
|
+
protected executeActionOnElement(): void;
|
|
307
|
+
getDescription(): string;
|
|
308
|
+
getJSON(): {
|
|
309
|
+
type: string;
|
|
310
|
+
memorySlotName: string;
|
|
311
|
+
id: string;
|
|
312
|
+
element: string;
|
|
313
|
+
description: string;
|
|
314
|
+
status: ACTION_STATUS;
|
|
315
|
+
error: string;
|
|
316
|
+
context: ActionContext;
|
|
317
|
+
tries: number;
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
declare class WaitAction extends AbstractAction {
|
|
321
|
+
miliseconds: number;
|
|
322
|
+
constructor(miliseconds: number);
|
|
323
|
+
getDescription(): string;
|
|
324
|
+
getJSON(): {
|
|
325
|
+
type: string;
|
|
326
|
+
id: string;
|
|
327
|
+
description: string;
|
|
328
|
+
context: ActionContext;
|
|
329
|
+
status: ACTION_STATUS;
|
|
330
|
+
error: string;
|
|
331
|
+
};
|
|
332
|
+
executeAction(): Promise<void>;
|
|
333
|
+
resetAction(): void;
|
|
334
|
+
}
|
|
335
|
+
declare class WaitUntilElementRemovedAction extends AbstractAction {
|
|
336
|
+
uiElement: UIElement;
|
|
337
|
+
tries: number;
|
|
338
|
+
constructor(uiElement: UIElement);
|
|
339
|
+
updateTries(tries: number): void;
|
|
340
|
+
resetAction(): void;
|
|
341
|
+
getElementName(): string;
|
|
342
|
+
protected executeAction(): Promise<void>;
|
|
343
|
+
getDescription(): string;
|
|
344
|
+
getJSON(): {
|
|
345
|
+
type: string;
|
|
346
|
+
id: string;
|
|
347
|
+
description: string;
|
|
348
|
+
context: ActionContext;
|
|
349
|
+
status: ACTION_STATUS;
|
|
350
|
+
error: string;
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
declare class PauseAction extends AbstractAction {
|
|
354
|
+
constructor();
|
|
355
|
+
getDescription(): string;
|
|
356
|
+
getJSON(): {
|
|
357
|
+
type: string;
|
|
358
|
+
id: string;
|
|
359
|
+
description: string;
|
|
360
|
+
context: ActionContext;
|
|
361
|
+
status: ACTION_STATUS;
|
|
362
|
+
error: string;
|
|
363
|
+
};
|
|
364
|
+
executeAction(): Promise<void>;
|
|
365
|
+
resetAction(): void;
|
|
366
|
+
}
|
|
367
|
+
declare class ManualAction extends AbstractAction {
|
|
368
|
+
description: string;
|
|
369
|
+
constructor(description: string);
|
|
370
|
+
getDescription(): string;
|
|
371
|
+
getJSON(): {
|
|
372
|
+
type: string;
|
|
373
|
+
id: string;
|
|
374
|
+
description: string;
|
|
375
|
+
context: ActionContext;
|
|
376
|
+
status: ACTION_STATUS;
|
|
377
|
+
error: string;
|
|
378
|
+
};
|
|
379
|
+
executeAction(): Promise<unknown>;
|
|
380
|
+
resetAction(): void;
|
|
381
|
+
}
|
|
382
|
+
declare class ReloadPageAction extends AbstractAction {
|
|
383
|
+
constructor();
|
|
384
|
+
getDescription(): string;
|
|
385
|
+
getJSON(): {
|
|
386
|
+
type: string;
|
|
387
|
+
id: string;
|
|
388
|
+
description: string;
|
|
389
|
+
context: ActionContext;
|
|
390
|
+
status: ACTION_STATUS;
|
|
391
|
+
error: string;
|
|
392
|
+
};
|
|
393
|
+
executeAction(): Promise<void>;
|
|
394
|
+
resetAction(): void;
|
|
395
|
+
}
|
|
396
|
+
export { AbstractAction, Action, ActionOnElement, ClickAction, SelectAction, TypeAction, TypePasswordAction, PressEscKeyAction, PressDownKeyAction, PressTabKeyAction, UploadFileAction, AssertTextIsAction, AssertContainsTextAction, AssertValueIsAction, AssertExistsAction, AssertNotExistsAction, SaveValueAction, WaitAction, WaitUntilElementRemovedAction, PauseAction, ManualAction, ReloadPageAction, ACTION_STATUS, };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { AbstractAction, ACTION_STATUS } from './actions';
|
|
2
|
+
import { UIUtils } from "./ui-utils";
|
|
3
|
+
import { UIElement } from './ui-element-builder';
|
|
4
|
+
import DateUtils from './date-utils';
|
|
5
|
+
declare const setAutomationLogs: (enabled: boolean) => void;
|
|
6
|
+
declare enum EVENT_NAMES {
|
|
7
|
+
START = "start",
|
|
8
|
+
END = "end",
|
|
9
|
+
ACTION_UPDATE = "action-update",
|
|
10
|
+
SAVE_VALUE = "save-value",
|
|
11
|
+
REGISTER_TEST = "register-test",
|
|
12
|
+
TEST_STARTED = "test-started",
|
|
13
|
+
TEST_PASSED = "test-passed",
|
|
14
|
+
TEST_FAILED = "test-failed",
|
|
15
|
+
TEST_END = "test-end",
|
|
16
|
+
USER_ACCEPT = "user-accept",
|
|
17
|
+
USER_REJECT = "user-reject"
|
|
18
|
+
}
|
|
19
|
+
type AutomationEventHandlerType = ((action?: any) => void);
|
|
20
|
+
declare class EventDispatcher {
|
|
21
|
+
events: Map<EVENT_NAMES, Array<AutomationEventHandlerType>>;
|
|
22
|
+
constructor();
|
|
23
|
+
on(eventName: EVENT_NAMES, callback: AutomationEventHandlerType): void;
|
|
24
|
+
off(eventName: EVENT_NAMES, callback: AutomationEventHandlerType): void;
|
|
25
|
+
dispatch(eventName: EVENT_NAMES, data?: any): void;
|
|
26
|
+
}
|
|
27
|
+
declare const AutomationEvents: EventDispatcher;
|
|
28
|
+
declare enum TestSpeed {
|
|
29
|
+
SLOW = 2000,
|
|
30
|
+
NORMAL = 1000,
|
|
31
|
+
FAST = 200
|
|
32
|
+
}
|
|
33
|
+
declare enum TestPlayStatus {
|
|
34
|
+
PLAYING = "Playing",
|
|
35
|
+
STOPPED = "Stopped",
|
|
36
|
+
PAUSED = "Paused"
|
|
37
|
+
}
|
|
38
|
+
declare enum RunMode {
|
|
39
|
+
NORMAL = "Normal",
|
|
40
|
+
STEPBYSTEP = "Step By Step"
|
|
41
|
+
}
|
|
42
|
+
declare const Test: (id: string, steps: () => void) => void;
|
|
43
|
+
declare const RunTest: (id: string) => void;
|
|
44
|
+
declare const Task: <T>(id: string, steps: (params: T) => void) => (params?: T | undefined) => Promise<void>;
|
|
45
|
+
declare const Click: (uiElement: UIElement) => void;
|
|
46
|
+
declare const Assert: (uiElement: UIElement) => {
|
|
47
|
+
textIs: (text: string) => void;
|
|
48
|
+
containsText: (text: string) => void;
|
|
49
|
+
valueIs: (value: string) => void;
|
|
50
|
+
exists: () => void;
|
|
51
|
+
notExists: () => void;
|
|
52
|
+
};
|
|
53
|
+
declare const Select: (value: string) => {
|
|
54
|
+
in: (uiElement: UIElement) => void;
|
|
55
|
+
};
|
|
56
|
+
declare const Type: (value: string) => {
|
|
57
|
+
in: (uiElement: UIElement) => void;
|
|
58
|
+
};
|
|
59
|
+
declare const ClearValue: () => {
|
|
60
|
+
in: (uiElement: UIElement) => void;
|
|
61
|
+
};
|
|
62
|
+
declare const PressEscKey: () => {
|
|
63
|
+
in: (uiElement: UIElement) => void;
|
|
64
|
+
};
|
|
65
|
+
declare const PressDownKey: () => {
|
|
66
|
+
in: (uiElement: UIElement) => void;
|
|
67
|
+
};
|
|
68
|
+
declare const PressTabKey: () => {
|
|
69
|
+
in: (uiElement: UIElement) => void;
|
|
70
|
+
};
|
|
71
|
+
declare const TypePassword: (value: string) => {
|
|
72
|
+
in: (uiElement: UIElement) => void;
|
|
73
|
+
};
|
|
74
|
+
declare const UploadFile: (file: File) => {
|
|
75
|
+
in: (uiElement: UIElement) => void;
|
|
76
|
+
};
|
|
77
|
+
declare const SaveValue: (uiElement: UIElement) => {
|
|
78
|
+
in: (memorySlotName: string) => void;
|
|
79
|
+
};
|
|
80
|
+
declare const Wait: {
|
|
81
|
+
(miliseconds: number): void;
|
|
82
|
+
untilElement(uiElement: UIElement): {
|
|
83
|
+
isRemoved: () => void;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
declare const Pause: () => void;
|
|
87
|
+
declare const ManualTask: (description: string) => void;
|
|
88
|
+
declare const ReloadPage: () => void;
|
|
89
|
+
declare class Automation {
|
|
90
|
+
private _document;
|
|
91
|
+
debug: Boolean;
|
|
92
|
+
private _uiUtils;
|
|
93
|
+
speed: TestSpeed;
|
|
94
|
+
status: TestPlayStatus;
|
|
95
|
+
runMode: RunMode;
|
|
96
|
+
currentActionCallback: ((action: AbstractAction) => {}) | undefined;
|
|
97
|
+
currentAction: AbstractAction | undefined;
|
|
98
|
+
constructor(window: Window);
|
|
99
|
+
get document(): Document;
|
|
100
|
+
get uiUtils(): UIUtils;
|
|
101
|
+
get isStepByStepMode(): boolean;
|
|
102
|
+
get isStopped(): boolean;
|
|
103
|
+
get isPlaying(): boolean;
|
|
104
|
+
get isPaused(): boolean;
|
|
105
|
+
pause(): void;
|
|
106
|
+
continue(): void;
|
|
107
|
+
next(): void;
|
|
108
|
+
stop(): void;
|
|
109
|
+
retryAction(): void;
|
|
110
|
+
skipAction(): void;
|
|
111
|
+
saveCurrentAction(callback: (action: AbstractAction) => {}, action: AbstractAction): void;
|
|
112
|
+
setDebug(value: boolean): void;
|
|
113
|
+
}
|
|
114
|
+
declare let AutomationInstance: Automation;
|
|
115
|
+
declare const Setup: (window: Window, tests?: Array<any>) => Automation;
|
|
116
|
+
export { Setup, AutomationInstance, Test, RunTest, Task, Click, Assert, Select, Type, TypePassword, ClearValue, PressEscKey, PressDownKey, PressTabKey, UploadFile, SaveValue, Wait, Pause, ManualTask, ReloadPage, DateUtils, AutomationEvents, EVENT_NAMES, TestSpeed, ACTION_STATUS, setAutomationLogs, };
|