1) 下载并安装AutoIt工具:https://pan.baidu.com/s/1bz3Z9G
2) 打开文件上传弹框,打开AutoIt Window Info(x64),定位文件输入框和打开按钮
3) 使用SciTe Script Editor编写脚本:
ControlFocus("打开", "", "Edit1")
WinWait("[CLASS:#32770]", "", 10)
ControlSetText("打开", "", "Edit1", $CmdLine[1])
Sleep(2000)
ControlClick("打开", "", "Button1")
4) 保存脚本文件为upload.au3,将文件upload.au3转换成可执行文件upload.exe
5) 编写python代码,实现文件上传
defcolumn_import(self):
#点击导入栏目self.find_element(self.column_import_button_loc).click()
#点击选择文件time.sleep(2)
self.find_element(self.choice_file_button_loc).click()
time.sleep(1)
os.system("F:\\A_TRS_TRSWorkFile\\python_selenium\\WCM8.0_20180124\\upload.exe F:\\A_TRS_TRSWorkFile\\python_selenium\\WCM8.0_20180124\\cloumnupload.zip ")
time.sleep(5)
self.find_element(self.column_import_ok_button_loc).click()
print("导入栏目成功")