The insect master has a good article, the link is as follows: http://www.cnblogs.com/fnng/p/4188162.html
His article upload.exe the files that need to be uploaded, and the following content as a supplement.
If you do not want to write the upload process to die, for example, want to specify in the program to upload files, the file path as a parameter to Upload.exe for uploading, is also possible, AutoIt can use parameterization to do this, see the following AutoIt script:
[Plain]View PlainCopy
- Controlfocus ("Open", "", "Edit1")
- Winwait ("[CLASS: #32770]", "", 10)
- Controlsettext ("Open", "", "Edit1", $CmdLine [1])
- Sleep (2000)
- Controlclick ("Open", "" "," Button1 ");
The above code specifies that the open window name is open and uses $cmdline[1] to specify the unique parameters that Upload.exe requires. The Python code that calls the Upload.exe is as follows:
[Python]View PlainCopy
- browser.find_element_by_id ("Crop_logo"). Click () #首先需要使用webdriver点击web页面的控件, when the Upload file dialog box pops up, The AutoIt script can find the Upload File dialog box and perform the preset action in the AutoIt script.
- # Upload.exe receive a parameter, is to upload the file path, currently only support the Upload file dialog box is "Open" Windows window
- exe_path=base_dir+"\\resource\\upload.exe"
- file_path=base_dir+"\\resource\\img.png"
- cmd=exe_path+"" +file_path
- Ps=subprocess. Popen (CMD)
- Ps.wait ()
Note: Calling Upload.exe can also use the Subprocess module, which is better than OS modules.
As follows:
[Python]View PlainCopy
- Ps=subprocess. Popen (CMD)
- Ps.wait ()
Understanding the implementation of the upload process, the download is the same.
Upload Download dialog box (parametric) with AutoIt operation