How to use vb script for QTP

VBSCRIPT

VB Script is used for HP QTP scripting in order to create Test Scripts.VB Script is a Microsoft language where using for .Net development for Web applications. VB Script is a light weight language ,easy to understand,easy to learn and very easy to prepare QTP Test scripts for QTP framework.



Purpose of VB Script in QTP

1.VB Script coding used in hp QTP Test scripting.
2.VB Script is a Microsoft language.
3.Licensed by a many companies and using for programming Language.

VB Script Data Types

VB Script has only one Data type i.e Variant which is used in vb script.Variant is a type of data type that having different information.Variant used as a Null pointer,Boolean,Byte,Storage purpose..etc
Variable is used as a Array type to store information.We can store different type of data into this variable.Vb Script variable should not exceed 255 characters and must be unique.

Variables

VB Script has different variable to declare values or assigned types using Dim,Public,Private statements.
Dim - Used for all functions with in the script like global declarations
Public - Used for all functions or procedures for all the scripts
Private - Used for only for which scripts it has declared.

Ex: 
'Global Variable Declarations
Dim k,l,m
'Assign value to K
K = Inputype("Please Enter k value")
'Assign value to l
l= InputType("Please Enter l value")
'Addition of two integers
m=l+k
'Display Addition value m
MsgBox(m)

Option Explicit is also a variable to declare variables,if Option Explicit used you should declare variables in Test scripts for all the variables.If used Option Explicit it will provide details if variables are not declare under Dim or Public or Private  statements.

VB Script Arrays

Array is a type of storage container which is used to store  the particular fixed size of  values of a single type.The length for array is established at the time of array is created.Array is starts with number 0 for example below

Ex: 
a[3] means 
a[0],a[1],a[2],a[3]
a[0] = 1
a[1]= 2
a[2] = 3
a[3] = 4

Two Types of Arrays

1.Static Array
2.Dynamic Array

Static Array:
In this Static Array we can mention size of the array while declaring the array.For Example

Dim Value[3]
Value[0] = 1
Value[1] = 2
Value[2] = 3
Value[3] = 4


Dynamic Array

In this type of Array we can change the array size at the type of Test script and we can resize the array size in Dynamic Array.

Ex: Dim a()

Suppose if we want to resize the specified array we can use ReDim statement to resize the dynamic array size.

ReDim a(5) 

No comments:

Post a Comment