Monday, 14 May 2012

VBScript Syntax Rules And Guidelines

Case Sensitive:
VBScript is not case sensitive.It means that it doesn't differentiate between upper case and lower case spelling of words, variables, objects and methods names or constants.

For example, Browser("aaa").Page("bbb").WebList("today").Select "131"
Browser("aaa").Page("bbb").WebList("Today").Select "131"will be treated in same way by QTP.

Text Strings:
When a value is entered as a text string, we should add quotation mark before and after the string.But we need to remember that the numbers also should be surrounded by quoatation marks, beacuse it's a text string that represent a number not a numeric value when the number is entered into a text box.

One more should be considered that the variables should not be surrounded by quotation marks.

For example: Browser("aaa").Page("bbb").WaitProperty("variable name", variable,20000)

Variables:
We can use the variable to store strings,integers,arrays and objects.Using variables is very helpful to make the scripts more readable and flexible.

Parenthesis:
To achieve the desired result and to avoid errors,it's important that we use parenthesis() correctly in our statements.

Indentation:
We can indent or out-dent our script to reflect the logical structure of the nesting of the statements.

Comments:
We can add the comments before writing a line or at the end of the statement.We have to use apostrophe(') to represent the comments.It's recommended to add the comments wherever possible, to make our scripts easier to understand and maintain.

Spaces:
We can add spaces in our script to improve clarity. These spaces are ignored by VBScript.

0 comments:

Post a Comment

 
Back To Top