Professional Documents
Culture Documents
TABLE OF CONTENTS
1. Introduction
2. QTP / UFT IDE
3. Record and Playback UFT/QTP Script
4. Keyword and Editor View in QTP/UFT
5. Local & Shared Object Repository in QTP/UFT
6. How to Replay a Script in QTP/UFT with Example
7. Parameterization in QTP/UFT with Example
8. Checkpoints in QTP/UFT with Example
9. IF, Else, End IF, Exists, Switch in QTP/UFT with Example
10. Reporter.ReportEvent in QTP/UFT with Example
11. Report Formats
12. Screen Capture
13. Export Report Results, Automatically
14. Understand SystemUtil.Run, SetSecure, Set, Type: QTP/UFT Examples
15. Object Repository & Object Operations
16. Object Spy, GetRoProperty, GetToProperty in QTP/UFT with Example
17. Virtual Objects
18. How Object Identification works in QTP/UFT?
19. Smart Identification in QTP/UFT with Example
20. Ordinal Identifier in QTP/UFT: Object Identification Example
21. Actions in QTP
22. Types of Recording Modes in QTP/UFT
23. How to use Functions in QTP/UFT
24. Step Generator
25. Synchronisation Points
26. How to use Transactions in QTP/UFT
27. Environment Variable in QTP (UFT) with Example
28. Regular Expressions
29. Debugging
30. VB Script Introduction
31. Variable Declaration
32. Option Explicit
33. Arrays
34. Msg box
35. Input Box
36. Different Loops
37. Folder Operations
38. File Operations
39. How to Import, Read, Change Data from EXCEL in QTP/UFT
40. String Functions
41. Date Functions
42. Function Usage
43. Sub Procedure
44. Frameworks
45. How to print Output Values in QTP/UFT with Example
46. How to use Recovery Scenario in QTP/UFT with Example
47. Optional Step in QTP/UFT with Example
INTRODUCTION TO HP QTP/UFT
QTP is an automated functional Testing tool that helps testers to execute automated
tests in order to identify any errors, defects or gaps in contrary to the expected
results of the application under test.
QTP Testing is based on scripting language VB script. Micro Focus’s UFT uses VBScript
to automate applications
Test Support Supports automation only for Supports tests on both web and
web – based applications. desktop applications.
Supported Java, C#, Ruby, Python etc. VB Script
programming
languages
1. Menu Bar:
a. File Menu:
i. New: Using File –>New, you can create a new Test, Business
Component, Solution, Function Library or an Application Area.
ii. Open: Using this option, you can open an already created Test,
Business Component, Solution, Function Library, Application Area or
any file type that can be opened in UFT.
iii. Add: You can add a new Test, Business Component, Function Library,
Application Area to a Solution.
iv. Close: Close the currently opened asset in the view. (Ctrl + F4).
v. Close Solution: Close the Solution. (Ctrl + Shift + F4).
vi. Save <Test Name>: Save the current test.
vii. Save <Test Name> As: Save the current test with a different name
(.tsp) extension.
viii. Save All: Save all testing documents in the Solution Explorer.
ix. Save (Other): Save a test with resources including Active Screen.
x. Recent: Shows a list of tests recently opened on your machine.
xi. Export Test: Export a test into a zip format.
xii. Import Test: Import a test from a zip format.
b. Edit Menu:
i. Format: Out of all the options present under Format (as shown
below), you would be using Comment and Uncomment more often.
ii. Code Snippet: This is a helpful tool for VB Script beginners. Using
Code Snippet option, you can quickly copy syntax for various types of
conditional and logical statements found in VB Script.
c. View Menu:
d. Search Menu:
e. Design Menu:
f. Record Menu:
g. Run Menu:
h. Resources Menu:
i. ALM Menu:
j. Tools Menu:
2. Solution Explorer: The Solution Explorer is a hierarchical tree of all actions and
tests in the current test, with their references, events, and flows.
3. Data Table: You can enter the data related to your test through data-tab from the
menu-bar at the bottom of the window. This panel is the tree hierarchy of data
sources that can be used with a test.
2. Record & Run settings shows a tab corresponding to add-ins installed and loaded for
your test. So, for example, if you have SAP Add-in Installed and loaded you will see
an SAP tab. The Windows Application tab is always available and is used for
environments, such as Visual Basic, ActiveX, and terminal emulators.
For any Environment, the Record and Run settings can be classified into two generic
groups:
4. Record the test steps. Once the action is completed, go to the record panel and click
‘Stop’. The script will be generated.
6. The result window will show the execution time stamp, pass, and failed steps.
KEYWORD VIEW AND EDITOR
VIEW IN QTP/UFT
Keyword View:
The Keyword View is comprised of a table-like view where Each step is a separate
row in the table and Each column represents different parts of the steps.
Item Column contains the item on which you want to perform the step. This column
uses icons displays the hierarchy of the GUI object on which operation is performed.
Value Column contains the argument values for the selected operation.
Editor View:
In the Editor View, each line represents a Test Step in VB Script. Consider the
following code
An Object’s Name is displayed in parentheses following the Object Type. Here the
Object Name is Login and Object Type is Dialog.
Dialog Box is the Parent Object where as WinEdit is the Child Object.
The Operation performed on the object is always displayed at the end of the
statement followed by any values associated with the operation. Here the word
“Gur9” is inserted in the AgentName Edit Box using the Set Method.
ParentObject(Name).ChildObject1(Name)...ChildObjectN(Name).Operation
LOCAL & SHARED OBJECT
REPOSITORY IN QTP / UFT
When a user records a test, the objects and their properties are captured by default.
iv. All repositories are local by default. To create a Shared Object Repository, in
the Object Repository Dialog Box, Click File > Export Local Objects.
v. Repository files have an extension .tsr .Give a suitable name and save.
vi. The Shared Repository File is now created.
vii. Next step is to associate the repository to your test, which enables you to use
it.
viii. To associate a repository with a test, Click Resources > Associate Repository.
ix. You can select the Repository to associate with Actions available in your test.
x. Now you can now use this shared repository to develop your test.
xi. You can use the Object Repository Manager to Edit a Share Repository.
xii. Select Resources > Object Repository Manager. Open the Object Repository.
xiii. By Default, Repository is opened in Read-only mode. To enable editing click
File > Enable Editing.
xiv. Once editing is enabled you can all the operations like cut, copy, paste,
rename objects etc that you can also do in Object Repository.
HOW TO REPLAY A SCRIPT IN
QTP / UFT
Once the script is recorded, you need to REPLAY the script to ensure the test steps
have recorded correctly. When you click the Run Button, a Run Dialog Box Opens.
The Run Box enables you to specify the location in which you want to save the run
session results.
It displays the default path and folder name in which results are stored. By default
results are stored in Test Folder. A new sub-folder is created with the name RESn.
The number n is incremented for each run. You can accept the default settings.
Temporary run results folder options save the results of the QTP program run in a
temporary folder. This option overwrites any results previously saved in this folder.
Its recommended that while developing your test script choose the Temporary
option and once the script is baseline you can use the new folder option.
One you click run, execution starts. In HP QTP/UFT window you can see a yellow
marker pointing at the step which is currently being executed.
PARAMETERIZATION IN QTP /
UFT
QTP provides us to pick different test inputs at a run time. This process of providing
different input values through external parameters is called as parameterization.
Value Configuration Dialog Box Opens. Currently, the value is set to a Constant. Click
on Parameter Radio Button. QTP assigns a default name to this parameter. You can
give a name of your choice and then click “OK.”
In the Global Sheet, a column with Header “Agent Name” and value Guru is created.
You can enter more values for this parameter.
When you click on “expert view” you will see that “Agent Name” is replaced by
“Guru”, and the type of sheet used.
Likewise, you can also parameterize the argument Password and enter different test
data sets.
What this Datasheet means is QTP will iterate the same six steps that we have
recorded three times. During the first iteration, it will use the data in the first row.
During the second it will use the data in the second row and so on.
The data driver enables you to quickly parameterize several property values
for test objects, checkpoints and method arguments containing the same
constant value within a given action.
7. Click next to parametrize the selected step and view the next step.
9. Click Finish to apply the parametrization settings of the current step to all
remaining steps containing the selected value. The Data Driver Wizard
closes and the Data Driver main screen shows how many occurrences you
selected to parametrize and how many remain as constants.
10. When you are finished with the parametrization constants click OK. The
parametrization options you selected are applied to your action.
Advantages of Parameterization:
Parameterization allows us to pick different values at run time.
It Reduces Time and Effort.
CHECK POINTS IN QTP / UFT
A checkpoint is a verification point that compares the current value with the
expected value for specified properties of an Object.
If the current and expected value match it generates a PASS status otherwise FAIL
status.
To add checkpoints, navigate to Design -> Checkpoint and select the required
checkpoint.
UFT will automatically add a step in the current action of the Test.
2. Text Checkpoint:
By default, UFT ignores the cases of the text string to be validated. You can check
and uncheck required checkboxes and click on the OK button. The checkpoint will be
added to the test script.
The Text Area Checkpoint enables you to check that a text string
appears within a defined area in a Test application, according to
specified criteria.
By adding Text Area Checkpoint in UFT you can validate static as well
as dynamic texts in UFT.
The Text Area Checkpoint Properties window will be displayed with the text string
that was selected within the defined area. Click on the “OK” button.
4. Bitmap Checkpoint:
Select the required object from the Bitmap Checkpoint window and click on the OK
button. The entire object bitmap will be captured and display in the Bitmap
Checkpoint properties window.
Syntax:
IF THEN
set of statements
END IF
Example:
Dim a,b
a=8 : b=6
if a>b then
msgbox “a is greater than b”
End if
2. ELSE Statement:
IF THEN
set of statements
ELSE
set of statements
END IF
Example:
Dim a,b
a=3 : b=6
if a>b then
msgbox “a is greater than b”
Else
Msgbox “Stay tuned to Software Testing Material”
End if
3. IF ELSE IF Statement:
Syntax:
IF THEN
set of statements
ELSEIF Then
set of statements
ELSE
set of statements
END IF
Example:
Dim a,b
a=8 : b=6
if a>b then
msgbox “a is greater than b”
Elseif a=b then
Msgbox “a is equals to b”
Else
Msgbox “a is not equals to b”
End if
4. Select Statement:
Syntax:
Example:
InputValue = Inputbox(“Enter the value: red or green or yellow”)
Select case lcase(InputValue)
Case “red”
Msgbox “stop”
Case “green”
Msgbox “go”
Case “yellow”
Msgbox “wait”
Case else
Msgbox “Invalid”
End Select
5. EXISTS Statement:
If you use Exists(3) as in your statement QTP will wait for 3 seconds
and check if object exist.
If you don’t use the parameter and simple use Exists, QTP will take the
default value which is 20 seconds.
REPORTER.REPORTEVENT IN
QTP/UFT
Reporter.ReportEvent Statement is used to send desired events (like Pass, Fail, etc)
and custom messages in the run results of UFT.
Syntax:
ReportStepName: Step name that is displayed in the Run Results window. Generally
used to write the expected result.
Details: It shows the description of the run results event. Generally used to write the
actual result.
ImageFilePath: This is an optional parameter. Provide the path and filename of the
image to be displayed in the run results. Supported image formats are BMP, PNG,
JPEG, and GIF.
Examples:
In order to set the required report formats, navigate to Tools -> Options -> Run
Sessions -> Report Format -> Select any of the report format -> OK.
2. Set Method:
Example:
Example:
Window("Flight Reservation").WinRadioButton("Business").Set
Example:
Window ("Flight Reservation"). Dialog("Open
Order").WinCheckBox("Order No.").Set "ON”
3. Click Method:
Syntax:
(Object Hierarchy).Click
Example:
Window("Login").WebButton("Ok").click
OBJECT OPERATIONS IN QTP /
UFT
1. Save Object Repositories to XML Format:
The Object Repository Merge Window opens. Here, select two Object
Repository files for merge and click OK.
Display objects and their properties by using filter options; show all
objects, or show only conflicting objects.
OBJECT SPY, GETROPROPERTY,
GETTOPROPERTY IN QTP/UFT
1. Object Spy:
Object spy is a feature in QTP using which you can view both the test
and run-time object properties and methods.
Object Spy gives the complete hierarchy of the object you have
selected.
Object Spy can be accessed from the tool bar as shown below:
Clicking the Object Spy icon, the Object Spy Dialog box opens. The
Objects can be added to the repository on clicking the pointing hand.
After Spying the object, the object hierarchy will be shown. Let us say,
we are spying the "Numbers" link at "http://easycalculation.com/".
The Object properties will be as shown below.
After Spying an object, click the "Highlight" option to highlight the
object in the application.
For adding the object into the Object Repository, click the "Add
objects" button in the Object spy dialog.
The properties and its values are displayed for the selected object in
the dialog box, which should be unique for QTP, to recognize the
objects while the script executes.
Syntax:
Example:
Using Object Spy you can look for the required object property that
you want to retrieve at run-time from the application.
We can use the “selection” property as it showing the current value of
the WebList object. Write the following code to retrieve the value of
the selected item from the fromPort WebList box.
msgbox strListBoxUtem
3. SetToProperty:
Syntax:
Example:
Syntax:
object.GetTOProperty(Property)
Example:
GetToProperty retrieves the value of the specified description properties from the
test object description that means it retrieves the object property that is stored in
the object repository. It can’t return the runtime property of a Test Object from the
application.
For example, If we spy the object property of fromPort WebList box, its HTML ID
property value will be shown as empty.
We will set an “html id” value for it and try to retrieve its value using both
GetRoProperty and GetToProperty.
Browser("Welcome: Mercury Tours").Page("Find a Flight:
Mercury").WebList("fromPort").SetTOProperty "html id","123"
strRoProp=Browser("Welcome: Mercury Tours").Page("Find a Flight:
Mercury").WebList("fromPort").GetRoProperty("html id")
Print "Runtime value of html id: " & strRoProp
strToProp=Browser("Welcome: Mercury Tours").Page("Find a Flight:
Mercury").WebList("fromPort").GetToProperty("html id")
Print "Test Object value of html id: " & strToProp
If we execute the above code the output will be different for both. The GetRoProperty will
return an empty value. However, the GetToProperty will return to value 123.
VIRTUAL OBJECTS IN QTP / UFT
Sometimes, an application under test may contain standard window object but are
not recognized by QTP.
Under these circumstances, objects can be defined as virtual object of type button,
link etc. so that user actions can be simulated on the virtual objects during
execution.
Example:
Map the Object against the Class Type and click "Next".
Click "Mark Object" Button. A cross hair cursor would appear and mark the object
that you would like to map and click "Next".
Navigation to Virtual object Manager: "Tools" >> "Virtual Object Manager" as shown
below:
Using Virtual Objects:
After creating the Virtual Objects, the created object can be used as shown below:
Window("Microsoft Word").WinObject("Ribbon").VirtualButton("button").Click
Though we map an object to a particular class (button or List), all the methods of the
native objects are not supported by Virtual objects.
HOW OBJECT IDENTIFICATION
WORKS IN QTP/UFT
QTP also uses a “human” like technology for object identification. During record
time, QTP tries to learn the properties of a GUI object on which operation is
performed.
During Run-Time, UFT compares the stored object properties with actual properties
of the object available on screen and uniquely identifies an object independent of its
location on a screen.
The stored object and together with its properties is called TEST Object.
During Run-Time, the actual object available on the application under test is called
Run-Time Object.
QTP stores Object and its properties in the Object Repository to identify them during
run-time. An Object could have a large number of properties associated with it. For
example, in Web Environment, a Button could have the following properties
associated.
If QTP will try and remember all the available properties for an object, size of Object
Repository will bloat and script execution time will increase drastically.
To avoid this, QTP by default does not store all the properties of an object but a
limited no. of typical properties for an object which helps in its unique identification.
This choice of properties(to be saved during record time) for various environments
and objects is stored in Object Identification.
For example, for a WebButton property “name” and its value “Login” together can
be termed as Object Description for that Web Button.
You can select an environment and QTP auto-populates list of all the supported
objects belonging to that environment. On the right QTP lists the properties that will
be stored for the object. The list is divided into:
i. Mandatory Properties: The main and core object properties of the object.
ii. Assistive Properties: The optional properties that are recorded only when
UFT is unable to create a unique object description using mandatory
properties alone.
QTP will store a value of alt, HTML tag, image type, properties mandatory even if it
can uniquely identify it using the alt property alone.
In case it cannot create unique description using mandatory property, QTP will store
assistive property. In this case, QTP will store the class property.
If this property helps create a unique description of the object, QTP will not store the
file name, height property. If a class property is not sufficient to create a unique
description, QTP will store filename property. If filename property creates a unique
description QTP will not store height property and so on.
Suppose during Record Time, QTP has only stored class property. At Runtime, QTP
will forget the distinction between mandatory and assistive properties and compare
all the recorded properties.
Even if any one of the properties does not match its stored value, Script fails.
SMART IDENTIFICATION IN
QTP / UFT
If the usual object identification process fails, UFT triggers Smart Identification,
which is a more flexible mechanism for identifying objects provided it is enabled in
Object Identification settings.
ii. Optional Filter Properties: Other properties that can help identify objects.
Choose the Environment, Object Class and Turn ON "Enable Smart Identification" as
shown below:
Click Configure and choose the base and Optional Filter Properties.
Add Properties in Base Properties apart from the default one and also add/remove
Optional Filter Properties. Please note that same properties cannot be a part of both
Mandatory and Assistive Properties and click "OK".
Verify if the Smart Identification is enabled after adding object of that type in the
Object Repository. Smart Identification is set to TRUE. We can also make it False in
case we do not want to enable Smart Identification.
We can even disable a test Level by applying at test script level under "Settings" of
"File" Menu as shown below:
If the Smart Identification is disabled as per Step# 6 then it will not apply smart
identification for any object during the script execution.
In case the objects are added with Smart Identification as Off, QTP will not use Smart
Identification for recognizing in future, even though we have enabled it later.
ORDINAL IDENTIFIER IN QTP /
UFT
If mandatory and assistive properties are insufficient to identify an object during a
record session, QTP uses Ordinal Identifier in addition to other captured properties
to identify the objects during a record session.
By default, an ordinal identifier type exists for each test object class.
In the Object Identification Window, you can modify the default Ordinal Identifier for
an Object
1. Index Based:
When using Index based ordinal identifier, while recording, QTP will
assign a value to INDEX property of an object.
The value is based on the order in which the object appears within the
source code.
TextBox 1 0
TextBox 4 1
TextBox 2 2
TextBox 5 3
TextBox 3 4
TextBox 6 5
2. Location Based:
The value is based on the order in which the object appears within the
window, frame, or dialog box, in relation to other objects with
identical properties.
The first occurrence of the object is 0.
Values are assigned in columns from top to bottom and left to right.
3. Creation Time:
When using the creation time ordinal identifier, while recording, QTP
will assign a value to Creation Time property of a Web Browser.
This value indicates the order in which the browser was opened
relative to other open browsers.
The first browser that opens while recording receives the value
CreationTime=0 and succeeding browsers are given values 1, 2, 3 …
and so on.
'Sync's www.google.com
Browser("creationtime:=" ).Sync
'Highlights microsoft.com
Browser("creationtime:=2").Highlight
ACTIONS IN QTP/UFT
Actions helps testers to divide scripts into groups of QTP statements .
Actions are similar to functions in VBScript; however, there are a few differences.
The properties of the action can be accessed by right clicking on the Script Editor
Window and selecting "Properties".
Types of Actions:
Non – Reusable Action: An action that can be called only in that specific test in
which it has been designed and can be called only once.
Reusable Action: An action that can be called multiple times, any test in which it
resides, and can also be used by any other tests.
Working with Actions:
There are three options to insert an action:
i. Call to New Action
ii. Call to Copy of Action
iii. Call to Existing Action
Right click on the scripting area and select "Call to New Action".
In the "Insert Call to New Action" Window, give the test name,
description, and also specify if it is a reusable action or not. Most
importantly, select the location of the action to be inserted.
You can check the changes, graphically, in the test Name Tab as
shown below:
Testers can insert a copy of an existing action at any point of the script
by performing the following steps:
Right click on the scripting area and select "Call to Copy of Action".
In the "Insert Call to Copy of Action" Window, Select "Test Name",
"Action Name" and also select the location of the action to be
inserted.
Right click on the Scripting area and select "Call to Existing Action"
In the "Select Action" Window, give the test name, Action name,
description and also specify the location of the action to be inserted.
You can check the changes graphically in the test Name Tab as shown
below:
TYPES OF RECORDING MODES
IN QTP/UFT
HP UFT (QTP) supports 4 types of recording modes:
i. Normal Recording
ii. Analog Recording
iii. Low-level Recording
iv. Insight Recording
1. Normal Recording:
This is the default Recording mode that records the objects and the
operations performed on the application under test.
2. Analog Recording:
4. Insight Recording:
UFT records operations, based on its appearance and not based on its
native properties.
FUNCTIONS IN QTP / UFT
If you have segments of code that you need to use several times in your tests, you
may want to create a user-defined function.
By using user-defined functions, your tests are shorter, and easier to design, read,
and maintain.
Your own function libraries in Micro Focus UFT can contain VBScript functions,
subroutines, modules etc.
Function Demo
End Function
Associate the library with your test. Click File > Settings > Resources > Associate
Function Library.Click Add. Select The Function Library File. Click Okay
You can use the Step Generator from the Keyword View and also from the Editor.
The Step Generator utility provides options to define steps for the following three
categories namely:
i. Test Objects
ii. Utility Objects
iii. Functions
It is used to generate test steps using the test objects present in the
Object Repository.
Step Generator also gives you the option to select the object from the
application if the same is not available in the object repository.
If the required Test Object is not available in the Object drop-down,
click on the pointing hand icon as shown above. “Select Test Object”
window will be displayed with the Object tree to let you select the
required object.
Click on the “OK” button. The generated step will be added to the
current action of the Test.
Browser("Mercury Tours").Page("Mercury
Tours").WebEdit("userName").Set "TestUser1"
You can also parametrize the value rather than setting a constant
value. Click on the <#> icon next to the value column or press
Ctrl+F11. The Value Configuration Options window will be displayed.
You can parametrize the constant value with either DataTable or
Environment value.
To parameterize the value with DataTable, select the DataTable
option, and enter the name of the parameter and click on the “OK”
button.
This category can be used to generate steps for various utility objects
as shown below.
Let’s say, we have added a parameter UserName in the global sheet
of the DataTable and want to retrieve its value at runtime in UFT.
Select the DataTable object and provide the name of the ParameterID
and SheetID as shown below.
SYNCHRONISATION IN QTP /
UFT
Synchronization is used to match the speed of UFT test script execution with the
speed of the application under test.
i. Wait Statement - Wait is used when we want UFT to wait for the specified
time. Once the specified time is lapsed, UFT process with execution of the
next step.
ii. WaitProperty Statement - WaitProperty is used to wait until the given object
property achieves the specified value in the given timeout else it continues to
the next step.
iii. Sync Statement (Only for Web) - Sync statement Waits for the browser to
complete current navigation.
Syntax – BrowserObject.Sync
TRANSACTIONS IN QTP / UFT
Transactions in UFT can be used to measure how long does it take to execute a
section or a few steps of your test.
You define transactions within your test by enclosing the appropriate sections of the
test with start and end transaction statements.
Transactions can be inserted anywhere in the script. There is no limit to the number
of transactions that can be added to a test.
Select Insert Start Transaction from Design -> Start Transaction. Start Transaction
Dialog Box opens. The Start Transaction Dialog box will be displayed. In the Name
field, you will have to provide a valid name and click on the OK button.
The Start Transaction statement will be added at the line where the cursor was
placed before.
In the same fashion, we can add the End Transaction. Set the cursor at line number
and select “Design ->EndTransaction”. End Transaction dialog box will be displayed
with the name what we provided for start transaction. Click on the OK button.
The End Transaction will be added to the script as shown below.
Run your Test Script and open the test result. You can see all Start and End
Transactions in the result viewer. Upon clicking on the End Transaction it will show
how long it has taken to execute the code for the specific section of the code. Here
we can see that for LoginTransaction it took around 5.6323 seconds.
ENVIRONMENT VARIABLES IN
QTP / UFT
Environment variables are variables that describe the environment in which
programs run.
Environment variables are dynamic in nature, and it can be changed. There are a
number of environment variables that can be referenced by programs and can be
useful in finding information about their computing environment.
Micro Focus UFT environment variables can be accessed by all actions, function
library, and recovery scenarios.
1. Built-in Variables:
Before the execution of the test, these are the variables that are
defined by the user. It can be used globally across different tests, or
they can also be restricted to one test.
Internal
External
User defined – Internal Variables: These variables are defined by the user before
executing the test and these are available only to a particular test.
User defined- External Variables: These variables are defined by the user and it can
be used globally across different tests.
MsgBox Environment.Value(“Guru99”)
DEBUGGING IN UFT / QTP
Debugging, in automation testing context, is a systematic process of spotting and
fixing the coding issues in the automation script so that the script will be more
robust and can spot the defects in the application.
Debugging Methods:
Step Into: Used to execute each and every step. Mostly used to steps into a
Function/Action and executes line by line. It automatically pauses on each line after
execution.
Step Over: Used to step over the step or function. The ‘Step Over‘ runs only the
current step in the active document that means if you step over a function in your
test, the whole function will be executed in one go and the script will pause at the
next step of the function.
Step Out: After step into the function, you can use the Step Out option at any point
to come out from the function. The run session is paused at the next line.
VB SCRIPT VARIABLES
A variable is a named memory location used to hold a value that can be changed
during the script execution.
Variables are declared using “dim” keyword. Since there is only ONE fundamental
data type, all the declared variables are variant by default. Hence, a user NEED NOT
mention the type of data during declaration.
Datatypes in VB Script:
Empty
Null
Integer
Long
Single
Double
Currency
Date
String
Object
Option Explicit:
The Option Explicit statement forces the explicit declaration of all variables using the
Dim, Private, Public, or ReDim statements.
If we use Option Explicit and if we don't declare the variables then the interpreter
will throw and error.
Arrays in VB Script:
An Array is a variable having named memory location which serves as a Container
and can hold multiple values in a single location.
Dim arr3
arr3 = Array("apple","Orange","Grapes"
Dim Array1(1,1)
Redim Statement:
Redim Statement is used to re-define the size of an Array. When the array is
declared without any size, then it can be declared again using Redim with the
feasibility of specifying the size of an array.
Preserve Keyword:
Preserve keyword is used to preserve the contents of a current array when the size
of an array gets changed.
Msgbox in VB Script:
The MsgBox function displays a message box and waits for the user to click a button
and then an action is performed based on the button clicked by the user.
Syntax:
MsgBox(prompt[,buttons][,title][,helpfile,context])