跳转到主要内容

FileChooser

FileChooser 对象由页面通过 page.on("filechooser") 事件分发。

with page.expect_file_chooser() as fc_info:
page.get_by_text("Upload file").click()
file_chooser = fc_info.value
file_chooser.set_files("myfile.pdf")

方法

set_files

v1.9 之前添加 fileChooser.set_files

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

用法

file_chooser.set_files(files)
file_chooser.set_files(files, **kwargs)

参数

返回


属性

element

v1.9 之前添加 fileChooser.element

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

用法

file_chooser.element

返回


is_multiple

v1.9 之前添加 fileChooser.is_multiple

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

用法

file_chooser.is_multiple()

返回


page

v1.9 之前添加 fileChooser.page

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

用法

file_chooser.page

返回