File: class-filechooser.md | Updated: 11/18/2025
On this page
FileChooser objects are dispatched by the page in the Page.FileChooser event.
var fileChooser = await page.RunAndWaitForFileChooserAsync(async () =>{ await page.GetByText("Upload file").ClickAsync();});await fileChooser.SetFilesAsync("temp.txt");
Methods
Added before v1.9 fileChooser.Element
Returns input element associated with this file chooser.
Usage
FileChooser.Element
Returns
Added before v1.9 fileChooser.IsMultiple
Returns whether this file chooser accepts multiple files.
Usage
FileChooser.IsMultiple
Returns
Added before v1.9 fileChooser.Page
Returns page this file chooser belongs to.
Usage
FileChooser.Page
Returns
Added before v1.9 fileChooser.SetFilesAsync
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.
Usage
await FileChooser.SetFilesAsync(files, options);
Arguments
files string
| IEnumerable
<string
> | FilePayload | IEnumerable
<FilePayload>#
options FileChooserSetFilesOptions? (optional)
NoWaitAfter bool
? (optional)#
Deprecated
This option has no effect.
This option has no effect.
Timeout [float]? (optional)#
Maximum time in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the BrowserContext.SetDefaultTimeout()
or Page.SetDefaultTimeout()
methods.
Returns