Summary of common functions in VBScript _vbs

Source: Internet
Author: User
Tags lowercase rtrim
Here are the functions and their uses that I've summarized in VBScript.

1,getroproperty

Description: Use the "Getroproperty method" to retrieve "current value of" a test object property from a Run-time object in your Application.

In general, all objects can use this method to get the actual value of the Run-time object.

Syntax: Object. Getroproperty (property, [Propertydata])

such as Buttonname=browser ("QA home Page"). Page ("QA home Page"). Webbutton ("Submit"). Gettoproperty ("Name")

2,waitproperty

Description: Waits until the specified object property achieves the specified value or exceeds the specified timeout before Ng to the next step.

This method resolves test object synchronization issues that are caused by waiting for the system to handle certain operations or network causes.

Syntax: Object. Waitproperty (PropertyName, PropertyValue, [TimeOut])

Such as

Window ("Test"). Static ("Status:"). Waitproperty "text", "Ready", 30000

3,instr

Returns the position of the the ' the ' of the ' the ' of the ' the ' of the ' occurrence

You can get the position of the first occurrence of a string in another string.

Syntax: InStr ([Start,]string1, string2[, compare])

4,split

Returns A zero-based, one-dimensional array containing a specified number of substrings.

This function splits the string that was originally concatenated with a particular string and gets a one-dimensional array.

5,ubound

Returns the largest available subscript for the indicated dimension to an array.

Gets the maximum value for a dimension.

6,trim

Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (T RIM).

You can use the LTrim function if you need to remove all the spaces to the left of the string, or you can use the RTrim function if you need to remove all the spaces to the right of the string. You can use the TRIM function if you need to remove all the spaces to the left and right of the string.

7,ucase

Returns A string that has been converted to uppercase.

This function converts all characters to a corresponding capitalization.

8,lcase

Returns A string that has been converted to lowercase.

This function converts all characters to the corresponding lowercase.

9,cstr

Returns An expression this has been converted to a Variant of subtype String.

Since VBScript has only one type variant, you can use this function to cast a variable to a string type.

10,cint

Returns An expression this has been converted to a Variant of subtype Integer.

Since VBScript has only one type variant, you can use this function to cast a variable to an integer type.

In descriptive programming statements, the most commonly used functions are:

11,create

This is the method that you must use to create a class or object.

12,childobjects

Use this method to get a collection of objects of a class that meet certain criteria.

13,count

Use this method to get the number of objects of a class that meet certain criteria.

The following example uses the Create method to return a Properties collection object named Editdescription, and then The returned object to instruct QuickTest to enter the Text:myname in the the ' the ' the ' the ' the ' the ' the ' the ' the ' the ' Webedit 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 usages can be found in QTP's help. Personal advice is: you'd better follow the example provided in QTP, use these functions yourself to write a few lines of statements, run after a look at the results of the operation, combined with QTP help inside the instructions, so that the study will be quick, also remember firmly.

When outputting the results, the commonly used functions are Msgbox and Print functions. The Msgbox function is available in QTP8.2 and above, the Print function needs to be used on the QTP 9.2 version, QTP 8.2 does not support this function, and it is not known whether QTP 9.0 supports this function.

Hope that we can sum up together, progress.

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.