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代碼,實現文件上傳
def column_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("導入欄目成功")