The following are the commonly used functions and their usage in VBScript.
1, getroproperty
Note: you use the getroproperty method to retrieve the current value of a test object property from a run-time object in your application.
In general, all objects can use this method to obtain the actual value of the runtime object.
Syntax: object. getroproperty (property, [propertydata])
For example, buttonname = browser ("QA home page "). Page ("QA home page "). Webbutton ("Submit "). Gettoproperty ("name ")
2, waitproperty
Note: waits until the specified object property achieves the specified value or exceeds the specified Timeout before continuing to the next step.
This method can solve the problem of test object synchronization caused by waiting for the system to process certain operations or network reasons.
Syntax: object. waitproperty (propertyname, propertyvalue, [timeout])
For example
Window ("test "). Static ("status :"). Waitproperty "text", "ready", 30000
3, instr
Returns the position of the first occurrence of one string within another.
You can obtain the position where a string first appears in another string.
Syntax: instr ([start,] string1, string2 [, compare])
4. Split
Returns a zero-based, one-dimen=array containing a specified number of substrings.
This function can split a string that was originally connected with a special string to obtain a one-dimensional array.
5, ubound
Returns the largest available subscript for the indicated dimension of an array.
Obtains the maximum value of a dimension.
6, trim
Returns a copy of a string without leading spaces (ltrim), trailing spaces (rtrim), or both leading and trailing spaces (TRIM ).
If you want to delete all spaces on the left of the string, you can use the ltrim function. If you want to delete all spaces on the right of the string, you can use the rtrim function. To delete all spaces on the left and right of a string, you can use the trim function.
7. ucase
Returns a string that has been converted to uppercase.
This function converts all characters into uppercase letters.
8, lcase
Returns a string that has been converted to lowercase.
This function converts all characters to lowercase letters.
9, CSTR
Returns an expression that has been converted to a variant of subtype string.
Because VBScript has only one type of variant, you can use this function to forcibly convert a variable to the string type.
10, CINT
Returns an expression that has been converted to a variant of subtype integer.
Because VBScript has only one type of variant, you can use this function to forcibly convert a variable to the integer type.
In descriptive programming statements, the most common functions are:
11. Create
This is a required method for creating a class or object.
12, childobjects
This method can be used to obtain a set of objects that meet certain conditions.
13, count
You can use this method to obtain the number of objects of a class that meet certain conditions.
The following example uses the create method to return a properties collection object named editdescription, and then uses the returned object to instruct quicktest to enter the text: myname In the first webedit object in the Mercury tours page with the name username.
Set editdesc = description. Create ()
Editdesc ("micclass "). Value = "webedit"
Editdesc ("name "). Value = "username"
Set lists = browser ("Welcome: Mercury "). Page ("Welcome: Mercury "). Childobjects (editdesc)
Numberoflists = lists. Count ()
If numberoflists> 0 then
Browser ("Welcome: Mercury "). Page ("Welcome: Mercury "). Lists (0 ). Set "myname"
End if
Some specific usage can be found in qtp help. My personal suggestion is: You 'd better follow the example provided in qtp and use these functions to write several lines of statements by yourself. After running the statements, check the running results and see the instructions in qtp help, in this way, you can learn quickly and remember to be firm.
When outputting results, common functions include msgbox and print functions. The msgbox function can be used in both qtp8.2 and later versions. The print function must be used in qtp 9.2. qtp 8.2 does not support this function. I wonder if qtp 9.0 supports this function.
I hope you can sum up and make progress together.