Upload Download dialog box (parametric) with AutoIt operation

Source: Internet
Author: User

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
    1. Controlfocus ("Open", "", "Edit1")
    2. Winwait ("[CLASS: #32770]", "", 10)
    3. Controlsettext ("Open", "", "Edit1", $CmdLine [1])
    4. Sleep (2000)
    5. 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
    1. 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.
    2. # Upload.exe receive a parameter, is to upload the file path, currently only support the Upload file dialog box is "Open" Windows window
    3. exe_path=base_dir+"\\resource\\upload.exe"
    4. file_path=base_dir+"\\resource\\img.png"
    5. cmd=exe_path+"" +file_path
    6. Ps=subprocess. Popen (CMD)
    7. Ps.wait ()

Note: Calling Upload.exe can also use the Subprocess module, which is better than OS modules.

As follows:

[Python]View PlainCopy
    1. Ps=subprocess. Popen (CMD)
    2. Ps.wait ()


Understanding the implementation of the upload process, the download is the same.

Upload Download dialog box (parametric) with AutoIt operation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.