QTP tutorial

The basic usage of QTP (six steps)
  QTP takes the unique Keyword View as its core idea, so that testers with weak development capabilities are able to participate in the writing of automated test scripts. At the same time, its unique Active Screen technology makes writing automated scripts visible, and each line of script can find the corresponding program interface. In addition to Keyword View, QTP also provides Expert View, which uses vb syntax and is specially prepared for testers with strong development capabilities. QTP also provides the concept of Object Repository, which stores all the information on the page as a tree structure of parent-child objects. For example, a page is a parent object and various web controls inside are child objects.

Step 1: Record the script

Click Record to start recording the script, of course you can set it first, in Automation–>Record and run settings. Generally use the basic recording mode, which uses UI objects and attributes to record while capturing various events, such as mouse clicks (you can set the type of capture event). Some operations such as minimizing the IE window will not be recorded. I don’t know how to record the mouse wheel event for the time being. . Right!

Step 2: Play back the script

Click Run to replay the current script. Of course, if you select Record and run any open browser when recording, you need to open the web page first (nonsense, everyone knows)

Step 3: See if the script runs successfully

If it goes well, the result page will automatically appear after Run. In the result page, pass is 0 and fail is also 0. Because there is no verification point, there is no right or wrong.

Step 4: Insert verification point

That is, the desired result, most of the verification points can be inserted during recording or after all recording. During recording, you can click Insert on the toolbar. After recording, you can right-click the object to be checked in the Active Screen window, and then select the corresponding verification point type in the right-click menu.

Commonly used verification points:

a. For text checkpoint, first select a piece of text, then right-click on the text, select insert text checkpoint, and select Constant or Parameter in the pop-up dialog box. The constant is very simple, with a fixed expected value, and Parameter parameterized verification See the detailed explanation below;

b. Picture type verification point, as the name implies, select a picture, right-click, and select Insert standard checkpoint

c. Bitmap type verification point, you can right-click anywhere in Active View, select Insert Bitmap checkpoint, and then select part of the area as the comparison object in the pop-up dialog box (this is more helpful for my 3D project *.*)

d. There are many others, such as form verification points, page verification points, database verification points, page verification points...

After inserting the verification point and then Run again, you can see whether it is pass or fail.

Step 5: Parameterized test

First, explain the data table. When testing, users often want to use different test data for a certain function to perform multiple repeated tests to achieve coverage of various boundary values ​​and logical paths. For example, if the user wants to perform 10 times repeatedly, then the user Need to record 10 scripts? Definitely not needed! Because we only need to record once and then we can use the data table function to create 10 data per row to loop (QTP will automatically loop).

Each Action has its own data table. For example, the default Action1 has a corresponding Action1 data table. In addition, all actions can share a Global data table. A data table is like an Excel table, each column is a parameter, and each row is an expected input (it can be imagined that how many rows means how many test cases and how many times the script is repeated).

The parameterization method is very simple, see below:

In the Keyword View, select the information that needs to be parameterized. If the user name when registering, and then click behind the Value cell of the test step, this time select Parameter in the pop-up dialog box, the default is the DataTable data table, the following Name is the parameter name is the column name in the data table, finally select a DataTable and click OK. Then switch to the data table window, you will see one more column (if the parameter name in Name already exists, then a new column will not be generated, but the information will be bound to the existing parameter).

Then, you can enter the expected parameters line by line in the DataTable, click Run, OK!

Step 6: Output value function

QTP can not only directly parameterize the expected input, but also output part of the data to the data table for use by other objects during operation. For example, if you need to fill in the password twice during registration, you can use the first password as the output value. The output value can correspond to a parameter name/column like the parameterization in step 4, and then the second password is bound to the parameter . In this way, the password entered for the first time will become the parameter value entered for the second time, ensuring the consistency of the second password.

Reference link:

Guess you like

Origin blog.csdn.net/shanlijia/article/details/107860089