This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
IInteractions.ts
89 lines (71 loc) · 2.22 KB
/
IInteractions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { IJsPath } from '@ulixee/js-path';
import IMouseResult from './IMouseResult';
import IPoint from '../browser/IPoint';
import {IKeyboardShortcut} from "./IKeyboardShortcuts";
import {IKeyboardKeyCode} from "./IKeyboardLayoutUS";
export type IElementInteractVerification = 'elementAtPath' | 'exactElement' | 'none';
export type IInteractionGroups = IInteractionGroup[];
export type IInteractionGroup = IInteractionStep[];
// Interactions
export interface IInteractionStep {
command: IInteractionCommand;
mousePosition?: IMousePosition;
mouseButton?: IMouseButton;
mouseResultVerifier?: () => Promise<IMouseResult>;
simulateOptionClickOnNodeId?: number;
keyboardCommands?: IKeyboardCommand[];
keyboardDelayBetween?: number;
keyboardKeyupDelay?: number;
delayNode?: IJsPath;
delayElement?: IJsPath;
delayMillis?: number;
verification?: IElementInteractVerification;
relativeToScrollOffset?: IPoint;
}
export enum InteractionCommand {
move = 'move',
scroll = 'scroll',
willDismissDialog = 'willDismissDialog',
click = 'click',
clickDown = 'clickDown',
clickUp = 'clickUp',
doubleclick = 'doubleclick',
type = 'type',
waitForMillis = 'waitForMillis',
}
export type IInteractionCommand = keyof typeof InteractionCommand;
// Mouse-specific Types
export enum MouseButton {
left = 'left',
middle = 'middle',
right = 'right',
}
export type IMouseButton = keyof typeof MouseButton;
export type IMousePositionXY = [number, number];
export function isMousePositionXY(mousePosition: any): boolean {
return (
Array.isArray(mousePosition) &&
mousePosition.length === 2 &&
typeof mousePosition[0] === 'number' &&
typeof mousePosition[1] === 'number'
);
}
export type IMousePosition = IMousePositionXY | IJsPath;
// Keyboard-specific Types
export type IKeyboardCommand = IKeyPress | IKeyboardObject;
export type IKeyboardObject = IKeyboardString | IKeyboardUp | IKeyboardDown | IKeyShortcutPress;
export interface IKeyboardString {
string: string;
}
export interface IKeyPress {
keyCode: IKeyboardKeyCode;
}
export interface IKeyShortcutPress {
shortcut: IKeyboardShortcut;
}
export interface IKeyboardUp {
up: IKeyboardKeyCode;
}
export interface IKeyboardDown {
down: IKeyboardKeyCode;
}