-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplaywright.ts
More file actions
86 lines (76 loc) · 2.26 KB
/
playwright.ts
File metadata and controls
86 lines (76 loc) · 2.26 KB
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
/**
* Execute Playwright code against the browser instance.
*/
export class Playwright extends APIResource {
/**
* Execute arbitrary Playwright code in a fresh execution context against the
* browser. The code runs in the same VM as the browser, minimizing latency and
* maximizing throughput. It has access to 'page', 'context', and 'browser'
* variables. It can `return` a value, and this value is returned in the response.
*
* @example
* ```ts
* const response = await client.browsers.playwright.execute(
* 'id',
* { code: 'code' },
* );
* ```
*/
execute(
id: string,
body: PlaywrightExecuteParams,
options?: RequestOptions,
): APIPromise<PlaywrightExecuteResponse> {
return this._client.post(path`/browsers/${id}/playwright/execute`, { body, ...options });
}
}
/**
* Result of Playwright code execution
*/
export interface PlaywrightExecuteResponse {
/**
* Whether the code executed successfully
*/
success: boolean;
/**
* Error message if execution failed
*/
error?: string;
/**
* The value returned by the code (if any)
*/
result?: unknown;
/**
* Standard error from the execution
*/
stderr?: string;
/**
* Standard output from the execution
*/
stdout?: string;
}
export interface PlaywrightExecuteParams {
/**
* TypeScript/JavaScript code to execute. The code has access to 'page', 'context',
* and 'browser' variables. It runs within a function, so you can use a return
* statement at the end to return a value. This value is returned as the `result`
* property in the response. Example: "await page.goto('https://example.com');
* return await page.title();"
*/
code: string;
/**
* Maximum execution time in seconds. Default is 60.
*/
timeout_sec?: number;
}
export declare namespace Playwright {
export {
type PlaywrightExecuteResponse as PlaywrightExecuteResponse,
type PlaywrightExecuteParams as PlaywrightExecuteParams,
};
}