UNPKG

n8n-nodes-playwright-mcp

Version:

Complete n8n Playwright node with all Microsoft Playwright MCP tools and AI assistant support for advanced browser automation

235 lines (234 loc) 6.23 kB
export interface IBrowserOptions { headless?: boolean; slowMo?: number; } export interface BrowserPaths { chromium: { windows: string[]; linux: string[]; darwin: string[]; }; firefox: { windows: string[]; linux: string[]; darwin: string[]; }; webkit: { windows: string[]; linux: string[]; darwin: string[]; }; } export interface IScreenshotOptions { fullPage?: boolean; path?: string; type?: 'png' | 'jpeg'; quality?: number; } export type PlaywrightOperation = 'navigate' | 'navigateBack' | 'navigateForward' | 'snapshot' | 'click' | 'hover' | 'drag' | 'selectOption' | 'type' | 'pressKey' | 'evaluate' | 'fileUpload' | 'handleDialog' | 'close' | 'resize' | 'consoleMessages' | 'networkRequests' | 'takeScreenshot' | 'waitFor' | 'tabList' | 'tabSelect' | 'tabNew' | 'tabClose' | 'install' | 'mouseMoveXY' | 'mouseClickXY' | 'mouseDragXY' | 'savePDF' | 'getText' | 'fillForm' | 'clickElement'; export interface IElementSelector { element?: string; ref?: string; selector?: string; } export interface IClickOptions extends IElementSelector { doubleClick?: boolean; button?: 'left' | 'right' | 'middle'; } export interface IDragOptions { startElement: string; startRef: string; endElement: string; endRef: string; } export interface ITypeOptions extends IElementSelector { text: string; submit?: boolean; slowly?: boolean; } export interface ISelectOptions extends IElementSelector { values: string[]; } export interface IEvaluateOptions extends IElementSelector { function: string; } export interface IFileUploadOptions { paths: string[]; } export interface IDialogOptions { accept: boolean; promptText?: string; } export interface IResizeOptions { width: number; height: number; } export interface IWaitOptions { time?: number; waitText?: string; textGone?: string; } export interface ITabOptions { index?: number; url?: string; } export interface ICoordinateOptions { element: string; x: number; y: number; } export interface IDragCoordinateOptions { element: string; startX: number; startY: number; endX: number; endY: number; } export interface IPDFOptions { filename?: string; dataPropertyName?: string; format?: 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal'; printBackground?: boolean; landscape?: boolean; } export interface IEnhancedScreenshotOptions extends IElementSelector { filename?: string; dataPropertyName?: string; imageType?: 'png' | 'jpeg'; fullPage?: boolean; quality?: number; } export interface IConsoleMessage { type: 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'count' | 'assert' | 'markTimeline' | 'profile' | 'profileEnd' | 'timeline' | 'timelineEnd' | 'time' | 'timeEnd' | 'timeStamp'; text: string; timestamp: string; location?: { url: string; lineNumber: number; columnNumber: number; }; } export interface INetworkRequest { url: string; method: string; headers: Record<string, string>; postData?: string; resourceType: string; status?: number; statusText?: string; responseHeaders?: Record<string, string>; timestamp: string; } export interface ITabInfo { index: number; url: string; title: string; active: boolean; } export interface IAccessibilityNode { role?: string; name?: string; value?: string; description?: string; keyshortcuts?: string; roledescription?: string; valuetext?: string; attributes?: Record<string, string>; children?: IAccessibilityNode[]; } export interface IPageSnapshot { url: string; title: string; snapshot: IAccessibilityNode | null; timestamp: string; } export interface IOperationResult { success: boolean; action: string; data?: any; error?: string; timestamp?: string; } export interface INavigationResult extends IOperationResult { url: string; title: string; content?: string; } export interface IInteractionResult extends IOperationResult { element?: string; ref?: string; selector?: string; } export interface IEvaluationResult extends IOperationResult { result: any; function: string; } export interface IScreenshotResult extends IOperationResult { url: string; filename?: string; imageType: string; fullPage: boolean; } export interface IPDFResult extends IOperationResult { url: string; filename?: string; } export interface ITabResult extends IOperationResult { tabs?: ITabInfo[]; index?: number; } export interface IConsoleResult extends IOperationResult { messages: IConsoleMessage[]; } export interface INetworkResult extends IOperationResult { requests: INetworkRequest[]; } export type PlaywrightCapability = 'core' | 'core-tabs' | 'core-install' | 'vision' | 'pdf'; export interface IPlaywrightConfig { capabilities?: PlaywrightCapability[]; browser?: { browserName?: 'chromium' | 'firefox' | 'webkit'; headless?: boolean; userDataDir?: string; executablePath?: string; }; timeout?: { default?: number; navigation?: number; element?: number; }; viewport?: { width: number; height: number; }; network?: { allowedOrigins?: string[]; blockedOrigins?: string[]; }; } export interface ILegacyOperationParams { operation: string; url?: string; selector?: string; value?: string; screenshotOptions?: IScreenshotOptions; dataPropertyName?: string; } export interface IAIToolContext { operation: PlaywrightOperation; parameters: Record<string, any>; pageState?: IPageSnapshot; capabilities: PlaywrightCapability[]; } export interface IAIToolSuggestion { operation: PlaywrightOperation; confidence: number; reasoning: string; parameters?: Record<string, any>; } export interface IPlaywrightError { code: string; message: string; operation: PlaywrightOperation; context?: Record<string, any>; }