Table of Contents

Interface IFileChooser

Namespace
Microsoft.Playwright
Assembly
Microsoft.Playwright.dll

IFileChooser objects are dispatched by the page in the FileChooser event.

var fileChooser = await page.RunAndWaitForFileChooserAsync(async () =>
{
    await page.GetByText("Upload file").ClickAsync();
});
await fileChooser.SetFilesAsync("temp.txt");
public interface IFileChooser

Properties

Element

Returns input element associated with this file chooser.

IElementHandle Element { get; }

Property Value

IElementHandle

IsMultiple

Returns whether this file chooser accepts multiple files.

bool IsMultiple { get; }

Property Value

bool

Page

Returns page this file chooser belongs to.

IPage Page { get; }

Property Value

IPage

Methods

SetFilesAsync(FilePayload, FileChooserSetFilesOptions?)

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.

Task SetFilesAsync(FilePayload files, FileChooserSetFilesOptions? options = null)

Parameters

files FilePayload
options FileChooserSetFilesOptions

Call options

Returns

Task

SetFilesAsync(IEnumerable<FilePayload>, FileChooserSetFilesOptions?)

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.

Task SetFilesAsync(IEnumerable<FilePayload> files, FileChooserSetFilesOptions? options = null)

Parameters

files IEnumerable<FilePayload>
options FileChooserSetFilesOptions

Call options

Returns

Task

SetFilesAsync(IEnumerable<string>, FileChooserSetFilesOptions?)

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.

Task SetFilesAsync(IEnumerable<string> files, FileChooserSetFilesOptions? options = null)

Parameters

files IEnumerable<string>
options FileChooserSetFilesOptions

Call options

Returns

Task

SetFilesAsync(string, FileChooserSetFilesOptions?)

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.

Task SetFilesAsync(string files, FileChooserSetFilesOptions? options = null)

Parameters

files string
options FileChooserSetFilesOptions

Call options

Returns

Task