Skip to main content

FileChooser

FileChooser 对象会在页面的 Page.FileChooser 事件中被派发。

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

方法

🌐 Methods

Element

Added before v1.9 fileChooser.Element

返回与此文件选择器关联的输入元素。

🌐 Returns input element associated with this file chooser.

用法

FileChooser.Element

返回


IsMultiple

Added before v1.9 fileChooser.IsMultiple

返回此文件选择器是否接受多个文件。

🌐 Returns whether this file chooser accepts multiple files.

用法

FileChooser.IsMultiple

返回


Page

Added before v1.9 fileChooser.Page

返回此文件选择器所属的页面。

🌐 Returns page this file chooser belongs to.

用法

FileChooser.Page

返回


SetFilesAsync

Added before v1.9 fileChooser.SetFilesAsync

设置此选择器关联的文件输入的值。如果某些 filePaths 是相对路径,则它们相对于当前工作目录解析。对于空数组,会清除所选文件。

🌐 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.

用法

await FileChooser.SetFilesAsync(files, options);

参数

返回