In this post we will look at ‘VB script’ code for different applications such as windows, java, .net , web etc. VB script is easy to understand and implement, Its just that you need know the basic terminologies associated.
The Start
The log-in application in the below image has three components which are ‘Window’, ‘Edit Box’, ‘Button’.
Step 1
In order to enter a name in the Edit Box ‘Name‘ , we need to identify the path, which is : The window and then the edit box and finally setting data with ‘Set’.
Window. EditBox. Set
This is the path required to enter a value in the ‘Name’ field of the login application.
Step 2
specify the properties for the individual components, which means :
Window(“Login”). Edit(“Name”) . Set ‘name’
The values in the double quotes are known as properties. Still confusing!.. do not worrry. check out the below samples.
Sample code for a Windows Application :
Window (“Login”). WinEdit (“Name”). Set “testnbug” Window (“Login”). WinEdit (“Email”). Set “testnbug@gmail.com” Window (“Login”). WinEdit (“Email”). Set “1234” Window (“Login”). Winbutton (“Login”).Click
The code looks very similar for different applications, The below code snippets are for different other applications. Those are easy and you can easily spot the differences. Have a look.
Sample code for a Visual Basic Application :
VbWindow (“Login”). VbEdit (“Name”). Set “testnbug” VbWindow (“Login”). VbEdit (“Email”). Set “testnbug@gmail.com” VbWindow (“Login”). VbEdit (“Email”). Set “1234” VbWindow (“Login”). VbButton (“Login”).Click
Sample code for a Java Based Application :
JavaWindow (“Login”). JavaEdit (“Name”). Set “testnbug” JavaWindow (“Login”). JavaEdit (“Email”). Set “testnbug@gmail.com” JavaWindow (“Login”). JavaEdit (“Email”). Set “1234” JavaWindow (“Login”). JavaButton (“Login”).Click
So, the difference is application name which is, either java or vb followed by window or edit box.
Web Based Application :
The components of a web based application are slightly different, which includes ‘Browser’, ‘Page’, ‘Edit Box’, and ‘Button’ as show in the below image. Steps to design are same as above, the only difference are the components.
Sample code for a Web based application : (Chrome browser)
Browser (“Chrome”). Page (“testnbug”). WebEdit (“Name”). Set “test” Browser (“Chrome”). Page (“testnbug”). WebEdit (“Email”). Set “t@gmail.com” Browser (“Chrome”). Page (“testnbug”). WebEdit (“Password”). Set “1234" Browser (“Chrome”). Page (“testnbug”). WebButton (“Login”). Click
Sample code for IE (Internet Explorer)
Browser (“IE”). Page (“testnbug”). WebEdit (“Name”). Set “test” Browser (“IE”). Page (“testnbug”). WebEdit (“Email”). Set “t@gmail.com” Browser (“IE”). Page (“testnbug”). WebEdit (“Password”). Set “1234" Browser (“IE”). Page (“testnbug”). WebButton (“Login”). Click
So, Did you find out the difference in various applications ? Wow ! …… Observe them carefully, as they form the basis of understanding the Vb Script in UFT/QTP. In the advanced posts on UFT where the descriptive programming comes into picture, this post will definitely make your life easier.