Writing this blog is to sort out some of the qtp knowledge you have learned in the past and post it in the form of notes. It's a warm story ~
I hope I can give some comments to encourage each other to learn from each other.
Certificate -------------------------------------------------------------------------------------------------------------------------------------------------
Note1: Object repository-Object repository
The Object Library is the place where qtp stores objects.
Qtp stores a definition for each retrieved object in the object library. These definitions contain various values used to confirm unique object parameters
For example, innertext, HTML Tag, etc. These web object parameters can be obtained through IE developer toolbar.
PS: The iedt plug-in is very practical for qtp users. Of course, it has been integrated into ie8.0.
Add object to Object Library
1. During the basic recording process, qtp automatically adds the object to or
2. manually add objects to the object library
When you manually add an object to the object library, qtp starts the object selection mode to add the object you selected.
There are two scenarios:
1. Semi-operation scenario:
Temporary Invalid object selection mode
Long press Ctrl and the mouse changes to the normal state. You can click the mouse and release CTRL to return to the object selection mode.
2. full operation scenarios:
If we need to directly switch between different programs when adding objects, we can
Press CTRL + ALT to invalidate the object selection mode. In this way, we can operate any other program normally.
Once the operation is complete, press Ctrl to restore to the valid mode and add the object.
PS: The effective mode mainly depends on the mouse status.
Bytes --------------------------------------------------------------------------------------------------------------------
Next is the basic operation method of the qtp Object Library.
It can be roughly divided into settoproperty, getroproperty, and gettoproperty.
To: objects in the test objects Test Library
RO: running-time objects
Settoproperty: Modify the property value of an object in the object library.
Gettoproperty: Get the object property value in the object library
Getroproperty: Get the running Object Property Value
Example1: modifying the properties of a test object
View plaincopy to clipboardprint?
'Create a webedit object
Set owebedit = browser ("Browser"). Page ("page"). webedit ("txtname ")
'Get Object Name
Oldname = owebedit. gettoproperty ("name ")
'Modify the object to "New Value"
Owebedit. settoproperty "name", "New Value"
'Get the object's new name
Newname = owebedit. gettoproperty ("name ")
Msgbox newname
'Create a webedit object
Set owebedit = browser ("Browser"). Page ("page"). webedit ("txtname ")
'Get Object Name
Oldname = owebedit. gettoproperty ("name ")
'Modify the object to "New Value"
Owebedit. settoproperty "name", "New Value"
'Get the object's new name
Newname = owebedit. gettoproperty ("name ")
Msgbox newname
Example2: Get the run-time object attribute during test execution
View plaincopy to clipboardprint?
Xxx = browser (""). Page (""). webedit (""). getroproperty ("value ")
Msgbox xxx
Xxx = browser (""). Page (""). webedit (""). getroproperty ("value ")
Msgbox xxx
PS: qtp does not provide a method to modify the phase of the run-time object, because its object can be directly modified by object. value, so you may not see setroproperty.
Bytes ------------------------------------------------------------------------------------------------------------------
Finally, we provide some overall maintenance methods for the object library.
1. Saving the Object Library
In the object library window, select the [export local objects] command to export the object library files in TSR format to the local
2. Merge object Libraries
During the project process, if the object library is split, it is best to generate a unified object library to make the test team better maintain and call the object library.
[Resources]-> [object Repository Manager]-> [Tool]-> [or merge tool]
Import a single object library in [primary file] and [secondary file], and then qtp is automatically merged into a new object library.
:
3. Object Library shared reference
Merge the object library into a public object library, which is a very good way to call and maintain
In combination with this method, we can continue to map case scripts to this public object library one by one.
[Resources]-> [associate repositories]-> associate with the required use case action
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/Tachibana814/archive/2010/02/28/5334305.aspx