Skip to main content
Version: 23.8.0

ElementHandle.uploadFile() 方法

¥ElementHandle.uploadFile() method

输入元素 的值设置为给定的文件路径。

¥Sets the value of an input element to the given file paths.

签名

¥Signature

class ElementHandle {
abstract uploadFile(
this: ElementHandle<HTMLInputElement>,
...paths: string[]
): Promise<void>;
}

参数

¥Parameters

范围

类型

描述

this

ElementHandle<HTMLInputElement>

paths

string[]

Returns:

Promise<void>

备注

¥Remarks

这不会验证文件路径是否存在。另外,如果路径是相对路径,则根据 当前工作目录 进行解析。对于连接到远程 Chrome 环境的本地脚本,路径必须是绝对路径。

¥This will not validate whether the file paths exists. Also, if a path is relative, then it is resolved against the current working directory. For locals script connecting to remote chrome environments, paths must be absolute.