Understanding basic VBScript syntax
VBScript is an easy-to-learn, yet powerful scripting language. You can use VBScript to develop scripts to perform both simple and complex object-based tasks, even if you have no previous programming experience.
This section provides some basic guidelines to help you use VBScript statements to enhance your UFT One test or component. For more details about using VBScript, see the MSDN VBScript documentation.
Each VBScript statement has its own specific syntax rules. If you do not follow these rules, errors will be generated when you run the problematic step. Additionally, if you try to move to the Keyword View from the Editor, UFT One lists any syntax errors found. You cannot switch to the Keyword View without fixing or eliminating the syntax errors.
When working in the Editor, bear in mind general VBScript syntax rules and guidelines.
By default, VBScript is not case sensitive and does not differentiate between uppercase and lowercase spelling of words, for example, in variables, object and method names, or constants.
For example, the two statements below are identical in VBScript:
Browser("Advantage Shopping").Page("Advantage Shopping").WebList("categoryListboxContactUs").Select "Headphones" browser("advantage shopping").page("advantage shopping").weblist("categorylistboxcontactus").select "headphones"
When you enter a value as a text string, you must add quotation marks before and after the string. For example, in the above segment of script, the names of the Web site, Web page, and edit box are all text strings surrounded by quotation marks.
In the following example, only the property name (first argument) is a text string and is in quotation marks. The second argument (the value of the property) is a variable and therefore does not have quotation marks. The third argument (specifying the timeout) is a numeric value, which also does not need quotation marks.
Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("$1,079.98").WaitProperty "innertext", price, 20
You can specify variables to store strings, integers, arrays and objects. Using variables helps to make your script more readable and flexible. For more details, see Using variables.
To achieve the desired result and to avoid errors, it is important that you use parentheses () correctly in your statements. For more details, see Using parentheses .
You can add comments to your statements using an apostrophe ('), either at the beginning of a separate line, or at the end of a statement. We recommend adding comments wherever possible, to make your scripts easier to understand and maintain.
You can add extra blank spaces to your script to improve clarity. These spaces are ignored by VBScript.