1、下載與安裝AutoIt v3 地址鏈接:http://pan.baidu.com/s/1hqsDFBA,我自己是32位的系統,用這個運行可以
2、安裝完成后,如下圖所示
3、 AutoIt Windows Info 用於幫助我們識 Windows 控件信息。
Compile Script to.exe 用於將 AutoIt 生成 exe 執行文件。
Run Script 用於執行 AutoIt 腳本。
SciTE Script Editor 用於編寫 AutoIt 腳本
4、上傳一個html備用upfile.html
<html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <title>upload_file</title> <link href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <div class="row-fluid"> <div class="span6 well"> <h3>upload_file</h3> <input type="file" name="file" /> </div> </div> </body> <script src="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.js"></script> </html>
5、 通過瀏覽器打開upfile.html,效果如下圖所示(建議用火狐打開)
6、 此時打開AutoIt Window Info,鼠標點擊 Finder Tool,鼠標將變成一個小風扇形狀的圖標,按住鼠標左鍵拖動到需要識別的控件上。
7、首先需要識別的是文本框。
8、識別文本框后,就要在該文本框中輸入文件路徑,之后就是點擊【打開】按鈕,所以嘞,待會還要按照步驟7定位下按鈕的位置。按照這個思路打開SciTE Script Editor,編輯腳本
;ControlFocus("title","text",controlID) Edit1=Edit instance 1
ControlFocus("文件上傳", "","Edit1")
; Wait 10 seconds for the Upload window to appear
WinWait("[CLASS:#32770]","",10)
; Set the File name text on the Edit field
ControlSetText("文件上傳", "", "Edit1", "D:\upload_file.txt")
Sleep(2000)
ControlClick("文件上傳", "", "Button1")
; Click on the Open button
9、 將上面的文件保存成11.au3文件
10、將11.au3轉化成exe文件,因為exe文件可以直接執行
11、 打開Compile Script to .exe,我是32位的,直接如下圖所示就可以了
12、 打開ride,直接上代碼
open browser file:///C:/Users/Administrator/Desktop/11.html
click element xpath=/html/body/div/div/input
sleep 2
evaluate os.system('C:/Users/Administrator/Desktop/11.exe') os
13、直接執行,報告pass了。界面上顯示有添加本地文件,但是不知道為什么有這樣的錯誤,歡迎大家拍磚