(1)普通上传:将本地文件路径作为一个值放在input标签中,通过form表单将这个值提交给服务器
# 定位上传按钮,添加本地文件 driver.find_element_by_id("file").send_keys(file_path + "test.txt") # file_path 文件目录
(2)插件上传:一般指基于Falsh,JavaScript或Ajax等技术实现的上传功能,使用AutoIt实现,需要导入import os
下载工具-- 官方网站:https://www.autoitscript.com/site/
详细:selenium借助AutoIt识别上传(下载)详解 - 虫师 - 博客园
import os
os.system("C:\\Users\\upload11.exe")
文件内容:
ControlFocus("打开",“”,“Edit1”);
ControlSexText("打开",“”,“Edit1”,“C:\Users\aa.docx”);
ControlClick("打开“,“”,“Button1”)
需要au3格式转为exe格式