The following are the most commonly used features of the QTP (only the menu entry is provided below, others have many entrances, but the functions are the same)
1. QTP above menu bar->tools->object Spy (object probe)----multiple portals
Features: Captures and views all categories, attributes, and supported methods of an object
2. QTP above menu bar->resours->object Repository (object library)----multiple portals
Features: Actions on new objects before writing code (add, delete, update, highlight, copy, paste, secondary object library, export object library, etc.)
3. QTP above menu bar->resours->object Repository Manager (Object Library Management)---only this one entrance
Features: Multi-person collaboration automation to develop assembly or maintenance code when the existing Object Library management operations (new Object library, open existing object library, available editing (Enable Editing), add, delete, update, highlight, copy, paste, QC connection, manage library properties, Object Library contrast, Object library merging, etc.)
It is worth mentioning that the object Repository manager's two ace-level "helper"-objects library comparison and object library merging
QTP above menu bar->resours->object Repository manager->tools->object Repository Comparison Tool (Object library comparison)
QTP top menu bar->resours->object Repository manager->tools->object Repository Merge Tool (Object library merge)
Below is a simple summary of several common types of objects in the Web:
Browser
The browser object is a browser object, such as Ie,ff,chrome. The browser object is the parent object of all Web objects, the top of the pyramid, and I have no constraints on it in Description properties. Use object spy to view browser objects
To see the relevant properties of the browser, because I now test the system needs to test IE6 compatibility, you see my version of IE or 6-_-! Operations lists the methods that the browser object can use, and here are a few common methods (first adding the browser object to the object library).
1.systemutil.run, open the browser, the specific way you can F1 view.
2.Sync, synchronous method, meaning to wait for the browser to fully open before the next operation.
3.Navigate, open the URL.
4.Close, close the browser.
1 2 3 4 |
Systemutil.run "Iexplore.exe" Browser ("Browser"). Sync Browser ("Browser"). Navigate ("http://localhost/qtp/demo-login.php") Browser ("Browser"). Close |
Tips: Open the specified URL can also use the Systemutil.run method, the above code can be simplified to
1 2 |
Systemutil.run "Iexplore.exe", "http://localhost/qtp/demo-login.php" Browser ("Browser"). Close |
Page
The Page object is generally a child of the browser, each of which is a Web object, and the name value of the Page object is the value of title in the HTML tag. The important methods of page objects are exist, Sync, childobjects and so on. There are few operations on browser and page in actual work, most of which are open close and synchronous.
Webedit
The input box in the Web page can be recognized as Webedit object, there are still many methods in operations, you can view it by yourself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21st 22 23 24 25 26 27 28 29 30 31 32 |
<title>web Object Demo </title> <meta http-equiv= "Content-type" content= "text/html" charset= "Utf-8" > <style> . content{ width:260px; height:30px; } . edit{ width:170px; } span{ width:70px; } </style> <body> <form action= "" method= "POST" > <div class= "Content" > <span>text</span><input type= "text" name= "Web" class= "edit" > </div> <div class= "Content" > <span>password</span><input type= "Password" name= "Web" class= "edit" > </div> <div class= "Content" > <span>textarea</span><textarea rows= "5" cols= "class=" ></textarea> "edit" </div> </form> </body> |
|
|
With more set and Getroproperty methods in Webedit, set is used to set the value in the input box, Getroproperty gets the value of the run-time object.
1 2 3 4 5 6 7 8 |
Browser ("Web Object Demo"). Page ("Web Object Demo"). Webedit ("text"). Set "111" Browser ("Web Object Demo"). Page ("Web Object Demo"). Webedit ("password"). Set "222" Browser ("Web Object Demo"). Page ("Web Object Demo"). Webedit ("textarea"). Set "333" A=browser ("Web Object Demo"). Page ("Web Object Demo"). Webedit ("text"). Getroproperty ("value") B=browser ("Web Object Demo"). Page ("Web Object Demo"). Webedit ("password"). Getroproperty ("value") C=browser ("Web Object Demo"). Page ("Web Object Demo"). Webedit ("textarea"). Getroproperty ("value") MsgBox "Text=" +a+ ";p assword=" +b+ "; textarea=" +c |
After running the output is as follows
Link
Link is a Web page where we add the following code to the page
1 2 3 |
<div class= "Content" > <span>link</span><a href= "http://www.baidu.com" > click here to jump to Baidu </a> </div> |
The operation of the link object is mainly click, Checkproperty. The Checkproperty method is to check that the URL property of the link object is correct, click on the operation, run the code below, the page will automatically jump to Baidu.
1 2 3 4 5 6 7 |
' Check that the URL property is correct Browser ("Web Object Demo"). Page ("Web Object Demo"). Link ("Click here to jump to Baidu") _ . Checkproperty "url", "http://www.baidu.com/" ' If the click method is executed correctly If Reporter.runstatus=pass Then Browser ("Web Object Demo"). Page ("Web Object Demo"). Link ("Click here to jump to Baidu"). Click End If |
Webbutton
The Webbutton object is a variety of buttons on the page, the main operation is click:)
Webelement
Webelement is mainly used to verify the correctness of the data, such as the span tag in the example above, by including the contents of the Div,span,p tags in the page.
1 2 3 4 |
If Browser ("Web Object Demo"). Page ("Web Object Demo") _ . Webelement ("password"). Getroproperty ("innerhtml") = "password" Then MsgBox "OK" End If |
Weblist
I identified the drop-down box in the page as a Weblist object and added the following code to our demo page.
1 2 3 4 5 6 7 8 9 &NBSP; |
<div class= "Content" > <span>select</span> <select> <option value = "PHP" >php</option> <option value = "java" >java</option> <option value= "VBS" >vbs</option> <option value= "Python" >python</option> </select> </div> |
Note the all Items property in the properties, which includes all the options in the list, select the option in Weblist with the Select method, using the same as the set method.
Webradiogroup && WebCheckBox
Webradiogroup The Radio box object, webcheckbox the check box object, add the following code.
1 2 3 4 5 6 7 8 9 10 11 |
<div class= "content"; <span>radio</span> <input type= "Radio " name=" Sex " value=" boy " checked=" checked "> Male < Input type= "Radio" name= "Sex" value= "girl" > Female </DIV> <div class= "Content"; <span>checkbox</span> <input type= "checkbox" name= "Swim" value= "swim" id= "Swim" > Swimming <input type= "checkbox" name= "Game" value= "Game" id= "Game" > Game <input type= "checkbox " name=" read " value=" read " id=" read "> Reading </DIV> |
The code for selecting the Radio box and check box is as follows
1 2 3 |
Browser ("Web Object Demo"). Page ("Web Object Demo"). Webradiogroup ("Sex"). Select "Girl" Browser ("Web Object Demo"). Page ("Web Object Demo"). WebCheckBox ("read"). Set "On" Browser ("Web Object Demo"). Page ("Web Object Demo"). WebCheckBox ("Swim"). Set "On" |
Webtable
The Webtable object is the focus and difficulty in the Web page control, in the page layout table is generally used for the presentation of data, which is the focus of our testing. The same way, now create the table control in the Web page and add the following code.
1 2 3 4 5 |
<table> <tr><td>text1</td><td>textarea1</td><td>sex1</td><td>hobby1 </td></tr> <tr><td>text2</td><td>textarea2</td><td>sex2</td><td>hobby2 </td></tr> <tr><td>text3</td><td>textarea3</td><td>sex3</td><td>hobby3 </td></tr> </table> |
And in the style label
1 2 3 4 5 6 7 8 9 10 11 12 |
table{ BORDER:1PX solid black; padding:0; margin:0 Auto; Border-collapse:collapse; } rd= BORDER:1PX solid black; font-size:12px; padding:3px 3px 3px 8px; Color:black; } |
As you can see, I identified the TD as a Webelement object, and the TD's parent element, the table, is recognized as a Webtable object. There are many ways to webtable objects, and here are a few common ways to refer to the code below.
1 2 3 4 5 6 7 8 9 10 11 12 |
"Get the number of columns col=browser (" Web Object Presentation "). Page ("Web Object Demo"). Webtable ("table"). ColumnCount (1) "get the number of rows row=browser (" Web Object Demo "). Page ("Web Object Demo"). Webtable ("table"). rowcount info=browser ("Web Object Demo"). Page ("Web Object Demo"). Webtable ("table"). Getcelldata (+) dim obj obj=browser ("Web Object Demo"). Page ("Web Object Demo"). Webtable ("table"). Childitemcount ("Webedit") msgbox "number of columns =" +cstr (col) + " rows =" +cstr (row) + " First row of first column = "+info+_ |
The results of the operation are as follows:
For most cases of webtable objects using descriptive programming,
QTP's Web Common object