跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

FileChooser ​

Added in: v1.8

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

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

Methods ​

FileChooser.Element() ​

Added in: v1.8

Returns input element associated with this file chooser.

Returns

  • ElementHandle

FileChooser.IsMultiple() ​

Added in: v1.8

Returns whether this file chooser accepts multiple files.

Returns

  • boolean

FileChooser.Page() ​

Added in: v1.8

Returns page this file chooser belongs to.

Returns

  • Page

FileChooser.SetFilesAsync() ​

Added in: v1.8

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.

Arguments

  • files path | Array<path> | Object | Array<Object>

    • name string

      File name

    • mimeType string

      File type

    • buffer Buffer

      File content

  • options Object (optional)

基于 Apache 2.0 许可证发布。