File: class-filechooser.md | Updated: 11/18/2025
On this page
FileChooser objects are dispatched by the page in the Page.onFileChooser(handler) event.
FileChooser fileChooser = page.waitForFileChooser(() -> page.getByText("Upload file").click());fileChooser.setFiles(Paths.get("myfile.pdf"));
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.setFiles
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
FileChooser.setFiles(files);FileChooser.setFiles(files, options);
Arguments
options FileChooser.SetFilesOptions (optional)
setNoWaitAfter boolean
(optional)#
Deprecated
This option has no effect.
This option has no effect.
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