SELENIUM2 python automated testing using the AutoIt tool for local file uploads

Source: Internet
Author: User

SELENIUM2 python automated testing using the AutoIt tool for local file uploads

I'm learning based onPythonlanguage ofselenium2During the automated test method, when a test involving a local upload file is found,selenium2when locating localwindowThere is limited capacity on the object (element) of the window. When the upload button is using theinputlabel, you can use theSend_keys ()method to add a local file path is easy to implement, but some upload controls use ainputelement, this timeSend_keys ()method is not feasible. Through online search and practice, summed up a very simple and effective method-borrowingAutoIttools to automate the local upload of files, here to share with you.

1, AutoIt Introduction and Installation

   autoit Yes one BAS Free software for the IC scripting language, which is designed for use in the Windows GUI (graphical user interface) for

official: https://www.autoitscript.com/site/

once downloaded and installed successfully, you can see in the Start menu The AutoIt tool, as shown in:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/88/A0/wKiom1f9pp2AGpOYAABxI89URO4756.png "title=" Picture 1.png "alt=" Wkiom1f9pp2agpoyaabxi89uro4756.png "/>

AutoIt Window Info: used to identify Windows Control information

Compile script To.exe: converting scripts written by AutoIt to executable files

Run script: for executing AutoIt Scripts

SciTE script Editor: for writing AutoIt Scripts

2, the use of methods and procedures

( 1 open autoit window Info tool, use it for positioning Windows gui ( Windows interface) elements

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/88/A0/wKiom1f9pqyx8np-AABYSmVKiYE952.png " title= "Picture 2.png" alt= "Wkiom1f9pqyx8np-aabysmvkiye952.png"/>

To upload a picture from your local computer (e.g.), click on the "create creative footage" button,

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/88/9D/wKioL1f9prugLryHAAB9naSwv3Y710.png " title= "Picture 3.png" alt= "Wkiol1f9pruglryhaab9naswv3y710.png"/>

pop-up file upload box:

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/88/A0/wKiom1f9psuAJ6UmAAE_a72z-_E844.png " title= "Picture 4.png" alt= "Wkiom1f9psuaj6umaae_a72z-_e844.png"/>

then switch to the previously opened AutoIt Window Info tool, find findertools, mouse click The small fan icon in Finder tool, The mouse becomes a movable small fan icon, hold down the left mouse button drag to the File upload box filename input box, write down the Class as Edit,Instance is 1

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/88/9D/wKioL1f9pt3z_kLxAAFKNmDR_AE713.png "title=" Picture 5.png "alt=" Wkiol1f9pt3z_klxaafknmdr_ae713.png "/>

Similarly, using the same method, get the "open" button of Class button,instance to 1

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/88/9D/wKioL1f9pu2Qu-ZZAAFTo0x6U_E987.png "title=" Picture 6.png "alt=" Wkiol1f9pu2qu-zzaafto0x6u_e987.png "/>

(2) open scite Script according to the control information recognized by AutoIt Window info Editor , scripting:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/88/A0/wKiom1f9pwWBwQLAAACWfpulCL4539.png "title=" Picture 7.png "alt=" Wkiom1f9pwwbwqlaaacwfpulcl4539.png "/>

when the script is written, click Tools->go, run the script.

(3) The script runs normally, open the Compile script to. exe tool under Setup and convert the script to an executable file, such as. This executable file can be called by a python program

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/88/A0/wKiom1f9pxfSsYCOAAD5zTVO5zY256.png " title= "Picture 8.png" alt= "Wkiom1f9pxfssycoaad5ztvo5zy256.png"/>

Click the Browser button, select the compiled script upload.au3, and click the Convert button to convert it to executable . EXE file

( 4 ) through python Automated test scripts invoke the upload.exe file for automated uploads

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/88/A0/wKiom1f9pyzztbanAAB9gnfv9nI922.png "title=" Picture 9.png "alt=" Wkiom1f9pyzztbanaab9gnfv9ni922.png "/>

SELENIUM2 python automated testing using the AutoIt tool for local file uploads

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.