Introduction to VBScript

by seetaram on August 20, 2011

VBScript is a scripting language which is used to automate certain tasks such as Create a Local User Account and Set the Privileges. One more usage of VBScript is in Test Automation. A well-known GUI automation tool Quick Test Professional uses VBScript as the scripting language to automate user actions on Application Under Test (AUT).

From an System Administrator’s perspective the VBScript reduces the day-to-day repetitive tasks.  From a software developer’s standpoint VBScript is a client-side scripting language used along with ASP.  On a web page if there is a need to validate the length of a certain field client-side scripting such as VBScript or Javascript is used to handle such situation instead of validating the same on the server side which is definitely time consuming.

Since the VBScript can be used with QTP (Quick Test Professional) for automating user actions on the application under test, it became well-known in the Tester Community.

VBScript is an interpreter hence the script is compiled runtime and executes line by line.  All the traditional programming languages such as C, C++, Java, Visual Basic, etc have compilers and the program will be compiled at once and run subsequently.

VBScript can be written using vbscript editors such as “vbsedit”.  If your objective is to learn vbscript for QTP then it is better to use QTP for writing the scripts.

Download QTP from HP’s download center – HP BTO Download Center

OR

Download VBScript Editor (Either trial version or get the registered version) – VBSEdit

OR

Download and install any editors such as Notepad++ or Editplus.  Write the script using the editor and save it as “.vbs” file.  Run the vbscript file just by double clicking the file.

Let us write a small vbscript which displays “Hello World”.

Dim a
a="Hello World"
msgbox a

 

Save the file as “helloworld.vbs” – we can see the vbscript icon.  Double click the file it runs and output will be as follows:

helloworld

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email