python+selenium+AutoIt实现文件上传


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("导入栏目成功")

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM