ElementHandle.uploadFile() 方法
🌐 ElementHandle.uploadFile() method
将input 元素的值设置为给定的文件路径。
🌐 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
范围 🌐 Parameter | 类型 🌐 Type | 描述 🌐 Description |
|---|---|---|
this | ElementHandle<HTMLInputElement> | |
paths | string[] |
返回:
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.