@toolstackhq/cdpwright 1.0.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.
- package/README.md +62 -0
- package/dist/assert/expect.d.ts +1 -0
- package/dist/assert/expect.js +7 -0
- package/dist/assert/expect.js.map +1 -0
- package/dist/chunk-6BPF3IEU.js +1572 -0
- package/dist/chunk-6BPF3IEU.js.map +1 -0
- package/dist/cli.js +2161 -0
- package/dist/cli.js.map +1 -0
- package/dist/expect-CY70zJc0.d.ts +318 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +878 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "trace";
|
|
2
|
+
declare class Logger {
|
|
3
|
+
private level;
|
|
4
|
+
constructor(level?: LogLevel);
|
|
5
|
+
setLevel(level: LogLevel): void;
|
|
6
|
+
error(message: string, ...args: unknown[]): void;
|
|
7
|
+
warn(message: string, ...args: unknown[]): void;
|
|
8
|
+
info(message: string, ...args: unknown[]): void;
|
|
9
|
+
debug(message: string, ...args: unknown[]): void;
|
|
10
|
+
trace(message: string, ...args: unknown[]): void;
|
|
11
|
+
log(level: LogLevel, message: string, ...args: unknown[]): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare class Session {
|
|
15
|
+
private connection;
|
|
16
|
+
private sessionId;
|
|
17
|
+
private emitter;
|
|
18
|
+
constructor(connection: Connection, sessionId: string);
|
|
19
|
+
on(event: string, handler: (params: unknown) => void): void;
|
|
20
|
+
once(event: string, handler: (params: unknown) => void): void;
|
|
21
|
+
send<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
22
|
+
dispatch(method: string, params: unknown): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class Connection {
|
|
26
|
+
private ws;
|
|
27
|
+
private id;
|
|
28
|
+
private callbacks;
|
|
29
|
+
private sessions;
|
|
30
|
+
private emitter;
|
|
31
|
+
private logger;
|
|
32
|
+
private closed;
|
|
33
|
+
constructor(url: string, logger: Logger);
|
|
34
|
+
waitForOpen(): Promise<void>;
|
|
35
|
+
createSession(sessionId: string): Session;
|
|
36
|
+
removeSession(sessionId: string): void;
|
|
37
|
+
on(event: string, handler: (params: unknown) => void): void;
|
|
38
|
+
send<T = unknown>(method: string, params?: Record<string, unknown>, sessionId?: string): Promise<T>;
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
private onError;
|
|
41
|
+
private onClose;
|
|
42
|
+
private failPending;
|
|
43
|
+
private onMessage;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type ActionEvent = {
|
|
47
|
+
name: string;
|
|
48
|
+
selector?: string;
|
|
49
|
+
frameId?: string;
|
|
50
|
+
durationMs?: number;
|
|
51
|
+
sensitive?: boolean;
|
|
52
|
+
status?: "passed" | "failed";
|
|
53
|
+
};
|
|
54
|
+
type AssertionEvent = {
|
|
55
|
+
name: string;
|
|
56
|
+
selector?: string;
|
|
57
|
+
frameId?: string;
|
|
58
|
+
durationMs?: number;
|
|
59
|
+
status?: "passed" | "failed";
|
|
60
|
+
};
|
|
61
|
+
type AutomationEventMap = {
|
|
62
|
+
"action:start": ActionEvent;
|
|
63
|
+
"action:end": ActionEvent;
|
|
64
|
+
"assertion:start": AssertionEvent;
|
|
65
|
+
"assertion:end": AssertionEvent;
|
|
66
|
+
};
|
|
67
|
+
declare class AutomationEvents {
|
|
68
|
+
private emitter;
|
|
69
|
+
on<K extends keyof AutomationEventMap>(event: K, handler: (payload: AutomationEventMap[K]) => void): void;
|
|
70
|
+
off<K extends keyof AutomationEventMap>(event: K, handler: (payload: AutomationEventMap[K]) => void): void;
|
|
71
|
+
emit<K extends keyof AutomationEventMap>(event: K, payload: AutomationEventMap[K]): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type LocatorOptions = {};
|
|
75
|
+
declare class Locator {
|
|
76
|
+
private frame;
|
|
77
|
+
private selector;
|
|
78
|
+
private options;
|
|
79
|
+
constructor(frame: Frame, selector: string, options?: LocatorOptions);
|
|
80
|
+
click(options?: {
|
|
81
|
+
timeoutMs?: number;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
dblclick(options?: {
|
|
84
|
+
timeoutMs?: number;
|
|
85
|
+
}): Promise<void>;
|
|
86
|
+
type(text: string, options?: {
|
|
87
|
+
timeoutMs?: number;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
exists(): Promise<boolean>;
|
|
90
|
+
text(): Promise<string | null>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type FrameSelectorOptions = {
|
|
94
|
+
pierceShadowDom?: boolean;
|
|
95
|
+
timeoutMs?: number;
|
|
96
|
+
};
|
|
97
|
+
type ClickOptions = {
|
|
98
|
+
timeoutMs?: number;
|
|
99
|
+
};
|
|
100
|
+
type TypeOptions = {
|
|
101
|
+
timeoutMs?: number;
|
|
102
|
+
sensitive?: boolean;
|
|
103
|
+
};
|
|
104
|
+
type QueryResult = {
|
|
105
|
+
objectId: string;
|
|
106
|
+
contextId: number;
|
|
107
|
+
};
|
|
108
|
+
declare class Frame {
|
|
109
|
+
readonly id: string;
|
|
110
|
+
name?: string;
|
|
111
|
+
url?: string;
|
|
112
|
+
parentId?: string;
|
|
113
|
+
private session;
|
|
114
|
+
private logger;
|
|
115
|
+
private events;
|
|
116
|
+
private contextId?;
|
|
117
|
+
private defaultTimeout;
|
|
118
|
+
constructor(id: string, session: Session, logger: Logger, events: AutomationEvents);
|
|
119
|
+
setExecutionContext(contextId?: number): void;
|
|
120
|
+
getExecutionContext(): number | undefined;
|
|
121
|
+
setMeta(meta: {
|
|
122
|
+
name?: string;
|
|
123
|
+
url?: string;
|
|
124
|
+
parentId?: string;
|
|
125
|
+
}): void;
|
|
126
|
+
evaluate<T = unknown>(fnOrString: string | ((...args: any[]) => any), ...args: any[]): Promise<T>;
|
|
127
|
+
query(selector: string, options?: FrameSelectorOptions): Promise<QueryResult | null>;
|
|
128
|
+
queryAll(selector: string, options?: FrameSelectorOptions): Promise<QueryResult[]>;
|
|
129
|
+
queryXPath(selector: string, options?: FrameSelectorOptions): Promise<QueryResult | null>;
|
|
130
|
+
queryAllXPath(selector: string, options?: FrameSelectorOptions): Promise<QueryResult[]>;
|
|
131
|
+
locator(selector: string, options?: FrameSelectorOptions): Locator;
|
|
132
|
+
click(selector: string, options?: ClickOptions): Promise<void>;
|
|
133
|
+
dblclick(selector: string, options?: ClickOptions): Promise<void>;
|
|
134
|
+
type(selector: string, text: string, options?: TypeOptions): Promise<void>;
|
|
135
|
+
typeSecure(selector: string, text: string, options?: TypeOptions): Promise<void>;
|
|
136
|
+
fillInput(selector: string, value: string, options?: {
|
|
137
|
+
timeoutMs?: number;
|
|
138
|
+
}): Promise<void>;
|
|
139
|
+
findLocators(options?: {
|
|
140
|
+
highlight?: boolean;
|
|
141
|
+
outputPath?: string;
|
|
142
|
+
outputJson?: string;
|
|
143
|
+
outputHtml?: string;
|
|
144
|
+
}): Promise<any[]>;
|
|
145
|
+
private writeLocatorHtml;
|
|
146
|
+
exists(selector: string, options?: FrameSelectorOptions): Promise<boolean>;
|
|
147
|
+
isVisible(selector: string, options?: FrameSelectorOptions): Promise<boolean>;
|
|
148
|
+
text(selector: string, options?: FrameSelectorOptions): Promise<string | null>;
|
|
149
|
+
textSecure(selector: string, options?: FrameSelectorOptions): Promise<string | null>;
|
|
150
|
+
selectOption(selector: string, value: string): Promise<void>;
|
|
151
|
+
setFileInput(selector: string, name: string, contents: string, options?: {
|
|
152
|
+
mimeType?: string;
|
|
153
|
+
}): Promise<void>;
|
|
154
|
+
attribute(selector: string, name: string, options?: FrameSelectorOptions): Promise<string | null>;
|
|
155
|
+
value(selector: string, options?: FrameSelectorOptions): Promise<string | null>;
|
|
156
|
+
valueSecure(selector: string, options?: FrameSelectorOptions): Promise<string | null>;
|
|
157
|
+
isEnabled(selector: string, options?: FrameSelectorOptions): Promise<boolean | null>;
|
|
158
|
+
isChecked(selector: string, options?: FrameSelectorOptions): Promise<boolean | null>;
|
|
159
|
+
count(selector: string, options?: FrameSelectorOptions): Promise<number>;
|
|
160
|
+
classes(selector: string, options?: FrameSelectorOptions): Promise<string[] | null>;
|
|
161
|
+
css(selector: string, property: string, options?: FrameSelectorOptions): Promise<string | null>;
|
|
162
|
+
hasFocus(selector: string, options?: FrameSelectorOptions): Promise<boolean | null>;
|
|
163
|
+
isInViewport(selector: string, options?: FrameSelectorOptions, fully?: boolean): Promise<boolean | null>;
|
|
164
|
+
isEditable(selector: string, options?: FrameSelectorOptions): Promise<boolean | null>;
|
|
165
|
+
private performClick;
|
|
166
|
+
private resolveElementBox;
|
|
167
|
+
private querySelectorInternal;
|
|
168
|
+
private querySelectorAllInternal;
|
|
169
|
+
private evaluateInContext;
|
|
170
|
+
private releaseObject;
|
|
171
|
+
private buildElementExpression;
|
|
172
|
+
private evalOnSelector;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
type GotoOptions = {
|
|
176
|
+
waitUntil?: "domcontentloaded" | "load";
|
|
177
|
+
timeoutMs?: number;
|
|
178
|
+
allowFileUrl?: boolean;
|
|
179
|
+
};
|
|
180
|
+
type ScreenshotOptions = {
|
|
181
|
+
path?: string;
|
|
182
|
+
format?: "png" | "jpeg";
|
|
183
|
+
quality?: number;
|
|
184
|
+
};
|
|
185
|
+
declare class Page {
|
|
186
|
+
private session;
|
|
187
|
+
private logger;
|
|
188
|
+
private events;
|
|
189
|
+
private framesById;
|
|
190
|
+
private mainFrameId?;
|
|
191
|
+
private lifecycleEvents;
|
|
192
|
+
private defaultTimeout;
|
|
193
|
+
constructor(session: Session, logger: Logger, events: AutomationEvents);
|
|
194
|
+
initialize(): Promise<void>;
|
|
195
|
+
frames(): Frame[];
|
|
196
|
+
mainFrame(): Frame;
|
|
197
|
+
frame(options: {
|
|
198
|
+
name?: string;
|
|
199
|
+
urlIncludes?: string;
|
|
200
|
+
predicate?: (frame: Frame) => boolean;
|
|
201
|
+
}): Frame | null;
|
|
202
|
+
locator(selector: string): Locator;
|
|
203
|
+
goto(url: string, options?: GotoOptions): Promise<void>;
|
|
204
|
+
query(selector: string): Promise<QueryResult | null>;
|
|
205
|
+
queryAll(selector: string): Promise<QueryResult[]>;
|
|
206
|
+
queryXPath(selector: string): Promise<QueryResult | null>;
|
|
207
|
+
queryAllXPath(selector: string): Promise<QueryResult[]>;
|
|
208
|
+
click(selector: string, options?: {
|
|
209
|
+
timeoutMs?: number;
|
|
210
|
+
}): Promise<void>;
|
|
211
|
+
dblclick(selector: string, options?: {
|
|
212
|
+
timeoutMs?: number;
|
|
213
|
+
}): Promise<void>;
|
|
214
|
+
type(selector: string, text: string, options?: {
|
|
215
|
+
timeoutMs?: number;
|
|
216
|
+
}): Promise<void>;
|
|
217
|
+
typeSecure(selector: string, text: string, options?: {
|
|
218
|
+
timeoutMs?: number;
|
|
219
|
+
}): Promise<void>;
|
|
220
|
+
fillInput(selector: string, value: string, options?: {
|
|
221
|
+
timeoutMs?: number;
|
|
222
|
+
}): Promise<void>;
|
|
223
|
+
evaluate<T = unknown>(fnOrString: string | ((...args: any[]) => any), ...args: any[]): Promise<T>;
|
|
224
|
+
textSecure(selector: string): Promise<string | null>;
|
|
225
|
+
valueSecure(selector: string): Promise<string | null>;
|
|
226
|
+
selectOption(selector: string, value: string): Promise<void>;
|
|
227
|
+
setFileInput(selector: string, name: string, contents: string, options?: {
|
|
228
|
+
mimeType?: string;
|
|
229
|
+
}): Promise<void>;
|
|
230
|
+
screenshot(options?: ScreenshotOptions): Promise<Buffer<ArrayBuffer>>;
|
|
231
|
+
screenshotBase64(options?: Omit<ScreenshotOptions, "path">): Promise<string>;
|
|
232
|
+
getEvents(): AutomationEvents;
|
|
233
|
+
getDefaultTimeout(): number;
|
|
234
|
+
private buildFrameTree;
|
|
235
|
+
private ensureFrame;
|
|
236
|
+
private onFrameAttached;
|
|
237
|
+
private onFrameNavigated;
|
|
238
|
+
private onFrameDetached;
|
|
239
|
+
private onExecutionContextCreated;
|
|
240
|
+
private onExecutionContextDestroyed;
|
|
241
|
+
private onExecutionContextsCleared;
|
|
242
|
+
private onLifecycleEvent;
|
|
243
|
+
private waitForLifecycle;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
type ExpectSelectorOptions = {
|
|
247
|
+
timeoutMs?: number;
|
|
248
|
+
};
|
|
249
|
+
declare class ElementExpectation {
|
|
250
|
+
private frame;
|
|
251
|
+
private selector;
|
|
252
|
+
private options;
|
|
253
|
+
private negate;
|
|
254
|
+
private events;
|
|
255
|
+
constructor(frame: Frame, selector: string, options: ExpectSelectorOptions, negate: boolean, events: AutomationEvents);
|
|
256
|
+
get not(): ElementExpectation;
|
|
257
|
+
toExist(): Promise<void>;
|
|
258
|
+
toBeVisible(): Promise<void>;
|
|
259
|
+
toBeHidden(): Promise<void>;
|
|
260
|
+
toBeEnabled(): Promise<void>;
|
|
261
|
+
toBeDisabled(): Promise<void>;
|
|
262
|
+
toBeChecked(): Promise<void>;
|
|
263
|
+
toBeUnchecked(): Promise<void>;
|
|
264
|
+
toHaveText(textOrRegex: string | RegExp): Promise<void>;
|
|
265
|
+
toHaveExactText(textOrRegex: string | RegExp): Promise<void>;
|
|
266
|
+
toContainText(textOrRegex: string | RegExp): Promise<void>;
|
|
267
|
+
toHaveValue(valueOrRegex: string | RegExp): Promise<void>;
|
|
268
|
+
toHaveAttribute(name: string, valueOrRegex?: string | RegExp): Promise<void>;
|
|
269
|
+
toHaveId(idOrRegex: string | RegExp): Promise<void>;
|
|
270
|
+
toHaveName(nameOrRegex: string | RegExp): Promise<void>;
|
|
271
|
+
toHaveCount(expected: number): Promise<void>;
|
|
272
|
+
toHaveClass(nameOrRegex: string | RegExp): Promise<void>;
|
|
273
|
+
toHaveClasses(expected: string[]): Promise<void>;
|
|
274
|
+
toHaveCss(property: string, valueOrRegex: string | RegExp): Promise<void>;
|
|
275
|
+
toHaveFocus(): Promise<void>;
|
|
276
|
+
toBeInViewport(options?: {
|
|
277
|
+
fully?: boolean;
|
|
278
|
+
}): Promise<void>;
|
|
279
|
+
toBeEditable(): Promise<void>;
|
|
280
|
+
private assert;
|
|
281
|
+
}
|
|
282
|
+
declare class ExpectFrame {
|
|
283
|
+
private frame;
|
|
284
|
+
private events;
|
|
285
|
+
constructor(frame: Frame, events: AutomationEvents);
|
|
286
|
+
element(selector: string, options?: ExpectSelectorOptions): ElementExpectation;
|
|
287
|
+
}
|
|
288
|
+
declare function expect(page: Page): {
|
|
289
|
+
element: (selector: string, options?: ExpectSelectorOptions) => ElementExpectation;
|
|
290
|
+
frame: (options: {
|
|
291
|
+
name?: string;
|
|
292
|
+
urlIncludes?: string;
|
|
293
|
+
predicate?: (frame: Frame) => boolean;
|
|
294
|
+
}) => ExpectFrame;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
declare module "../core/Page.js" {
|
|
298
|
+
interface Page {
|
|
299
|
+
expect(): ReturnType<typeof expect>;
|
|
300
|
+
expect(selector: string, options?: ExpectSelectorOptions): ElementExpectation;
|
|
301
|
+
find: {
|
|
302
|
+
locators: (options?: {
|
|
303
|
+
highlight?: boolean;
|
|
304
|
+
outputPath?: string;
|
|
305
|
+
outputJson?: string;
|
|
306
|
+
outputHtml?: string;
|
|
307
|
+
}) => Promise<any[]>;
|
|
308
|
+
};
|
|
309
|
+
findLocators(options?: {
|
|
310
|
+
highlight?: boolean;
|
|
311
|
+
outputPath?: string;
|
|
312
|
+
outputJson?: string;
|
|
313
|
+
outputHtml?: string;
|
|
314
|
+
}): Promise<any[]>;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export { AutomationEvents as A, Connection as C, ElementExpectation as E, Frame as F, Logger as L, Page as P, type LogLevel as a, Locator as b, ExpectFrame as c, type ExpectSelectorOptions as d, expect as e };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { C as Connection, L as Logger, A as AutomationEvents, P as Page, a as LogLevel } from './expect-CY70zJc0.js';
|
|
2
|
+
export { F as Frame, b as Locator, e as expect } from './expect-CY70zJc0.js';
|
|
3
|
+
import { ChildProcess } from 'child_process';
|
|
4
|
+
|
|
5
|
+
declare class BrowserContext {
|
|
6
|
+
private browser;
|
|
7
|
+
private id;
|
|
8
|
+
constructor(browser: Browser, id: string);
|
|
9
|
+
getId(): string;
|
|
10
|
+
newPage(): Promise<Page>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
declare class Browser {
|
|
14
|
+
private connection;
|
|
15
|
+
private process;
|
|
16
|
+
private logger;
|
|
17
|
+
private events;
|
|
18
|
+
private cleanupTasks;
|
|
19
|
+
private contexts;
|
|
20
|
+
constructor(connection: Connection, child: ChildProcess, logger: Logger, events: AutomationEvents, cleanupTasks?: Array<() => void>);
|
|
21
|
+
on(event: "action:start" | "action:end" | "assertion:start" | "assertion:end", handler: (payload: any) => void): void;
|
|
22
|
+
newContext(): Promise<BrowserContext>;
|
|
23
|
+
newPage(options?: {
|
|
24
|
+
browserContextId?: string;
|
|
25
|
+
}): Promise<Page>;
|
|
26
|
+
disposeContext(contextId: string): Promise<void>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type LaunchOptions = {
|
|
31
|
+
headless?: boolean;
|
|
32
|
+
args?: string[];
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
logLevel?: LogLevel;
|
|
35
|
+
logEvents?: boolean;
|
|
36
|
+
logActions?: boolean;
|
|
37
|
+
logAssertions?: boolean;
|
|
38
|
+
executablePath?: string;
|
|
39
|
+
userDataDir?: string;
|
|
40
|
+
maximize?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
declare class AssertionError extends Error {
|
|
44
|
+
selector?: string;
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
lastState?: unknown;
|
|
47
|
+
constructor(message: string, options?: {
|
|
48
|
+
selector?: string;
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
lastState?: unknown;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type AutomatonLaunchOptions = LaunchOptions & {
|
|
55
|
+
logger?: Logger;
|
|
56
|
+
};
|
|
57
|
+
declare const automaton: {
|
|
58
|
+
launch(options?: AutomatonLaunchOptions): Promise<Browser>;
|
|
59
|
+
};
|
|
60
|
+
declare const chromium: {
|
|
61
|
+
launch(options?: AutomatonLaunchOptions): Promise<Browser>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { AssertionError, AutomationEvents, type AutomatonLaunchOptions, Browser, BrowserContext, LogLevel, Logger, Page, automaton, chromium };
|