Robot framework--12 rfs+autoitlibrary Test Web dialog box

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/tulituqi/article/details/21871247

Selenium2library is basically sufficient when we actually test the Web page, but there will be some cases that will be out of selenium2library control and cannot be manipulated. For example, when downloading files, to choose where to save the file, such as uploading files, to choose which file to upload, these in the selenium2library is not a good way to deal with. But the combination of the autoitlibrary, it can be very good to deal with. Combined with the content of Autoitlibrary 2, this article describes the Autoitlibrary Installation and dialog box processing, the next introduction upload download.

Two specific demo and testcase I have packed together, please download here, http://download.csdn.net/detail/tulituqi/7570453 (new link, previously expired)

Download unzip directly with ride open the inside tests see Code or run a case.

1, autoitlibrary Installation

Simply say install, the following 2 download, first install PYWIN32, and then install Autoitlibrary, unzip into the corresponding directory to execute Python setup.py install

Pywin32-217.win32-py2.7.exe (i downloaded 217, the latest seems to be 218, version more, please note that the PY version http://sourceforge.net/projects/pywin32/files/pywin32/)

Autoitlibrary-1.1.tar.gz (the above pywin32 must be installed, and Python's installation directory cannot have spaces, and if there is a space, there will be an error registering the AutoIt DLL.) Version is always 1.1, download path: http://code.google.com/p/robotframework-autoitlibrary/)

64-bit machine: In addition to installing the above 2, but also have to install a AutoItV3 (deadline for the latest official website: http://www.autoitscript.com/site/autoit-news/ autoit-v3-3-10-0-released/, if there is a later update, please download it from the homepage yourself. In general, this can be used after loading.

2. Autoitlibrary Object recognition

After the successful installation of Autoitlibrary, in your hard disk a packing directory will be more than one robotframework directory, the specific disk depends on which disk of your user directory, for example, my is in the D drive, so the more out of this directory is the following path:

D:\RobotFramework\Extensions\AutoItLibrary

Here are some assistive tools, such as Autoitx.chm is the help document, autoitlibrary.html is the test library's keyword document description, Au3Info.exe is the most important tool to identify objects.

In the Finder tool position there is a doji, you can use the mouse to drag him to the object you need to identify, like this:

Autoitlibrary's object operations are largely a few major parts, window operations, control operations, mouse operations, process operations, run operations, Reg operations, and some other operations.

One of the first three operations I am more commonly used, window and control should be better understand, you see the window is Windows, the Window button, text box, etc. is control. So when you usually want to manipulate the control, you typically need to activate the window before you manipulate the control.

Autoitlibrary mouse operation to use the real coordinates, which is slightly different from the coordinates in the Selenium2library, the next chapter will have examples.

Back, you can see the most important identified attributes, divided by two, in the upper left half, basic Window info, and basic Control info.

After I use many times, window recognition with title more, control mainly with Controlid,controlid is in basic Control info class+instance, for example, this object in the picture, His controlid is Edit1, the key word Strcontrol is ControlID (CHM is written controlid).

autoitlibrary keyword I do not introduce one by one, you can see the CHM Help or HTML keyword documents, but CHM is a native AutoIt document, for understanding the role of the keyword is helpful. The keyword document is just a list of all the keywords and parameters that are rarely explained.

3, Web dialog box A, you must have seen this dialog box, the previous one is only OK, there are ok to cancel 2 buttons.

b, you should have seen this dialog box.

C, there is the kind of pop-up on the Web page to enter the user password login box, I do not find examples here, also wood. (Find, see the bottom)

All of these can be handled with autoitlibrary.

For a, the confirm action in Selenium2library can be handled.

For B, C, it is better to use autoitlibrary, because the input of those text boxes is out of the selenium2library control.

First look at a this dialog box in selenium2library processing, the script is as follows:

One of the most important is the confirm action, by the way to popularize the relevant keywords

Choose Cancel on Next Confirmation

Choose Ok on Next Confirmation

These 2 keywords are actually specifically for a in the second kind, from the literal meaning can be understood, choose OK or Cancel in the next confirmation, please note that the next confirmation, that is, you must also use confirmation, Instead of using this is to choose OK or cancel, specifically to see the use of the script.

Take a look at the processing in autoitlibrary, the script is as follows:

I made a keyword to close the dialog box, which makes it easy to make repeated calls. This keyword implementation of the function I basically refer to the confirmation, in addition to click on the button, but also the message back, but I did not do choose Cancel part. The script for the specific keyword is as follows:

My Demo page has 3 buttons in the table above, payment, confirmation, input. Payments and confirmations are the type of a, and the input is type B.

My script only does a type a processing, other types of people please as practice do it.

If other types of things do not, you can refer to the next article.

Find c type, ie pop-up this window, you can also use autoitlibrary processing, there are similar situations can be practiced under their own.

Robot framework--12 rfs+autoitlibrary Test Web dialog box

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.