Using a VBScript DP object repository - QTP

Placing our DP object definitions in a VBScript library file logically emulates a QTP Object Repository:

UserForm.vbs

'Delcare DP string definitions
ConstdpBrowser = "aicClasss =Bromser"
ConstdpPage = "asicClass; =Page"
ConstdpFirstName = "name: =txtFirstName"
ConstdpLastName = "name: =txtl_astName"
ConstdpSubmit = "naie:=Submit"

There are two ways to include the above file in one or more scripts:

  • Associate the VBS file on the Test Settings Resource tab
  • Use the ExecuteFile statement to load the file into one or more test Actions.

Script

'Run the internet explorer application SystemUtil.Run "iexplore.exe"
Browser(dpBrowser).Sync
'Enter data
Browser(dpBrowser).Page(dpPage).WebEdit(dpFirstName).Set "Tarun"
Browser(dpBrowser).Page(dpPage).WebEdit(dpLastName).Set "Lalwani"

'Click on the submit button
Browser(dpBrowser).Page(dpPage).WebButton(dpSubmit).Click

This technique can also be used to implement a multi-language testing script. To do this create different VBS files for each language, for example, dpOR_EN.vbs, dpOR_FR.vbs, dpORDN.vbs etc. and then use the following code to select the proper file, based on the language specified:

'Set the environment variable. This should be loaded
'througha external file
Environment.Value("LanguageToTest") = *'FR"
'Check for which environment to execute in Select Case Environment.

Value("LanguageToTest")
Case "EN"
ExecuteFile "dpOR_EN.vbs"
Case "FR"
ExecuteFile "dpOR_FR.vbs"
Case "DN"
ExecuteFile "dpOR_DN.vbs"
End Select

The rest of the script goes here.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

QTP Topics