effect-playwright
    Preparing search index...

    Interface FileChooser

    FileChooser objects are dispatched by the page in the page.on('filechooser') event.

    // Start waiting for file chooser before clicking. Note no await.
    const fileChooserPromise = page.waitForEvent('filechooser');
    await page.getByText('Upload file').click();
    const fileChooser = await fileChooserPromise;
    await fileChooser.setFiles(path.join(__dirname, 'myfile.pdf'));
    interface FileChooser {
        element(): ElementHandle;
        isMultiple(): boolean;
        page(): Page;
        setFiles(
            files:
                | string
                | readonly string[]
                | { buffer: Buffer; mimeType: string; name: string }
                | readonly { buffer: Buffer; mimeType: string; name: string }[],
            options?: {
                noWaitAfter?: boolean;
                signal?: AbortSignal;
                timeout?: number;
            },
        ): Promise<void>;
    }
    Index
    • Returns input element associated with this file chooser.

      Returns ElementHandle

    • Returns whether this file chooser accepts multiple files.

      Returns boolean

    • Returns page this file chooser belongs to.

      Returns Page

    • Sets the value of the file input this chooser is associated with. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files.

      Parameters

      • files:
            | string
            | readonly string[]
            | { buffer: Buffer; mimeType: string; name: string }
            | readonly { buffer: Buffer; mimeType: string; name: string }[]
        • string
        • readonly string[]
        • { buffer: Buffer; mimeType: string; name: string }
          • buffer: Buffer

            File content

          • mimeType: string

            File type

          • name: string

            File name

        • readonly { buffer: Buffer; mimeType: string; name: string }[]
      • Optionaloptions: { noWaitAfter?: boolean; signal?: AbortSignal; timeout?: number }

      Returns Promise<void>