inupt label can upload files directly through send_keys
Non-input label, AutoIt upload
1. Install AutoIt
2.AutoIt menu Introduction
SciTE Script Editor Editor for writing AutoIt script
AutoIt Windows Info element locator, information used to identify Windows Controls
Run Script AutoIt script execution
Compile Script to.exe AutoIt will generate an executable file
3. step file uploads:
a. Positioning windows control elements
. B Open SciTE Script Editor editor to write code as follows:
WinActivate ( "file upload")
ControlSetText ( "file upload", "", "Edit1", $ CmdLine [1])
# ControlSetText ( "file upload", "", "Edit1", "D: \ 1.png")
Sleep(2000)
ControlClick ( "file upload", "", "Button1")
c. Save the file .au3 (Editor can go run the debugger)
d. Open the Compile Script to.exe AutoIt generated executable file exe
No parameterization step b, can be performed cmd exe file: a file is added to the window opening, the implementation of the cmd exe file
Such as: D: \ text.exe
There parameterization step b, can be performed cmd exe file / au3 file, adding a file name, such as: D: \ text.au3 a.txt
e. python execute the exe
import os
os.system (r "D: \ text.exe") # non-parametric wording
jpg = "D \ 1.jpg"
os.system (r "D: \ text.au3% s"% jpg) # writing has parameterized
4. Batch upload pictures, a for loop
Method one: first to upload the picture on the next list, then the for loop
all_png = [“D:\\1.png”, “D:\\2.png”]
for i in all_png:
# 1 points to open the picture editor
# 2 points to open the Upload File button
# 3. Do autoit upload files
os.system(“D:\text.exe %s” % i)
time.sleep(3)
Method Two: To upload the file number, starting from 0, such as: 0.png, 1.png. Into the same directory, then the for loop
for i in range(4):
# 1 points to open the picture editor
# 2 points to open the Upload File button
# file name
file_name = "D: \\% s.png"% i # parametric path name
# Execute autoit upload files
os.system(“D:\text.exe %s” % file_name)
time.sleep(3)