/** * Download Handler * * P1 - File download management * * Supports: * - Click and wait for download * - Download verification * - Multiple downloads handling * - Download timeout * - File size validation * * @see https://playwright.dev/docs/downloads */ export interface DownloadConfig { /** Download directory */ downloadDir?: string; /** Timeout for download to start (ms) */ timeout?: number; /** Save downloaded files */ saveFiles?: boolean; } export interface DownloadInfo { /** Suggested filename */ filename: string; /** Save path (if saved) */ path?: string; /** Download URL */ url?: string; /** File MIME type */ mimeType?: string; /** File size in bytes */ size?: number; /** Download timestamp */ timestamp: number; } export interface DownloadActionOptions { /** Action to perform before download (click, hover, etc) */ action?: 'click' | 'dblclick' | 'hover'; /** Wait for download to complete */ waitForCompletion?: boolean; /** Timeout (ms) */ timeout?: number; } export interface DownloadVerification { /** Expected filename pattern */ filenamePattern?: string | RegExp; /** Minimum file size (bytes) */ minSize?: number; /** Maximum file size (bytes) */ maxSize?: number; /** Expected MIME type */ mimeType?: string; } export interface DownloadResult { success: boolean; download?: DownloadInfo; rawDownload?: any; error?: string; } /** * Download Handler class */ export declare class DownloadHandler { private downloads; private downloadDir; private defaultTimeout; private saveFiles; private stats; constructor(config?: DownloadConfig); private ensureDownloadDir; /** * Setup download handling for a page */ setupDownloadHandler(page: any): void; /** * Click element and wait for download */ clickAndWaitForDownload(page: any, selector: string, options?: DownloadActionOptions): Promise; /** * Click multiple elements and wait for downloads */ clickAndWaitForDownloads(page: any, selectors: string[], options?: DownloadActionOptions): Promise>; /** * Wait for download by filename pattern */ waitForDownload(page: any, filenamePattern: string | RegExp, timeout?: number): Promise; /** * Verify a download */ verifyDownload(download: any, verification: any): Promise; /** * Get all downloads */ getAllDownloads(): DownloadInfo[]; /** * Get download by filename */ getDownload(filename: string): DownloadInfo | undefined; /** * Get last download */ getLastDownload(): DownloadInfo | undefined; /** * Clear all downloads */ clearDownloads(): void; /** * Delete downloaded files */ clearDownloadFiles(): Promise; /** * Get download directory */ getDownloadDir(): string; /** * Set download directory */ setDownloadDir(dir: string): void; /** * Get download count */ get downloadCount(): number; /** * Assert download exists */ assertDownloadExists(filenamePattern: string | RegExp): DownloadResult; /** * Get download statistics */ getStats(): { totalDownloads: number; successfulDownloads: number; failedDownloads: number; totalSize: number; averageSize: number; }; /** * Get download history */ getHistory(): DownloadInfo[]; /** * Reset statistics */ resetStats(): void; } /** * Factory function to create Download Handler */ export declare function createDownloadHandler(config?: DownloadConfig): DownloadHandler; export default DownloadHandler;