Professional Documents
Culture Documents
Advanced QTP Book PDF
Advanced QTP Book PDF
Advanced QTP Book PDF
com
Advanced QTP
(In VBScript Orientation)
1) Introduction
2) Comments
3) VB Script Variables
5) VB Script Operators
6) Input/Output Operations
7) Constants
8) Conditional Statements
9) General Examples
11) Procedures
14) Errors
17) Solutions
Introduction
When a VBScript is inserted into a HTML document, the Internet browser will read
the HTML and interpret the VBScript. The VBScript can be executed immediately, or
at a later event.
Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of
environments, including Web client scripting in Microsoft Internet Explorer and Web
server scripting in Microsoft Internet Information Service.
That is, when a script arrives at your computer, WSH plays the part of the host — it
makes objects and services available for the script and provides a set of guidelines
within which the script is executed. Among other things, Windows Script Host
manages security and invokes the appropriate script engine
Windows Script Host is built into Microsoft Windows 98, 2000, and Millennium
Editions and higher versions.
A Windows script is a text file. We can create a script with any text editor as long as
we save our script with a WSH-compatible script extension (.js, vbs, or .wsf).
The most commonly available text editor is already installed on our computer —
Notepad. We can also use your favorite HTML editor, VbsEdit, Microsoft Visual C++,
or Visual InterDev.
1.Start Notepad.
2.Write your script. For example purposes, type Msgbox "Hello VB Script"
3.Save this text file with a .vbs extension (instead of the default .txt extension). For
example, Hello.vbs
5.Windows Script Host invokes the VB Script engine and runs your script. In the
example, a message box is displayed with the message "Hello VB Script"
Scripts are often embedded in Web pages, either in an HTML page (on the client
side) or in an ASP page (on the server side).
In the case of a script embedded in an HTML page, the engine component that
interprets and runs the script code is loaded by the Web browser, such as Internet
Explorer.
In the case of a script embedded in an ASP page, the engine that interprets and runs
the script code is built into Internet Information Services (IIS).
Windows Script Host executes scripts that exist outside an HTML or ASP page and
that stand on their own as text files.
Generally, we write scripts in either Microsoft JScript or VBScript, the two script
engines that ship with Microsoft Windows 98, 2000 and Millennium Editions.
We can use other script engines, such as Perl, REXX, and Python, with Windows
Script Host.
A stand-alone script written in JScript has the .js extension; a stand-alone script
written in VBScript has the .vbs extension. These extensions are registered with
Windows. When we run one of these types of files, Windows starts Windows Script
Host, which invokes the associated script engine to interpret and run the file.
Comments
2.1 Syntax
Rem comment (After the Rem keyword, a space is required before comment.)
Or
Select block of statement and use short cut key Ctrl + M (for comment)
Select comment block and use short cut key Ctrl + Shift + M (for uncomment)
2.3 Example
VB Script Variables
We declare variables explicitly in our script using the Dim statement, the Public
statement, and the Private statement.
For example:
Dim city
Dim x
We declare multiple variables by separating each variable name with a comma. For
Example:
We can also declare a variable implicitly by simply using its name in our script. That
is not generally a good practice because we could misspell the variable name in one
or more places, causing unexpected results when our script is run. For that reason,
the Option Explicit statement is available to require explicit declaration of all
variables.
The Option Explicit statement should be the first statement in our script.
Variable names follow the standard rules for naming anything in VBScript. A variable
name:
o Must begin with an alphabetic character.
o Cannot contain an embedded period.
o Must not exceed 255 characters.
o Must be unique in the scope in which it is declared.
When we declare a variable within a procedure, only code within that procedure can
access or change the value of that variable.
The lifetime of a script-level variable extends from the time it is declared until the
time the script is finished running.
At procedure level, a variable exists only as long as you are in the procedure.
The variable is on the left side of the expression and the value you want to assign to
the variable is on the right.
For example:
A = 200
City = “Hyderabad”
X=100: Y=200
Array variables and scalar variables are declared in the same way, except that the
declaration of an array variable uses parentheses () following the variable name.
Example:
Dim A(3)
Although the number shown in the parentheses is 3, all arrays in VBScript are zero-
based, so this array actually contains 4 elements.
We assign data to each of the elements of the array using an index into the array.
Beginning at zero and ending at 4, data can be assigned to the elements of an array
as follows:
A(0) = 256
A(1) = 324
A(2) = 100
A(3) = 55
Similarly, the data can be retrieved from any element using an index into the
particular array element you want.
For example:
SomeVariable = A(4)
In a two-dimensional array, the first number is always the number of rows; the
second number is the number of columns.
We can also declare an array whose size changes during the time our script is
running. This is called a dynamic array.
The array is initially declared within a procedure using either the Dim statement or
using the ReDim statement.
However, for a dynamic array, no size or number of dimensions is placed inside the
parentheses.
For example:
Dim MyArray()
ReDim AnotherArray()
To use a dynamic array, you must subsequently use ReDim to determine the number
of dimensions and the size of each dimension.
In the following example, ReDim sets the initial size of the dynamic array to 25. A
subsequent ReDim statement resizes the array to 30, but uses the Preserve keyword
to preserve the contents of the array as the resizing takes place.
ReDim MyArray(25)
There is no limit to the number of times we can resize a dynamic array, although if
we make an array smaller, we lose the data in the eliminated elements.
VBScript has only one data type called a Variant. A Variant is a special kind of data
type that can contain different kinds of information, depending on how it is used.
Because Variant is the only data type in VBScript, it is also the data type returned by
all functions in VBScript.
Beyond the simple numeric or string classifications, a Variant can make further
distinctions about the specific nature of numeric information. For example, we can
have numeric information that represents a date or a time. When used with other
date or time data, the result is always expressed as a date or a time. We can also
have a rich variety of numeric information ranging in size from Boolean values to
huge floating-point numbers. These different categories of information that can be
contained in a Variant are called subtypes. Most of the time, we can just put the kind
of data we want in a Variant, and the Variant behaves in a way that is most
appropriate for the data it contains.
The following table shows subtypes of data that a Variant can contain.
Subtype Description
Empty Variant is uninitialized. Value is 0 for numeric variables or a zero-length string
("") for string variables.
Null Variant intentionally contains no valid data.
Boolean Contains either True or False.
Byte Contains integer in the range 0 to 255.
Integer Contains integer in the range -32,768 to 32,767.
Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
Long Contains integer in the range -2,147,483,648 to 2,147,483,647.
Single Contains a single-precision, floating-point number in the range -3.402823E38
to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive
values.
Double Contains a double-precision, floating-point number in the range -
1.79769313486232E308 to -4.94065645841247E-324 for negative values;
4.94065645841247E-324 to 1.79769313486232E308 for positive values.
Date (Time) Contains a number that represents a date between January 1, 100 to
December 31, 9999.
String Contains a variable-length string that can be up to approximately 2 billion
characters in length.
Object Contains an object.
Error Contains an error number.
We can use conversion functions to convert data from one subtype to another. In
addition, the VarType function returns information about how your data is stored
within a Variant.
VB Script Operators
Operators are used for performing mathematical, comparison and logical operations.
VBScript has a full range of operators, including arithmetic operators, comparison
operators, concatenation operators, and logical operators.
When several operations occur in an expression, each part is evaluated and resolved
in a predetermined order called operator precedence.
We can use parentheses to override the order of precedence and force some parts of
an expression to be evaluated before others.
Operations within parentheses are always performed before those outside. Within
parentheses, however, standard operator precedence is maintained.
When expressions contain operators from more than one category, arithmetic
operators are evaluated first, comparison operators are evaluated next, and logical
operators are evaluated last.
Comparison operators all have equal precedence; that is, they are evaluated in the
left-to-right order in which they appear.
Arithmetic and logical operators are evaluated in the following order of precedence.
Operator Description
1) Exponentiation Operator (^) Raises a number to the power of an exponent
2) Multiplication Operator (*) Multiplies two numbers.
3) Division Operator (/) Divides two numbers and returns a floating-point
result.
4) Integer Division Operator (\) Divides two numbers and returns an integer result.
5) Mod Operator Divides two numbers and returns only the remainder.
6) Addition Operator (+) Sums two numbers.
7) Subtraction Operator (-) Finds the difference between two numbers or indicates
the negative value of a numeric expression.
Operator Description
1) = (Equal to) Used to compare expressions.
2) <> (Not equal to) Used to compare expressions.
3) < Less than
4) > Grater than
5) <= Less than or equal to
Operator Description
1) Addition Operator (+) Sums two numbers
If Then
1) Both expressions are numeric Add.
2) Both expressions are strings Concatenate.
3) One expression is numeric and the Add.
other is a string
2) Concatenation Forces string concatenation of two expressions.
Operator (&)
Input/Output Operations
Displays a prompt in a dialog box, waits for the user to input text or click a button,
and returns the contents of the text box.
Example:
Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)
Displays a message in a dialog box, waits for the user to click a button, and returns a
value indicating which button the user clicked.
Example:
Dim MyVar
MyVar = MsgBox ("Hello World!", 65, "MsgBox Example")
VB Script Constants
A constant is a meaningful name that takes the place of a number or string and
never changes.
We create user-defined constants in VBScript using the Const statement. Using the
Const statement, we can create string or numeric constants with meaningful names
and assign them literal values.
Const statement
Example:
Represent Date literals and time literals by enclosing them in number signs (#).
We declare multiple constants by separating each constant name and value with a
comma. For example:
Const price= 100, city= “Hyderabad”, x= 27
Conditional Statements
We can control the flow of our script with conditional statements and looping
statements.
Using conditional statements, we can write VBScript code that makes decisions and
repeats actions. The following conditional statements are available in VBScript:
1) If…Then…Else Statement
2) Select Case Statement
To run only one statement when a condition is True, use the single-line syntax for
the If...Then...Else statement.
Dim myDate
myDate = #2/13/98#
If myDate < Now Then myDate = Now
To run more than one line of code, we must use the multiple-line (or block) syntax.
This syntax includes the End If statement.
Dim x
x= 20
If x>10 Then
msgbox "Hello G.C.Reddy"
msgbox "x value is: "&x
msgbox "Bye Bye"
End If
Dim x
x= Inputbox (" Enter a value")
If x>100 Then
Msgbox "Hello G.C.Reddy"
Msgbox "X is a Big Number"
Msgbox "X value is: "&X
Else
Msgbox "GCR"
Msgbox "X is a Small Number"
Msgbox "X value is: "&X
End If
Else
Msgbox "Hello Sir"
Msgbox "X is a Grand Number"
End If
End If
End If
Example:
End If
End If
End If
End If
Option explicit
Dim x,y, Operation, Result
x= Inputbox (" Enter x value")
y= Inputbox ("Enter y value")
Operation= Inputbox ("Enter an Operation")
Case "add"
Result= cdbl (x)+cdbl (y)
Msgbox "Hello G.C.Reddy"
Msgbox "Addition of x,y values is "&Result
Case "sub"
Result= x-y
Msgbox "Hello G.C.Reddy"
Msgbox "Substraction of x,y values is "&Result
Case "mul"
Result= x*y
Msgbox "Hello G.C.Reddy"
Msgbox "Multiplication of x,y values is "&Result
Case "div"
Result= x/y
Msgbox "Hello G.C.Reddy"
Msgbox "Division of x,y values is "&Result
Case "mod"
Result= x mod y
Msgbox "Hello G.C.Reddy"
Msgbox "Mod of x,y values is "&Result
Case "expo"
Result= x^y
Msgbox "Hello G.C.Reddy"
Msgbox"Exponentation of x,y values is "&Result
Case Else
Msgbox "Hello G.C.Reddy"
msgbox "Wrong Operation"
End Select
8.3.1 Write a program for finding out whether the given year is a leap year
or not?
Dim xyear
xyear=inputbox ("Enter Year")
8.3.2 Write a program for finding out whether the given number is, Even
number or Odd number?
Dim num
num=inputbox ("Enter a number")
sum= Cdbl (num1) + Cdbl (num2) 'if we want add two strings conversion
require
msgbox ("Sum is " &sum)
Dim p,t, r, si
p=inputbox ("Enter Principle")
t=inputbox ("Enter Time")
r=inputbox ("Enter Rate of Interest")
si= (p*t*r)/100 ' p= principle amount, t=time in years, r= rate of interest
msgbox ("Simple Interest is " &si)
8.3.5 Read Four digit number, calculate & display the sum of the number or
display Error message if the number is not a four digit number?
8.3.6 Read any Four-digit number and display the number in reverse order?
Dim num,rev
num= inputbox("Enter a number")
If len(num)=4 Then
Else
msgbox "Number, you entered is not a 4 digit number"
End If
8.3.7 Read 4 subjects marks; calculate the Total marks and grade?
(a) If average marks Greater than or equal to 75, grade is Distinction
b) If average marks Greater than or equal to 60 and less than 75 , then grade is
First
c) If average marks Greater than or equal to 50 and less than 60 , then grade is
Second
d) If average marks Greater than or equal to 40 and less than 50 , then grade is
Third
e) Minimum marks 35 for any subject, otherwise 'no grade fail')
If cdbl(e) >=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot
>=300 Then
msgbox "Grade is Distinction"
else If cdbl(e) >=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot
>=240 and tot<300 Then
msgbox "Grade is First"
else If cdbl(e) >=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot
>=200 and tot<240 Then
msgbox "Grade is Second"
else If cdbl(e) >=35 and cdbl(m) >=35 and cdbl(p) >=35 and cdbl(c) >=35 and tot
>=160 and tot<200 Then
msgbox "Grade is Third"
else
msgbox "No Grade, Fail"
End If
End If
End If
End If
Dim num,n
n=Inputbox ("Enter a Vaule")
For num= 1 to n step 2
msgbox num
Next
Dim num,n
n=Inputbox ("Enter a Vaule")
For num= 2 to n step 2
msgbox num
Next
Dim num,n
n=Inputbox ("Enter a Vaule")
For num=n to 1 step -1
msgbox num
Next
8.16 Verify weather the entered 10 digit value is a numeric value or not?
Dim a,x,y,z,num
num=Inputbox ("Enter a Phone Number")
If isnumeric (d1) = "True" and isnumeric (d2) = "True" and isnumeric (d3) = "True"
and isnumeric (d4) = "True"and isnumeric (d5) = "True"and isnumeric (d6) =
"True"and isnumeric (d7) = "True"and isnumeric (d8) = "True"and isnumeric (d9) =
"True"and isnumeric (d10) = "True" Then
msgbox "It is a Numeric Value"
else
Msgbox "It is NOT Numeric"
End If
8.17 Verify weather the entered value is a 10 digit value or not and Numeric
value or not? (Using multiple if conditions)
Dim a,x,y,z,num
num=Inputbox ("Enter a Phone Number")
If isnumeric (d1) = "True" and isnumeric (d2) = "True" and isnumeric (d3) = "True"
and isnumeric (d4) = "True"and isnumeric (d5) = "True"and isnumeric (d6) =
"True"and isnumeric (d7) = "True"and isnumeric (d8) = "True"and isnumeric (d9) =
"True"and isnumeric (d10) = "True" Then
msgbox "It is a Numeric Value"
End If
End If
The statements are repeated either while a condition is True or until a condition
becomes True.
a) Do While condition
Statements
-----------
-----------
Loop
Or, we can use this below syntax:
Example:
Dim x
Do While x<5 x=x+1
Msgbox "Hello G.C.Reddy"
Msgbox "Hello QTP"
Loop
b) Do
Statements
-----------
-----------
Loop While condition
Example:
Dim x
x=1
Do
Msgbox "Hello G.C.Reddy"
Msgbox "Hello QTP"
x=x+1
Loop While x<5
c) Do Until condition
Statements
-----------
-----------
Loop
Or, we can use this below syntax:
Example:
Dim x
Do Until x=5 x=x+1
Msgbox "G.C.Reddy"
Msgbox "Hello QTP"
Loop
Or, we can use this below syntax:
d) Do
Statements
-----------
-----------
Loop Until condition
Or, we can use this below syntax:
Example:
Dim x
x=1
Do
Msgbox “Hello G.C.Reddy”
Msgbox "Hello QTP"
x=x+1
Loop Until x=5
Syntax:
While condition
Statements
-----------
-----------
Wend
Example:
Dim x
x=0
While x<5 x=x+1
msgbox "Hello G.C.Reddy"
msgbox "Hello QTP"
Wend
Example:
Dim x
For x= 1 to 5 step 1
Msgbox "Hello G.C.Reddy"
Next
Syntax:
Example: (1
Example: (2
MyArray = Array("one","two","three","four","five")
For Each element In MyArray
msgbox element
Next
11.1 read a number and verify that number Range weather in between 1 to
100 or 101 to 1000?
Option explicit
Dim a,x
a=Inputbox ("Enter a Vaule")
a=cdbl(a)
If a<= 100 Then
For x= 1 to 100
If a=x Then
msgbox "a is in between 1 to 100 range"
End If
Next
else
For x= 101 to 1000
If a=x Then
msgbox "a is in between 101 to 1000 range"
End If
Next
End If
11.1 read Data and find that data size, If size <>4 then display invalid data
message, if data size = 4 then verify “a” is there or not in that data?
Dim x
x=Inputbox ("Enter 4 digit value")
x1=Right(x,1)
x2=Left (x,1)
x3=mid (x,2,Len(1))
x4=mid (x,3,Len(1))
y=len(x)
If y=4 Then
If x1="a" or x2="a" or x3="a" or x4="a" Then
msgbox "a is there"
else
msgbox "a is Not there"
End If
else
msgbox "Invalid Data"
End If
VB Script Procedures
In VBScript, there are two kinds of procedures available; the Sub procedure and the
Function procedure.
A Sub procedure is a series of VBScript statements (enclosed by Sub and End Sub
statements) that perform actions but don't return a value.
A Sub procedure can take arguments (constants, variables, or expressions that are
passed by a calling procedure).
If a Sub procedure has no arguments, its Sub statement must include an empty set
of parentheses ().
Syntax:
Sub Procedure name ()
Statements
-----------
-----------
End Sub
Or
Sub Procedure name (argument1, argument2)
Statements
-----------
-----------
End Sub
Example: 1
Sub ConvertTemp()
temp = InputBox("Please enter the temperature in degrees F.", 1)
MsgBox "The temperature is " & Celsius(temp) & " degrees C."
End Sub
Example: 2
A Function procedure is similar to a Sub procedure, but can also return a value.
Example: 1
Function Celsius(fDegrees)
Celsius = (fDegrees - 32) * 5 / 9
End Function
Example: 2
Function cal(a,b,c)
cal = (a+b+c)
End Function
A Function in our code must always be used on the right side of a variable
assignment or in an expression.
For example:
Temp = Celsius(fDegrees)
-Or-
MsgBox "The Celsius temperature is " & Celsius(fDegrees) & " degrees."
To call a Sub procedure from another procedure, type the name of the procedure
along with values for any required arguments, each separated by a comma.
The Call statement is not required, but if you do use it, you must enclose any
arguments in parentheses.
The following example shows two calls to the MyProc procedure. One uses the Call
statement in the code; the other doesn't. Both do exactly the same thing.
Notice that the parentheses are omitted in the call when the Call statement isn't
used.
Types of Functions
o Conversions (25)
o Dates/Times (19)
o Formatting Strings (4)
o Input/Output (3)
o Math (9)
o Miscellaneous (3)
o Rounding (5)
o Strings (30)
o Variants (8)
Important Functions
1) Abs Function
Returns the absolute value of a number.
Dim num
num=abs(-50.33)
msgbox num
2) Array Function
Returns a variant containing an Array
Dim A
A=Array("hyderabad","chennai","mumbai")
msgbox A(0)
ReDim A(5)
A(4)="nellore"
msgbox A(4)
3) Asc Function
Returns the ANSI character code corresponding to the first letter in a string.
Dim num
num=Asc("A")
msgbox num
4) Chr Function
Returns the character associated with the specified ANSI character code.
Dim char
Char=Chr(65)
msgbox char
* It returns A *
5) CInt Function
Returns an expression that has been converted to a Variant of subtype Integer.
Dim num
num=123.45
myInt=CInt(num)
msgbox MyInt
6) Date Function
Dim mydate
mydate=Date
msgbox mydate
7) Day Function
8) DateDiff Function
Returns the number of intervals between two dates.
Dim myday
mydate=#02-17-2009#
x=Datediff("d",mydate,Now)
msgbox x
9) Hour Function
Returns a whole number between 0 and 23, inclusive, representing the hour of the
day.
Dim mytime, Myhour
mytime=Now
myhour=hour (mytime)
msgbox myhour
Dim MyCheck
MyCheck = VarType(300) ' Returns 2.
Msgbox Mycheck
* It Returns ‘Script’ *
Function myTime(N)
Dim StartTime, EndTime
StartTime = Timer
For I = 1 To N
Next
EndTime = Timer
myTime= EndTime - StartTime
msgbox myTime
End Function
Call myTime(2000)
MyVar = "459.95"
MyCheck = IsNumeric(MyVar)
msgbox MyCheck
Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)
21.1 Case-sensitivity:
By default, VBScript is not case sensitive and does not differentiate between upper
case and lower-case spelling of words, for example, in variables, object and method
names, or constants.
When we enter a value as a text string, we must add quotation marks before and
after the string. For example, in the above segment of script, the names of the Web
site, Web page, and edit box are all text strings surrounded by quotation marks.
Note that the value 31 is also surrounded by quotation marks, because it is a text
string that represents a number and not a numeric value.
In the following example, only the property name (first argument) is a text string
and is in quotation marks. The second argument (the value of the property) is a
variable and therefore does not have quotation marks. The third argument
(specifying the timeout) is a numeric value, which also does not need quotation
marks.
21.3 Variables:
We can specify variables to store strings, integers, arrays and objects. Using
variables helps to make our script more readable and flexible
21.4 Parentheses:
To achieve the desired result and to avoid errors, it is important that we use
parentheses () correctly in our statements.
21.5 Indentation:
We can indent or outdent our script to reflect the logical structure and nesting of the
statements.
21.6 Comments:
We can add comments to our statements using an apostrophe ('), either at the
beginning of a separate line, or at the end of a statement. It is recommended that
we add comments wherever possible, to make our scripts easier to understand and
maintain.
21.7 Spaces:
We can add extra blank spaces to our script to improve clarity. These spaces are
ignored by VBScript.
Errors
We have two types Errors in VB Script; they are VBScript Run-time Errors and
VBScript Syntax Errors
VBScript run-time errors are errors that result when our VBScript script attempts to
perform an action that the system cannot execute. VBScript run-time errors occur
while our script is being executed; when variable expressions are being evaluated,
and memory is being dynamic allocated.
VBScript syntax errors are errors that result when the structure of one of our
VBScript statements violates one or more of the grammatical rules of the VBScript
scripting language. VBScript syntax errors occur during the program compilation
stage, before the program has begun to be executed.
a) Creating a Folder
Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\logs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
b) Deleting a Folder
c) Copying Folders
Set oFSO=createobject("Scripting.Filesystemobject")
oFSO.CopyFolder "E:\gcr6", "C:\jvr", True
d) Checking weather the folder available or not, if not creating the folder
Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\logs"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
msgbox strDirectory & " already created "
else
Set objFolder = objFSO.CreateFolder(strDirectory)
end if
b) Checking weather the File is available or not, if not creating the File
strDirectory="E:\"
strFile="Scripting.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile("E:\ScriptLog.txt")
End if
e) Reading data from a flat file and using in data driven testing
Dim fso,myfile
Set fso=createobject("scripting.filesystemobject")
Set myfile= fso.opentextfile ("F:\gcr.txt",1)
myfile.skipline
While myfile.atendofline <> True
x=myfile.readline
s=split (x, ",")
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury
Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set s(0)
Dialog("Login").WinEdit("Password:").SetSecure s(1)
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Wend
Set objFSO=createobject("Scripting.filesystemobject")
Set txtFilepath = objFSO.GetFile("E:\gcr.txt")
txtFilepath.Delete()
strDirectory="E:\"
strFile="gcr.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strDirectory & strFile) Then
Set objFile = objFSO.Getfile(strDirectory & strFile)
objFile.delete ()
End if
Dim f1, f2
f1="e:\gcr1.txt"
f2="e:\gcr2.txt"
Public Function CompareFiles (FilePath1, FilePath2)
Dim FS, File1, File2
Set FS = CreateObject("Scripting.FileSystemObject")
CompareFiles = False
Do While File1.AtEndOfStream = False
Str1 = File1.Read
Str2 = File2.Read
File1.Close()
File2.Close()
End Function
Call Comparefiles(f1,f2)
End If
sFileName="E:\gcr.txt"
sString="gcreddy"
Const FOR_READING = 1
Dim oFso, oTxtFile, sReadTxt, oRegEx, oMatches
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oTxtFile = oFso.OpenTextFile(sFileName, FOR_READING)
sReadTxt = oTxtFile.ReadAll
Set oRegEx = New RegExp
oRegEx.Pattern = sString
oRegEx.IgnoreCase = bIgnoreCase
oRegEx.Global = True
Set oMatches = oRegEx.Execute(sReadTxt)
MatchesFound = oMatches.Count
Set oTxtFile = Nothing : Set oFso = Nothing : Set oRegEx = Nothing
msgbox MatchesFound
Dim objWD
Set objWD = CreateObject("Word.Application")
objWD.Documents.Add
objWD.Selection.TypeText "This is some text." & Chr(13) & "This is some more
text"
objWD.ActiveDocument.SaveAs "e:\gcreddy.doc"
objWD.Quit
Dim objexcel
Set objExcel = createobject("Excel.application")
objexcel.Visible = True
objexcel.Workbooks.add
objexcel.Cells(1, 1).Value = "Testing"
objexcel.ActiveWorkbook.SaveAs("f:\gcreddy1.xls")
objexcel.Quit
Test Requirements
1) Verify Login Boundary (Check all the boundary conditions of the Login
window. Checks to see if the correct message appears in the error window
(Flight Reservation Message)
2) Verify Cancel Operation (in Login Dialog box, if user selects cancel button,
before enter any data after enter data dialog box should be disappeared.)
4) Verify state of Update Order Button, before open an Order and after
open an Order (in Flight Reservation before opening an order Update Order
button should be disabled after opening an order enabled.)
7) Verify Flight From & Flight To Combo Boxes (In Flight reservation, select
an item from Fly From: combo box and verify weather that item available or
not in Fly To: combo box, like this select all items one by one in Fly From and
verify weather selected items available or not in Fly To.)
8) Verify Order No Entry in Flight Reservation. (In Open Order dialog box,
Order No object accepts numeric values only.)
9) Get Test Data from a Flat file and use in Data Driven Testing (through
Scripting)
10) Get Test Data From a Database and use in Data Driven Testing
(through Scripting)
11) Count, how many links available in Mercury Tours Home Page?
12) Count how many Buttons and Edit boxes available in Flight
Reservation window?
14) In Login Dialog box, Verify Help message (The message is ‘The password is
'MERCURY')
16) Create an Excel file, enter some data and save the file through VB
scripting?
Solutions:
1) Verify Login Boundary (Check all the boundary conditions of the Login
dialog box. Checks to see if the correct message appears in the error window
(Flight Reservation Message)
1) ApplicationDir = Environment("ProductDir")
2) ApplicationPath = "\samples\flight\app\flight4a.exe"
3) If Window("Flight Reservation").Exist(2) Then
4) Window("Flight Reservation").Close
5) SystemUtil.Run ApplicationDir & ApplicationPath
6) Elseif Not Dialog("Login").Exist(1) Then
7) SystemUtil.Run ApplicationDir & ApplicationPath
8) End If
9) Dialog("Login").WinEdit("Agent Name:").Set Datatable.Value
("AgentName",dtGlobalSheet)
10) Dialog("Login").WinEdit("Password:").Set Datatable.Value
("Password",dtGlobalSheet)
11) Dialog("Login").WinButton("OK").Click
12) If Dialog("Login").Dialog("Flight Reservations").Exist(1) and
Datatable.Value ("Status",dtGlobalSheet)="Fail" Then
13) Dialog("Login").Dialog("Flight Reservations").Static("Agent name must
be at").Check CheckPoint("Agent name must be at least 4 characters
long.")
14) Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
2) Verify Cancel Operation (in Login Dialog box, if user selects cancel button,
before enter any data after enter data dialog box should be disappeared.)
4) Verify state of Update Order Button, before open an Order and after open
an Order (in Flight Reservation before opening an order Update Order button should
be disabled after opening an order enabled.)
1) Option explicit
2) Dim bo,ao
3) If Not window("Flight Reservation").Exist (2) Then
4) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe"
5) Dialog("Login").Activate
6) Dialog("Login").WinEdit("Agent Name:").Set "Gcreddy"
7) Dialog("Login").WinEdit("Password:").SetSecure
"4aa8bce9984f1a15ea187a2da5b18c545abb01cf"
8) Dialog("Login").WinButton("OK").Click
9) End If
10) Window("Flight Reservation").Activate
11) bo=Window("Flight Reservation").WinButton("Update Order").GetROProperty
("Enabled")
1) Option explicit
2) Dim n,f,b,e
3) If Not window("Flight Reservation").Exist (2) Then
4) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe"
5) Dialog("Login").Activate
6) Dialog("Login").WinEdit("Agent Name:").Set "asdf"
7) Dialog("Login").WinEdit("Password:").SetSecure
"4aa8b7b7c5823680cfcb24d30714c9bbf0dff1eb"
8) Dialog("Login").WinButton("OK").Click
9) End If
10) For n= 1 to 10 step 1
11) Window("Flight Reservation").Activate
12) Window("Flight Reservation").WinButton("Button").Click
13) Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
1) Option Explicit
2) Dim t,p,tot,n
3) For n= 1 to 10 step 1
4) If Not window("Flight Reservation").Exist (2) Then
5) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury
Interactive\QuickTest Professional\samples\flight\app\","open"
6) Dialog("Login").Activate
7) Dialog("Login").WinEdit("Agent Name:").Set "Gcreddy"
8) Dialog("Login").WinEdit("Password:").SetSecure
"4aa892d62c529f1c23298175ad78c58f43da8e34"
9) Dialog("Login").WinButton("OK").Click
10) End If
7) Verify Flight From & Flight To Combo Boxes (In Flight reservation, select an
item from Fly From: combo box and verify weather that item available or not in Fly
To: combo box, like this select all items one by one in Fly From and verify weather
selected items available or not in Fly To.)
1) Option explicit
2) Dim qtp,flight_app,f,t,i,j,x,y
3) If Not Window("text:=Flight Reservation").Exist (7)= True Then
4) QTP=Environment("ProductDir")
5) Flight_app="\samples\flight\app\flight4a.exe"
6) SystemUtil.Run QTP & Flight_app
7) Dialog("text:=Login").Activate
8) Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "asdf"
9) Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure
"4aa5ed3daf680e7a759bee1c541939d3a54a5b65"
10) Dialog("text:=Login").WinButton("text:=OK").Click
11) End If
9) Window("Flight Reservation").WinButton("Button").Click
10) Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
11) Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "a"
12) ord=Window("Flight Reservation").Dialog("Open
Order").WinEdit("Edit").GetVisibleText
13) If ord= "a" Then
14) Reporter.ReportEvent 1,"Res","Order No Object is taking invalid data"
15) else
16) Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "1"
17) Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
18) End If
9) Get Test Data from a Flat file and use in Data Driven Testing (through
Scripting)
1) Dim fso,myfile
2) Set fso=createobject("scripting.filesystemobject")
3) Set myfile= fso.opentextfile ("F:\gcr.txt",1)
4) myfile.skipline
5) While myfile.atendofline <> True
6) x=myfile.readline
7) s=split (x, ",")
8) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe"
9) Dialog("Login").Activate
10) Dialog("Login").WinEdit("Agent Name:").Set s(0)
11) Dialog("Login").WinEdit("Password:").SetSecure s(1)
12) Dialog("Login").WinButton("OK").Click
13) Window("Flight Reservation").Close
14) Wend
10) Get Test Data From a Database and use in Data Driven Testing (through
Scripting)
1) Dim con,rs
2) Set con=createobject("Adodb.connection")
3) Set rs=createobject("Adodb.recordset")
4) con.provider=("microsoft.jet.oledb.4.0")
11) Count, how many links available in Mercury Tours Home Page.
1) Set oDesc = Description.Create()
2) oDesc("micclass").Value = "Link"
3) Set Lists = Browser("Welcome: Mercury").Page("Welcome:
Mercury").ChildObjects (oDesc)
4) NumberOfLinks = Lists.Count()
5) Reporter.ReportEvent 2,"Res","Number of Links are: "&NumberOfLinks
12) Count, how many Buttons and Edit boxes available in Flight Reservation
main window.
17) If (oe=true and ce=true and fe=true) and (oc="OFF" and cc="OFF" and
fc="OFF") Then
18) Reporter.ReportEvent 0,"Res","Pass"
19) else
20) Reporter.ReportEvent 1,"Res","Fail"
21) End If
22) Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "ON"
23) ono=Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Order No.").GetROProperty ("Checked")
24) If ono="ON" Then
25) fd=Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Flight
Date").GetROProperty ("Enabled")
26) ono=Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Customer Name").GetROProperty ("Enabled")
27) fd=false
28) ono=false
29) Reporter.ReportEvent 0,"Res","Pass"
30) else
31) Reporter.ReportEvent 1,"Res","Fail"
32) End If
33) Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order
No.").Set "OFF"
34) Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer
Name").Set "ON"
35) cn=Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Customer Name").GetROProperty ("Checked")
36) If cn="ON" Then
37) ono=Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Order No.").GetROProperty ("Enabled")
38) fd=Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Flight
Date").GetROProperty ("Enabled")
39) fd=True
40) ono=false
41) Reporter.ReportEvent 0,"Res","Pass"
42) else
43) Reporter.ReportEvent 1,"Res","Fail"
44) End If
15) Count all opened Browsers on desktop and close them all?
1) Set oDesc = Description.Create()
2) oDesc("micclass").Value = "Browser"
3) Set Browsers =Desktop.ChildObjects (oDesc)
4) NumberofBrowsers = Browsers.Count()
16) Create an Excel file, enter some data and save the file through VB
scripting?
1) Dim objexcel
2) Set objExcel = createobject("Excel.application")
3) objexcel.Visible = True
4) objexcel.Workbooks.add
5) objexcel.Cells(1, 1).Value = "Testing"
6) objexcel.ActiveWorkbook.SaveAs("f:\exceltest.xls")
7) objexcel.Quit
Object Description
ActiveX An ActiveX control.
AcxButton An ActiveX button.
AcxCalendar An ActiveX calendar object.
AcxCheckBox An ActiveX check box.
AcxComboBox An ActiveX combo box object.
AcxEdit An ActiveX edit box.
AcxRadioButton An ActiveX radio button.
AcxTable An ActiveX table.
An object that enables you to work with objects
AcxUtil returned by performing an operation (usually via
the Object property) on an ActiveX test object.
Object Description
DelphiButton A Delphi button.
DelphiCheckBox A Delphi check box.
DelphiComboBox A Delphi combo box.
DelphiEdit A Delphi edit box.
DelphiEditor A Delphi multi-line editor.
DelphiList A Delphi list.
DelphiListView A Delphi list-view control.
DelphiNavigator A Delphi navigator control.
DelphiObject A Delphi object.
DelphiRadioButton A Delphi radio button.
DelphiScrollBar A Delphi scroll bar.
DelphiSpin A Delphi spin box.
DelphiStatic A Delphi static control.
DelphiStatusBar A Delphi status bar.
DelphiTable A Delphi table.
DelphiTabStrip A Delphi tab strip.
DelphiTreeView A Delphi tree-view control.
Object Description
JavaApplet A Java applet.
JavaButton A Java button.
JavaCalendar A Java calendar.
JavaCheckBox A Java check box.
JavaDialog A Java dialog box.
JavaEdit A Java edit box.
A Java control that contains labeled
JavaExpandBar bar items, which can be expanded
or collapsed by the user.
An internal frame that can be
JavaInternalFrame
activated from the Java applet.
A Java control that displays text
JavaLink
with links.
A Java list box with single or
JavaList
multiple selection.
JavaMenu A Java menu item.
JavaObject A generic Java object.
JavaRadioButton A Java radio button.
JavaSlider A Java slider.
JavaSpin A Java spin object.
JavaStaticText A Java static text object.
A Java tabstrip control containing
JavaTab
tabbed panels.
JavaTable A Java table.
JavaToolbar A Java toolbar.
JavaTree A Java tree.
JavaWindow A Java window.
Object Description
WbfCalendar A .NET Web Forms calendar control.
WbfGrid A .NET Web Forms DataGrid object.
Object Description
SwfButton A .NET Windows Forms button object.
A DateTimePicker or a Month Calendar .NET
SwfCalendar
Windows Forms calendar object.
SwfCheckBox A .NET Windows Forms check box.
SwfComboBox A .NET Windows Forms combo box.
SwfEdit A .NET Windows Forms edit box.
SwfEditor A .NET Windows Forms multi-line edit box.
SwfLabel A .NET Windows Forms static text object.
SwfList A .NET Windows Forms list.
SwfListView A .NET Windows Forms ListView control.
SwfObject A standard .NET Windows Forms object.
A property grid control based on the .NET
SwfPropertyGrid
Windows Forms library.
SwfRadioButton A .NET Windows Forms radio button.
SwfScrollBar A .NET Windows Forms scroll bar.
SwfSpin A .NET Windows Forms spin object.
SwfStatusBar A .NET Windows Forms status bar control.
SwfTab A .NET Windows Forms tab control.
A grid control based on the .NET Windows Forms
SwfTable
library.
SwfToolBar A .NET Windows Forms toolbar.
SwfTreeView A .NET Windows Forms TreeView control.
SwfWindow A .NET Windows Forms window.
Object Description
A button control in a Windows Presentation
WpfButton
Foundation application.
Object Description
OracleApplications An Oracle Applications session window.
OracleButton An Oracle button.
OracleCalendar An Oracle calendar.
OracleCheckbox A check box Oracle field.
OracleFlexWindow An Oracle flexfield window.
OracleFormWindow An Oracle Form window.
OracleList An Oracle poplist (combo box) or list.
An Oracle window containing a list of values for
OracleListOfValues
selection.
OracleLogon An Oracle Applications sign-on window.
OracleNavigator An Oracle Navigator window.
OracleNotification An Oracle error or message window.
OracleRadioGroup An Oracle option (radio button) group.
The status line and message line at the bottom
OracleStatusLine
of an Oracle Applications window.
OracleTabbedRegion An Oracle tabbed region.
OracleTable An Oracle block of records.
OracleTextField An Oracle text field.
OracleTree An Oracle tree.
Object Description
PSFrame A frame object within a PeopleSoft application.
Object Description
PbButton A PowerBuilder button.
PbCheckBox A PowerBuilder check box.
PbComboBox A PowerBuilder combo box.
PbDataWindow A PowerBuilder DataWindow control.
PbEdit A PowerBuilder edit box.
PbList A PowerBuilder list.
Object Description
An SAP Gui for HTML application button,
including icons, toolbar buttons, regular buttons,
SAPButton
buttons with text, and buttons with text and
image.
SAPCalendar A calendar in a Web-based SAP application.
An SAP Gui for HTML application toggle button,
SAPCheckBox
including check boxes and toggle images.
A menu that is opened by clicking a menu icon
SAPDropDownMenu
within an SAP Gui for HTML application.
An SAP Gui for HTML application edit box,
SAPEdit including single-line edit boxes and multi-line
edit boxes (text area).
SAPFrame An SAP Gui for HTML application frame.
SAPiView An SAP Enterprise Portal application iView frame.
A drop-down or single/multiple selection list in an
SAPList
SAP Gui for HTML application.
SAPMenu An SAP Gui for HTML application top-level menu.
SAPNavigationBar A navigation bar in a Web-based SAP application.
An OK Code box in an SAP Gui for HTML
SAPOKCode
application.
SAPPortal An SAP Enterprise Portal desktop.
An SAP Gui for HTML application radio button
SAPRadioGroup
group.
SAPStatusBar An SAP Gui for HTML application status bar.
SAPTable An SAP Gui for HTML application table or grid.
An SAP Gui for HTML application tab strip object
SAPTabStrip
(an object that enables switching between
multiple tabs).
SAPTreeView An SAP Gui for HTML application tree object.
Object Description
An APO grid control in an SAP GUI for Windows
SAPGuiAPOGrid
application.
SAPGuiButton A button in an SAP GUI for Windows application.
A calendar object in an SAP GUI for Windows
SAPGuiCalendar
application.
A check box in an SAP GUI for Windows
SAPGuiCheckBox
application.
A combo box in an SAP GUI for Windows
SAPGuiComboBox
application.
An edit box in an SAP GUI for Windows
SAPGuiEdit
application.
Any object in an SAP GUI for Windows
SAPGuiElement
application.
A grid control in an SAP GUI for Windows
SAPGuiGrid
application.
A static text label in an SAP GUI for Windows
SAPGuiLabel
application.
A menu bar in an SAP GUI for Windows
SAPGuiMenubar
application.
An OK Code box in an SAP GUI for Windows
SAPGuiOKCode
application.
A radio button in an SAP GUI for Windows
SAPGuiRadioButton
application.
Represents the SAP GUI for Windows session on
SAPGuiSession
which an operation is performed.
A status bar in an SAP GUI for Windows
SAPGuiStatusBar
application.
A table control in an SAP GUI for Windows
SAPGuiTable
application.
A tab strip in an SAP GUI for Windows
SAPGuiTabStrip
application.
A text area in an SAP GUI for Windows
SAPGuiTextArea
application.
Object Description
An edit box whose value can be set by a
SblAdvancedEdit dynamic object that opens after clicking
on a button inside the edit box
SblButton A Siebel button.
SblCheckBox A check box with an ON and OFF state.
SblEdit An edit box.
SblPickList A drop-down pick list.
A Siebel table containing a variable
SblTable
number of rows and columns.
A number of tabs and four arrows that
SblTabStrip move its visible range to the left and to
the right.
SblTreeView A tree view of specific screen data.
An applet in a Siebel test automation
SiebApplet
environment.
An application in a Siebel test automation
SiebApplication
environment.
A button control in a Siebel test
SiebButton
automation environment.
A calculator control in a Siebel test
SiebCalculator
automation environment.
A calendar control in a Siebel test
SiebCalendar
automation environment.
A checkbox in a Siebel test automation
SiebCheckbox
environment.
The communications toolbar in a Siebel
SiebCommunicationsToolbar
test automation environment.
SiebCurrency A currency calculator in a Siebel test
automation environment.
A list object in a Siebel test automation
SiebList
environment.
A menu or menu item in a Siebel test
SiebMenu
automation environment.
A page tab in a Siebel test automation
SiebPageTabs
environment.
A predefined query in a Siebel test
SiebPDQ
automation environment.
A pick list in a Siebel test automation
SiebPicklist
environment.
A rich text control in a Siebel test
SiebRichText
automation environment.
A screen object in a Siebel test
SiebScreen
automation environment.
A screen view in a Siebel test automation
SiebScreenViews
environment.
The Task Assistant in a Siebel test
SiebTaskAssistant
automation environment.
The task UI pane in a Siebel test
SiebTaskUIPane
automation environment.
A text box in a Siebel test automation
SiebText
environment.
A text area in a Siebel test automation
SiebTextArea
environment.
A threadbar in a Siebel test automation
SiebThreadbar
environment.
A toolbar in a Siebel test automation
SiebToolbar
environment.
A tree view object in a Siebel test
SiebTree
automation environment.
A view object in a Siebel test automation
SiebView
environment.
A view applet in a Siebel test automation
SiebViewApplets
environment.
Object Description
An object that enables you to access top-level
Desktop
items on your desktop.
Dialog A Windows dialog box.
Static A static text object.
An object used to control applications and
SystemUtil
processes during a run session.
WinButton A Windows button.
WinCalendar A Windows calendar.
WinCheckBox A Windows check box.
WinComboBox A Windows combo box.
Window A standard window.
WinEdit A Windows edit box.
WinEditor A Windows multi-line editor.
WinList A Windows list.
WinListView A Windows list-view control.
WinMenu A Windows menu.
WinObject A standard (Windows) object.
WinRadioButton A Windows radio button.
WinScrollBar A Windows scroll bar.
WinSpin A Windows spin box.
WinStatusBar A Windows status bar.
WinTab A Windows tab strip in a dialog box.
WinToolbar A Windows toolbar.
WinTreeView A Windows tree-view control.
Object Description
WinTab A Windows tab strip in a dialog box.
WinTable A Stingray grid.
WinToolbar A Windows toolbar.
WinTreeView A Stingray tree control.
Object Description
A terminal emulator field that fully supports
TeField
HLLAPI.
A terminal emulator screen that fully supports
TeScreen
HLLAPI.
A terminal emulator screen that uses text-only
TeTextScreen
HLLAPI or does not support HLLAPI.
TeWindow A terminal emulator window.
Object Description
VbButton A Visual Basic button.
VbCheckBox A Visual Basic check box.
VbComboBox A Visual Basic combo box.
VbEdit A Visual Basic edit box.
VbEditor A Visual Basic multi-line editor.
VbFrame A Visual Basic frame.
VbLabel A static text object.
VbList A Visual Basic list.
VbListView A Visual Basic list-view control.
VbRadioButton A Visual Basic radio button.
VbScrollBar A Visual Basic scroll bar.
VbToolbar A Visual Basic toolbar.
VbTreeView A Visual Basic tree-view control.
VbWindow A Visual Basic window.
Object Description
WinButton A button in the VisualAge Smalltalk application.
An edit box in the VisualAge Smalltalk
WinEdit
application.
WinList A list in the VisualAge Smalltalk application.
Object Description
Browser A Web browser (or browser tab).
Frame An HTML frame.
Image An image with or without a target URL link.
Link A hypertext link.
Page An HTML page.
ViewLink A Viewlink object.
A section of an image (usually a section of a
WebArea
client-side image map).
WebButton An HTML button.
WebCheckBox A check box with an ON and OFF state.
WebEdit An edit box, usually contained inside a form.
A general Web object that can represent any
WebElement
Web object.
An edit box with a browse button attached, used
WebFile
to select a file from the File dialog box.
WebList A drop-down box or multiple selection list.
A set of radio buttons belonging to the same
WebRadioGroup
group.
A table containing a variable number of rows and
WebTable
columns.
WebXML An XML document contained in a Web page.
Object Description
An object that supports attachment-related test
Attachments
object operations.
An object that supports configuration-related test
Configuration
object operations.
B) Utility Objects
• Crypt Object
• DataTable Object
• Description Object
• DotNetFactory Object
• DTParameter Object
• DTSheet Object
• Environment Object
• Extern Object
• LocalParameter Object
• MercuryTimers Object (Collection)
• MercuryTimer Object
• Parameter Object
• PathFinder Object
• Properties Object (Collection)
• QCUtil Object
• RandomNumber Object
• Recovery Object
• Reporter Object
• RepositoriesCollection Object
• Repository Object
• Services Object
• Setting Object
• SystemMonitor Object
• TextUtil Object
• TSLTest Object
• XMLUtil Object
C) Supplemental Objects
• DbTable Object
• VirtualButton Object
• VirtualCheckBox Object
• VirtualList Object
• VirtualObject Object
• VirtualRadioButton Object
• VirtualTable Object
• XMLAttribute Object
• XMLAttributesColl Object
• XMLData Object
• XMLElement Object
• XMLElementsColl Object
• XMLFile Object
• XMLItemColl Object
VBScript Glossary
ActiveX control
An object that you place on a form to enable or enhance a user's interaction
with an application. ActiveX controls have events and can be incorporated into
other controls. The controls have an .ocx file name extension.
ActiveX object
An object that is exposed to other applications or programming tools through
Automation interfaces.
Argument
A constant, variable, or expression passed to a procedure.
Array
A set of sequentially indexed elements having the same type of data. Each
element of an array has a unique identifying index number. Changes made to
one element of an array do not affect the other elements.
Automation object
An object that is exposed to other applications or programming tools through
Automation interfaces.
Bitwise comparison
A bit-by-bit comparison of identically positioned bits in two numeric
expressions.
Boolean expression
An expression that evaluates to either True or False.
By reference
A way of passing the address, rather than the value, of an argument to a
procedure. This allows the procedure to access the actual variable. As a
result, the variable's actual value can be changed by the procedure to which it
is passed.
By value
A way of passing the value, rather than the address, of an argument to a
procedure. This allows the procedure to access a copy of the variable. As a
result, the variable's actual value can't be changed by the procedure to which
it is passed.
character code
A number that represents a particular character in a set, such as the ASCII
character set.
Class
The formal definition of an object. The class acts as the template from which
an instance of an object is created at run time. The class defines the
properties of the object and the methods used to control the object's
behavior.
Class module
A module containing the definition of a class (its property and method
definitions).
Collection
An object that contains a set of related objects. An object's position in the
collection can change whenever a change occurs in the collection; therefore,
the position of any specific object in the collection may vary.
Comment
Text added to code by a programmer that explains how the code works. In
Visual Basic Scripting Edition, a comment line generally starts with an
apostrophe ('), or you can use the keyword Rem followed by a space.
Comparison operator
A character or symbol indicating a relationship between two or more values or
expressions. These operators include less than (<), less than or equal to
(<=), greater than (>), greater than or equal to (>=), not equal (<>), and
equal (=).
Constant
A named item that retains a constant value throughout the execution of a
program. Constants can be used anywhere in your code in place of actual
values. A constant can be a string or numeric literal, another constant, or any
combination that includes arithmetic or logical operators except Is and
exponentiation. For example:
Const A = "MyString"
Data ranges
Each Variant subtype has a specific range of allowed values:
Subtype Range
Byte 0 to 255.
Date expression
Any expression that can be interpreted as a date. This includes any
combination of date literals, numbers that look like dates, strings that look
like dates, and dates returned from functions. A date expression is limited to
numbers or strings, in any combination, that can represent a date from
January 1, 100 through December 31, 9999.
Dates are stored as part of a real number. Values to the left of the decimal
represent the date; values to the right of the decimal represent the time.
Negative numbers represent dates prior to December 30, 1899.
Date literal
Any sequence of characters with a valid format that is surrounded by number
signs (#). Valid formats include the date format specified by the locale
settings for your code or the universal date format. For example, #12/31/99#
is the date literal that represents December 31, 1999, where English-U.S. is
the locale setting for your application.
Date separators
Characters used to separate the day, month, and year when date values are
formatted.
Empty
A value that indicates that no beginning value has been assigned to a
variable. Empty variables are 0 in a numeric context, or zero-length in a
string context.
Error number
A whole number in the range 0 to 65,535, inclusive, that corresponds to the
Number property of the Err object. When combined with the Name property
of the Err object, this number represents a particular error message.
Expression
A combination of keywords, operators, variables, and constants that yield a
string, number, or object. An expression can perform a calculation,
manipulate characters, or test data.
Intrinsic constant
A constant provided by an application. Because you can't disable intrinsic
constants, you can't create a user-defined constant with the same name.
Keyword
A word or symbol recognized as part of the VBScript language; for example, a
statement, function name, or operator.
Locale
The set of information that corresponds to a given language and country. A
locale affects the language of predefined programming terms and locale-
specific settings. There are two contexts where locale information is
important:
• The code locale affects the language of terms such as keywords and
defines locale-specific settings such as the decimal and list separators,
date formats, and character sorting order.
• The system locale affects the way locale-aware functionality behaves,
for example, when you display numbers or convert strings to dates.
You set the system locale using the Control Panel utilities provided by
the operating system.
Nothing
The special value that indicates that an object variable is no longer associated
with any actual object.
Null
A value indicating that a variable contains no valid data. Null is the result of:
Numeric expression
Any expression that can be evaluated as a number. Elements of the
expression can include any combination of keywords, variables, constants,
and operators that result in a number.
Object type
A type of object exposed by an application, for example, Application, File,
Range, and Sheet. Refer to the application's documentation (Microsoft Excel,
Microsoft Project, Microsoft Word, and so on) for a complete listing of
available objects.
pi
Pi is a mathematical constant equal to approximately 3.1415926535897932.
Private
Variables that are visible only to the script in which they are declared.
Procedure
A named sequence of statements executed as a unit. For example, Function
and Sub are types of procedures.
Procedure level
Describes statements located within a Function or Sub procedure.
Declarations are usually listed first, followed by assignments and other
executable code. For example:
Property
A named attribute of an object. Properties define object characteristics such
as size, color, and screen location, or the state of an object, such as enabled
or disabled.
Public
Variables declared using the Public Statement are visible to all procedures in
all modules in all applications.
Run time
The time when code is running. During run time, you can't edit the code.
Run-time error
An error that occurs when code is running. A run-time error results when a
statement attempts an invalid operation.
Scope
Defines the visibility of a variable, procedure, or object. For example, a
variable declared as Public is visible to all procedures in all modules.
Variables declared in procedures are visible only within the procedure and
lose their value between calls.
SCODE
A long integer value that is used to pass detailed information to the caller of
an interface member or API function. The status codes for OLE interfaces and
APIs are defined in FACILITY_ITF.
Script level
Any code outside a procedure is referred to as script-level code.
Seed
An initial value used to generate pseudorandom numbers. For example, the
Randomize statement creates a seed number used by the Rnd function to
create unique pseudorandom number sequences.
String comparison
A comparison of two sequences of characters. Unless specified in the function
making the comparison, all string comparisons are binary. In English, binary
comparisons are case-sensitive; text comparisons are not.
String expression
Any expression that evaluates to a sequence of contiguous characters.
Elements of a string expression can include a function that returns a string, a
string literal, a string constant, or a string variable.
Type library
A file or component within another file that contains standard descriptions of
exposed objects, properties, and methods.
Variable
A named storage location that can contain data that can be modified during
program execution. Each variable has a name that uniquely identifies it within
its level of scope.
Variable names: