Basic functions of qtp

Source: Internet
Author: User
Tags failover

? Basic functions of qtp
HP quicktest professional supports Function Testing and regression testing, which are used in every major software application and environment. This solution uses the keyword-driven idea to simplify the idea creation and maintenance process. It allows the testers to use professional capture technology to capture the process directly from the application screen to build a trial case. The testing experts can also thoroughly explain internal testing and object attributes through the Integrated script and debugging environment.
? Qtp Framework Structure
Take test as the Execution Unit of the test. Each test contains several types of actions. Take action as the most
Small unit ing Object Library, multiple actions can be shared and unified
The steps in the object library and action can include user recording operations or
Function calls in the function library.

The basic process of qtp proactive failover
? Record a trial script
? Edit the trial script
? Debug the trial script
? Execute the trial script
? Analyze the test results
Record a trial script
1. plugin loading settings Management
Start qtp and the displayed plug-in management interface is displayed.

Select the plug-in to be loaded based on the control type of the tested application. For example, the qtp built-in example application "flight" is a standard windows program, and some of the controls are ActiveX controls, therefore, select to load ActiveX control during the trial.
2. Recording and replaying settings
After selecting the plug-in to be loaded, click okbutton to go to the main interface of qtp. For example, what you see includes the trial view (keyword view and expert attempt ), data Table/information interface and Active Screen Interface.

Select automation | record and run settings. The recording and execution settings page is displayed.
Specifies the application to be recorded. The recording execution setting interface is shown in the following figure. On the recording and execution page of the Windows application, you can select two recording modes, one is "record and run test on any open windows-bassed", which can be used to record programs that appear in the system; the second method is the "record and run only on" Method for recording targeted applications to avoid recording unnecessary interfaces. There are three ways to use this method.
(1) Select the "Application opened by quicktest" option to record and execute only programs called by qtp.
(2) Select the "Application opened via the startup pot" option, then only the Start menu is recorded and the desktop shortcut is started.
(3) Select "application specified below" to record and execute the application added to the List. Click button to add the path of the executable file to be recorded.
For example, if you want to record the "flight" example program, select the path "C: \ Program Files \ Mercury Interactive \ quicktest Professional \ samples \ flight \ app \ flight4a.exe"

3. Record the first test script of active failover
After setting it to only record the "flight" program, select automation | record from the menu, or press the shortcut key F3 on the toolbar. qtp automatically starts the specified folder.
For example, enter username and password "Mercury" and click OK.
Button to record the login process of the "flight" Program

Press the "stop" button or press F4 to stop recording. The recording result is displayed.

Keyword View:

Expert View:


In the key-word view, you can see the operation steps of the record's trial. Each of the trial steps and interface operations are displayed on the "Active Screen" page.
In this way, we have completed the compilation of one of the most important ghost trial examples. We need to make further changes to the recorded ghost script. These work can be done in the keyword view, it can also be done in the expert view.
Edit the trial script
1. Edit the trial script in the keyword View
(1) Add the gaze to the trial steps in the keyword View
In the keyword view, right-click the column header and select "comment". An additional column named "comment" appears ", in this column, you can add a gaze for each trial step.


2) Add the Token test information output to the keyword view.
If you want to input the corresponding trial information to the trial report after a trial step is completed, right-click the trial step and choose "insert step | report ", the page is displayed.
For example, report "Start login" before activating the "login" Interface"
In the "status" drop-down box on the page, select "retry ".
Report status (which can be done, passed,
One of the four shapes, failed and warning)
Enter the information abstract in "name", and in "details"
Enter specific information

After joining the report

(3) Insert a checkpoint
Check all checkpoint sub-menu items in the checkpoint, including text, bitmap, XML, and database (data table) check points. The running result of each checkpoint will have corresponding records in automation-result, and some checkpoints must be recorded for use.
You can also right-click the trial procedure and choose "insert standard checkpoint" from the shortcut menu.

For example, we check the okbutton attributes and insert a standard checkpoint.
First, locate the OK submission step, right-click,
Select Insert Standard
Checkpoint ", as shown in the figure on the right.
Select the attribute to be checked in the interface, for example, select
"Enableed" attribute, set to true, and select "text"
Attribute, set "OK ".


Click "OK" button and you will be able to see it in the keyword view.
The new checkpoint step, for example

(4) Insert a new sequence in the keyword View
For example, before entering the password, you need to click "help" button to view help. In this case, you need to add the retry step for clicking "help" button.
First, go to the step for entering username, right-click the username, and select "insert step | step generator". The page on the left is displayed, "Category" includes "test object", "utility object", and "function", which respectively represent the following:
Meaning:
Test object: The testing object, that is, the interface of the program to be destroyed
The control element on the page.
Utility object: tool object, which is built in qtp
Various developers who write the test scripts to help them establish the test Logic
Class Object
Function: various functions, including library functions and built-in functions
Function, a local script function.
Here, we select "test object" and then click
Click the icon button next to the "object" drop-down box.

The Select object interface appears, as shown in the left figure. Select the help object on the interface, and click OK to return to the step Generator interface, select "click" in the "operation" drop-down box and select the "insert another step" option.
(If no help object exists in the object list on the select object for Step interface, you can click
Type button, and then move to the "login" Field of the flight program
And select the "help" button from the object.
Click "OK" button to add the "help" button to the trial.
Object List)


Click "insert" button to return to the keyword view. You can see that the new trial steps have been added,

2. Edit the trial script in the expert view
"Expert view" is a powerful VBSCRIPT script editor. Here, you can directly write the code of the trial script. It is suitable for you to be familiar with the VBScript language, I have good programming skills to take the initiative to test the use of project engineers.
The script editor provided by qtp supports the "syntax awareness" function. For example, if you enter "dialog (" login ") in the Code and add some values, you can automatically display a drop-down list, you can select all the attributes and methods included in the "login" trial object,

Debug the trial script
1. syntax check
Select "Tools | check Syntax" from the menu, select a button from the toolbar, or press the shortcut key "Ctrl + F7" to check the syntax of the trial script. If the syntax check is successful, the prompt information is displayed on the "information" page, for example

If the syntax check finds a problem, the specific information will be listed on the "information" interface, for example

2. Use breakpoints
After the syntax check is passed, you can directly execute the code or set breakpoints to debug the script. You can use the shortcut key "F9", click the border of the line where the code is located, or press the button on the toolbar to set the breakpoint.


Then, press F5 or button to stop the execution process at the breakpoint ,. At this time, you can perform single-step debugging, select "Debug | step over", or press the shortcut key "F10" to execute the next line of code, or select "Debug | step ", or press the shortcut key "F11" to enter the function called in the code line.

Then, press F5 or run button to stop the execution process at the breakpoint ,. At this time, you can perform single-step debugging, select "Debug | step over", or press the shortcut key "F10" to execute the next line of code, or select "Debug | step ", or press the shortcut key "F11" to enter the function called in the code line.

Use of the debug Viewer
During debugging, you can select "View | debug viewer" to display the debugging viewer,
You can see the property or variable value of the object to be tested.

Execute the trial script
1. Execute the entire trial. After the syntax check and debugging are correct, you can press F5 to execute the entire trial script. Before performing the explain test, you can make necessary settings for the execution. Select "Tools | options" in the menu, and an interface is displayed.

The "run mode" execution mode is normal.
Or fast

"View results when run
Session end
Open the trial result page

"Allow other mercury produncts
To run test "agrees with other mercury's
Tool call qtp

"Save still image captures
Results "saves exquisite images to the results

2. Execute partial retry tests.
If there are multiple actions, you can locate the action to be executed and select "automtion | run current action" from the menu to execute the current action. This helps you locate the problem of the current action.
Another method is to execute partial test. You can right-click a test step and choose "run from step" from the menu ", you can execute the trial from the current trial start, or select "Run To step" to execute the trial steps selected from the beginning.
3. Execute the retry test in batches.
The "test batch runner" tool provided by qtp can be used"
To execute the retry script in batches. You must
In "Tools | options", make sure
"Allow other mercury
Products to run test option
Selected.
Open from the Start Menu
"Test batch runner" tool, select
"Batch | Add" to add the retry script to be executed,
Select "batch | run" to execute all
Testing script

Analyze the test results
1. Select the storage location of the trial result
In qtp, execute the retry script. A dialog box is displayed.
If you select "new run results folder", you can select a folder for this test to store the test results file. If you select "temporary run results folder", then qtp places the execution of the Token test result in the default folder and overwrites the Token test result in the previous folder.

2. view the summary of the trial results
After the trial script is executed, you can view the summary result on the page, including the name, start time, end time, and number of iterations of the trial. Status.

3. view the checkpoint result
In the left-side form of the test result, all the test steps are displayed in a tree structure. If you select the node cheeckpoint "OK", you can see the results.

Qtp Script Development
? Keyword driver ghost Test
? Data-driven trial
? Descriptive programming with qtp
Keyword driver ghost Test
1. What is the keyword driver retry method?
The keyword-driven testing method is also called the table-driven testing method. Keyword-driven NLP test separates the programming work of the NLP test script, so that those who do not have programming skills can develop their own active NLP test script.
The keyword-driven NLP test mainly depends on the active framework. By using the self-automation framework, you only need to test the development of tables and keyword. The framework runs the test script by interpreting table data and keyword to drive the application to be merged. This can be clearly reflected in the keyword view of qtp. For example, you can use the following sequence table to complete a sequence test for the Windows Calculator.

2. Edit the Object Library
The first step of using the keyword driving framework of qtp to perform an active Token test is to collect the information of the Token Test object and store it in the object repository ).
To add an object to the benchmark test, select "Resources | Object repository" and open the "Object repository-all object repositories" dialog box, as shown in the left.
Take the calculator program as an example. Select "oboject | add object to local" and jump
Calculator Application
Interface, click the mouse to appear
Figure dialog box, click OK
Add an object to the object library


After the object library is added, you can select the object from the drop-down list when editing the trial procedure in the keyword view.

3. Select the Trial Object
After editing the object library, you can select the required trial object in the item column of the keyword view, as shown in the left figure.
If the trial object is not in the drop-down list, you can
To select "object from
Repository ", select from the object library,
For example, see.


4. Select the operation corresponding to the object
After selecting a Token Test object from the object library, you can select the corresponding operation in the "operation" column. For example, you can select "click" for a button.

5. Set the trial Logic
In the keyword view, the same settings support the trial logic, such as conditional inference and loop.
The following describes the testing logic of a for loop. The trial logic is implemented by clicking "=" button of the calculator repeatedly.
(1) In the keyword view, right-click and select "insert step | loop statement | for…" from the menu... Next ", add a cyclical testing step,


(2 ). in the "value" column, the for loop statement "for iterator = 1 to 1 step 1" is displayed. This statement only loops once. Therefore, you need to change the value after "to" 3, so that the statements in the loop body can be run three times,

(3 ). then, add a retry step to the end of the statement. In the item column, select the = button as the testing object. In the operation column, select the "click" operation for the object to be tested.

This completes a round-robin failover test.
Logical settings can be used in expert attempts
The corresponding script code is shown in the right figure.

Data-driven trial
You can actively review the recorded and edited scripts. The disadvantage of this linear self-automation test mode is that the coverage of the test is lower than that of the test. The review only involves the interface operations made during recording, the input review data, the interface operations specified during script editing, and the review data.
How can we make the trial script not only limited to the trial data during the recording or editing? Data-driven failover is the best solution to the problem. The data-driven trial tool extracts the trial data from the script and stores the data in an external file or database. During the trial, the system dynamically reads the trial data from the file.
General steps for data-driven failover
1. Data of the trial steps of "batch digitalization"
2. edit a data table
3. Set the number of iterations
In qtp, you can use multiple methods to serialize the trial script, including data table parameters and environment variable parameters) random Number parameterization.
The following uses the "flight" program that comes with qtp as an example to describe how to perform Compaction on the pilot script.
As you can see from the recorded script, This section describes how to merge the number of tokens in the "destination" trial step in the keyword view.

(1) data table regionalization
First, select the "fly to:" test step row and click the cell in the "value" column, as shown in.


Click the button next to the cell, or press the shortcut key
"Ctrl + F11", as shown in the figure on the right
In this interface, select "Parameters" next
Select "data table" in the drop-down box
Number of partitions, in "location in data table"
You can select global sheet or
"Current action sheet", the difference is that the number of shards is stored
Different locations

You can view the data table in the "View | data table" menu. You can see that there is a default data "London" in the flyto column, which is a constant in the recording script before the compaction.

After several other pieces of data are written into the data, we can see that

Edit data table
By directly editing the table, you can add a lot of other trial data. When qtp is executed, the data will be extracted from the data table you see to digitize the input during the trial.

Detection point
The last step of the trial script is to check whether the flight end point in the ticket booking record is correct, and the same needs to be appropriately renewed, you can click the cell in the "value" column of the test step where the checkpoint is located,

Click the "right" button next to it. The page shown in the right figure is displayed. Select "parameter" in "Configure value", click "OK" button to receive the default settings, or click the edit button next to it. On the page displayed in the figure, set the number of shards. We can choose to create a new deployment
You can also select "flyto" because the checkpoint
The expected value for the end of the flight should be the same as the final value of the flight.
Click okbutton to complete the upload
Digitalization



Set the data table Iteration Method
After completing the trial steps and the number of workers at the checkpoint, make some necessary settings before executing the script. Select "file | Settings" from the menu ", the "retry Settings" page appears.

"Run One iterator only" means to execute only once, that is, even if there are multiple data entries in the data table, it is only executed once; "run on all rows" indicates that all data in the data table is executed once. Select "run from row... To... Row ..." You can further set the execution range of the trial data.
Select "run on all row" and run the command to obtain the test result.

(2) random number used for random number partitioning
The number of flights selected in the pilot test procedure is different. Because the flight data table changes along with the selected Start Point and end point, the random number must be used for special processing, as shown in the following code.

First, obtain the number of lines in the flight list through the getitemscount attribute, then use randomnumber to randomly pick up one of them, and then select a flight using the select method.
3) using environment variable counts
The following uses the "agent name" and "password" on the "flight" Logon interface as an example to describe how to use the environment variable "batch.
First, select "file | Settings". The page is displayed. In this interface, switch
On the "Environment" page
Select "user-defined" in "type ",
Click the "+" button next to it.
Environment variable name and input value.


Repeat the preceding steps to define the "password" environment variable and obtain the result as an example.

After the environment variable is defined and its value is set, the environment variable can be used in the trial step.
In the keyword view, locate the "value" column of the "agentname" trial step, for example,

Click <#> next to it. The displayed page is displayed. On the page, select "parameter", select "environment" in the drop-down box, and select "agentname" in "name ". Repeat this step to set "Enter logon password ".

After the configuration is complete, qtp reads the environment variable value bound to the trial step when executing the trial script to execute the corresponding data input action.

Descriptive programming with qtp
Some interface elements appear dynamically or dynamically during the record test. During the recording, they are not added to the record Test Library, how can we control these dynamic interface elements in the trial? Qtp provides descriptive programming to solve these problems.
When executing a script written with descriptive narration programming, qtp will use the object description in the explain test script to find the object. The location of the search is not the object library, it matches the version number of the temporary trial object created by qtp when the trial program is executed.
In qtp, there are two development methods to describe narrative programming: one is to directly describe the narrative, and the other is to use the description object. The following uses the NCP servers logon time display table as an example ,.

1. Direct description
For the previous NCP servers time display table, the duration trial is to verify whether the time is correct. It is time-changing and can be solved through descriptive narration programming, for example, the following script:
Browser ("Shenzhen yuanzheng software Co., Ltd."). Page ("Shenzhen yuanzheng software Co., Ltd."). webedit ("username"). Set "Xiaoyu"
Browser ("Shenzhen yuanzheng software Co., Ltd."). Page ("Shenzhen yuanzheng software Co., Ltd."). webedit ("password"). setsecure "4bda8fb406a2bf5fa628b028325fcebe031d"
Wait 8
Browser ("Shenzhen yuanzheng software Co., Ltd."). Page ("Shenzhen yuanzheng software Co., Ltd."). Image ("DL"). Click
'Match the Web table using the regular expression in the positium table
Text1 = "server time .*"
STR = browser ("Shenzhen yuanzheng software Co., Ltd "). page ("user management | diagnostic service value-added service management backend "). webtable ("Name: = webtable", "text: =" & text1 ). getcelldata (1, 2)
Msgbox Str
The syntax format of the description is as follows:
Testobject ("propertyname1: = propertyvalue1", "…", "Propertynamen: = propertyvaluen ")
Testobject: type name of the testing object, such as winbutton and webtable.
Propertyname: property name of the object to be tested
Propertyvalue: the property value of the object to be tested.
2. Use the description object
To use the description object, use code similar to the following:
Set mydescription = description. Create ()
Text1 = "server time. *"
'Add descriptive attributes for description
Mydescription ("name"). value = "webtable"
Mydescription ("text"). value = text1
STR = browser ("Shenzhen yuanzheng software Co., Ltd."). Page ("user management | diagnostic service value-added service management backend"). webtable (mydescription). getcelldata)
Here, the attribute description of the trial object is packaged in the description object, and the description object instance is used to represent the attribute description of a trial object.
Integration of qtp and QC
After connecting to QC through qtp, you can save the trial script to QC's trial requirements, then, QC can execute the qtp script based on the requirements of the trial samples and actively record the trial results. The method is as follows:
1. Install the "quicktest add-in for Quality Center" plug-in. On the qtp installation page, select "Quality Center loading items" to install the QC plug-in.

2. Connect qtp to QC
You can open the "file | quality center connection" dialog box through the "file | quality center connection" menu or the "button ,.
In the "file | quality center connection" dialog box, enter the QC address in the server URL and click "Connect" button.


After connecting to QC, the user logon dialog box shown in the left figure is displayed. Just like logging on to QC through IE, enter username, password and click "AUTHENTICATE authentication", select the domain, and the project will be ready.
As shown in the right figure after logging on, click "close" button to close the dialog box.


3. Save the qtp script to QC.
After connecting to QC, the "quality centera" button appears when saving the script, as shown in the left figure. Click this button to jump to the Trial Plan folder in QC, as shown in the right figure. Select a folder, change the name, and save the folder.


4. Execute the trial script in QC.
(1) execute the test script in the test plan
In the trial plan, select the trial script to be executed, and then select the trial script page to view the scripts in the same expert view and keyword view as in qtp ,. Click the button to start qtp and run the script, but the result is not saved to QC after the execution. In fact, scripts are usually debugged in the explain test plan.


(2) execute the qtp script in the laboratory
In the trial lab, you can execute one or more scripts in a batch.
Create a test set that contains 8 test scripts (create a test set for the method of test QC training documents ),. You can select a Token Test script, and then click execute button to execute a single Token test item. You can also click execute Token Test Set button to execute all the Token test scripts in the Token Test Set.

After you click "run the test set", a dialog box is displayed. In this dialog box, configure the execution host, and click "Run all". The script will be executed in sequence.

After execution, the trial result is recorded in QC. You can click "Launch Report" to view the trial report.

NCP service project active trial
Take the NCP service project as an example to demonstrate the self-active crash test of qtp applied to web programs
 

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.