Tuesday, November 17, 2015
Working with Reporter Objects
1.1.1 Report Event Method
1.1.2 Filter Property
1.1.3 Report Path Property
Working with TextUtil Object
1.1.1
GetText Method
Returns the text from the specified window handle area.
Syntax
TextUtil.GetText(hWnd [, Left,
Top, Right, Bottom])
1.1.2
GetTextLocation Method
Checks whether a specified text string is contained in a specified
window area.
Syntax
TextUtil.GetTextLocation(TextToFind, hWnd,
Left, Top, Right, Bottom[,
MatchWholeWordOnly])
Working with the Data Table Object
1.1.1
Add Sheet Method
Adds the specified sheet to the run-time Data Table
Syntax: DataTable.AddSheet (Sheet
Name)
Example:
Variable=DataTable.AddSheet ("My
Sheet").Add Parameter ("Time", "8:00")
1.1.2
Delete Sheet Method
Deletes the specified sheet from the run-time Data Table.
Syntax: DataTable.DeleteSheet SheetID
Example: DataTable.DeleteSheet "My
Sheet“
1.1.3
Export Method
Saves a copy of the run-time Data Table
in the specified location.
Syntax: DataTable.Export (Filename)
Example: DataTable.Export ("C:\flights.xls")
1.1.4
Export Sheet Method
Exports a specified sheet of the run-time Data Table to the
specified file.
Syntax: DataTable.ExportSheet (Filename, DTSheet)
Example: DataTable.ExportSheet
"C:\name.xls" ,1
1.1.5
GetCurrentRow Method
Returns the current (active) row in
the run-time global data sheet.
1.1.6
GetRowCount Method
Returns the total number of rows in the
longest column in the global data sheet or in the specified data sheet of the
run-time Data Table.
Example:
rowcount = DataTable.GetSheet("My Sheet").GetRowCount
1.1.7
Get Sheet Method
Returns the specified sheet from the
run-time Data Table.
Example: MyParam=DataTable.GetSheet
("My Sheet").Add Parameter ("Time", "8:00")
1.1.8
GetSheetCount Method
Returns the total number of sheets in
the run-time Data Table.
1.1.9
Import Method
Imports the specified Microsoft Excel
file to the run-time Data Table.
Syntax: DataTable.Import (Filename)
Example: DataTable.Import
("C:\flights.xls")
1.1.10
Import Sheet Method
Imports a sheet of a specified file to
a specified sheet in the run-time Data Table.
Syntax:
DataTable.ImportSheet (Filename, SheetSource,
SheetDest)
Example: DataTable.ImportSheet
"C:\name.xls" ,1 ,"name"
1.1.11
SetCurrentRow Method
Sets the specified row as the current
(active) row in the run-time Data Table.
Example: DataTable.SetCurrentRow (2)
1.1.12
SetNextRow Method
Sets the row after the current (active)
row as the new current row in the run-time Data
Table.
1.1.13
SetPrevRow Method
Sets the row above the current (active)
row as the new current (active) row in the run-time
Data Table.
1.1.14
Global Sheet Property
Returns the Global sheet of the
run-time Data Table.
Example:
DataTable.GlobalSheet.AddParameter "Time", "5:45"
1.1.15
Local Sheet Property
Returns the current (active) local
sheet of the run-time Data Table.
Example: MyParam=DataTable.LocalSheet.AddParameter
("Time", "5:45")
1.1.16
Raw Value Property
Retrieves the raw value of the
cell in the specified parameter and the current row of the run-time
Data Table.
Syntax:
DataTable.RawValue ParameterID [,
SheetID]
SheetID can be the sheet name, index or
dtLocalSheet, or
dtGlobalSheet.
1.1.17
Value Property
Retrieves or sets the value of the cell
in the specified parameter and the current row of the run-time Data Table.
Syntax:DataTable.Value(ParameterID [, SheetID])
Tuesday, November 3, 2015
Working in the Expert View
1.1 VBScript Language Overview
1.1.1
VBScript Data Types
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.
Subtype
|
Description
|
Empty
|
Variant
is un initialized. 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.
|
1.1.2
VBScript Variables
1.1.2.1 Declaring Variables
You
declare variables explicitly in your script using the Dim
statement, the Public statement, and the Private statement.
Variables
declared with Dim at the script level are available to all procedures within
the script. At the procedure level, variables are available only within the
procedure.
Public
statement variables are available to all procedures in all scripts.
Private
statement variables are available only to the script in which they are
declared.
1.1.2.2 Variable Naming
Restrictions
Variable names follow the standard rules for naming anything in
VBScript. A variable name:
Must begin with an alphabetic character.
Cannot contain an embedded period.
Must not exceed 255 characters.
Must be unique in the scope in which it is declared.
1.1.2.3 Scope and Lifetime of Variables
A
variable's scope is determined by where you declare it. When you declare a
variable within a procedure, only code within that procedure can access or
change the value of that variable. It has local scope and is a procedure-level
variable. If you declare a variable outside a procedure, you make it
recognizable to all the procedures in your script. This is a script-level
variable, and it has script-level scope.
The
lifetime of a variable depends on how long it exists. 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. When the procedure exits, the variable is
destroyed. Local variables are ideal as temporary storage space when a
procedure is executing. You can have local variables of the same name in
several different procedures because each is recognized only by the procedure
in which it is declared.
1.1.3
VBScript Constants
You
create user-defined constants in VBScript using the Const
statement. Using the Const statement, you can create string or numeric
constants with meaningful names and assign them literal values. For example:
Const
MyString = "This is my string."
Const
MyAge = 49
1.1.4
VBScript Operators
1.1.4.1 Arithmetic Operators
Description
|
Symbol
|
Exponentiation
|
^
|
Unary
negation
|
-
|
Multiplication
|
*
|
Division
|
/
|
Integer
division
|
\
|
Modulus
arithmetic
|
Mod
|
Addition
|
+
|
Subtraction
|
-
|
String
concatenation
|
&
|
1.1.4.2 Comparison Operators
Description
|
Symbol
|
Equality
|
=
|
Inequality
|
<>
|
Less
than
|
<
|
Greater
than
|
>
|
Less
than or equal to
|
<=
|
Greater
than or equal to
|
>=
|
Object
equivalence
|
Is
|
1.1.4.3 Logical Operators
Description
|
Symbol
|
Logical
negation
|
Not
|
Logical
conjunction
|
And
|
Logical
disjunction
|
Or
|
Logical
exclusion
|
Xor
|
Logical
equivalence
|
Eqv
|
Logical
implication
|
Imp
|
1.1.5
Using Conditional Statements
The
following conditional statements are available in VBScript:
1.1.5.1 If...Then...Else statement.
Example:
If value
= 0 Then
AlertLabel.ForeColor = vbRed
Else
AlertLabel.Forecolor
= vbBlack
End If
1.1.5.2 Select Case statement.
Example:
Select
Case strMyText
Case "MasterCard"
DisplayMCLogo
ValidateMCAccount
Case
"Visa"
DisplayVisaLogo
ValidateVisaAccount
Case Else
DisplayUnknownImage
PromptAgain
End
Select
1.1.6
Looping Through Code
The
following looping statements are available in VBScript:
1.1.6.1 Do...Loop:
Loops
while or until a condition is True.
Repeats
a block of statements while a condition is true or until a condition becomes
True.
Do
[{While | until} condition]
[Statements]
[Exit
Do]
[Statements]
Or, you
can use this syntax:
Do
[Statements]
[Exit
Do]
[statements]
Loop
[{While | until} condition]
1.1.6.2 While...Wend:
Loops
while a condition is True.
Executes
a series of statements as long as a given condition is True.
While condition
Version
[statements]
Wend
1.1.6.3 For...Next:
Uses a
counter to run statements a specified number of times.
Repeats
a group of statements a specified number of times.
For
counter = start To end [Step step]
[Statements]
[Exit
For]
[Statements]
Next
For
Each...Next: Repeats a group of statements for each item in a collection or
each element of an array.
Repeats
a group of statements for each element in an array or collection.
For Each
element In group
[Statements]
[Exit
For]
[Statements]
Next
[element]
1.1.7
VBScript Procedures
1.1.7.1 Sub Procedures
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.
Example:
Sub
ConvertTemp()
temp = InputBox("Please enter the
temperature in degrees F.", 1)
msgbox ()"The temperature is "
& Celsius(temp) & " degrees C."
End Sub
1.1.7.2 Function Procedures
A
Function procedure is a series of VB Script statements enclosed by the Function
and End Function statements.
Example:
Function
Celsius(fDegrees)
Celsius = (fDegrees - 32) * 5 / 9
End
Function
The easiest way to create a test is to begin by recording typical business
processes that you perform on your application or Web site. Then, to increase
your test’s power and flexibility, you can add programming statements to the
recorded framework. Programming statements can contain:
- Recordable test
object methods: operations that a user can perform on an application or
Web site.
- Non-recordable test
object methods: operations that users cannot perform on an application or
Web site. You use these methods to retrieve or set information, or to
perform operations triggered by an event.
- Run-time
methods of the object being tested.
- Various
VBScript programming commands that affect the way the test runs, such as
conditions and loops. These are often used to control the logical flow of
a test.
- supplemental
statements, such as comments, to make your test easier to read, and
messages that appear in the test results, to alert you to a specified
condition
Note: Test object
methods are defined in Quick Test; run-time
methods are defined within the object you are testing, and therefore are
retrieved from them.
You can incorporate decision-making into your test and define messages for
the test results by using the appropriate dialog boxes.
In addition, you can improve the readability of
your test using With statements. You can instruct Quick Test to
automatically generate With statements as you record. But even after
your basic test is recorded, you can convert its statements, in the Expert
View, to With statements—by selecting a menu command.Introduction to the Expert View
1.1 Object Model in the Expert View
The Expert View provides an alternative to the Tree View for testers who
are familiar with VBScript. In the Expert View, you can view the recorded test
in VBScript and enhance it with programming.
The Expert View displays the steps you executed while recording your test
in VBScript. After you record your test, you can increase its power and
flexibility by adding recordable and non-recordable VBScript statements. You
can add statements that perform operations on objects or retrieve information
from your site. For example, you can add a step that checks that an object
exists, or you can retrieve the return value of a method.
The objects in Quick Test are divided by environment. Quick Test environments
include standard Windows objects, Visual Basic objects, ActiveX objects, Web
objects, Multimedia objects, as well as objects from other environments
available as external add-ins.
Most objects have corresponding methods. For example, the Back
method is associated with the Browser object.
In the following example, the user enters mercury in the User Name edit box
while recording. The following line is recorded in the Expert View:
Browser ("Mercury_Tours"). Page
("Mercury_Tours"). WebEdit ("username").Set
"mercury"
When running the test, the Set method inserts the mercury text into
the WebEdit object.
In the following example, the user selects Paris from the Departure City
list box while recording. The following line is recorded in the Expert View:
Browser("Mercury Tours").Page("Find
Flights").WebList("depart").Select
"Paris "
When the test runs, the Select method selects Paris in the WebList object.
1.2 Using Quick Test Professional’s online books
Quick Test Professional documentation helps
you take full advantage of he capabilities of this powerful, easy-to-use,
testing tool.
·
Quick Test Professional User’s Guide—provides step-by-step instructions on
how to use Quick Test to test your applications. It describes many useful
features, options, and testing procedures with guidelines and helpful examples.
·
Quick Test Professional Installation Guide—explains how to install Quick
Test Professional.
·
Quick Test Professional Tutorial—teaches you basic Quick Test skills and
shows you how to start testing your applications.
·
Quick Test Professional Object Model Reference—provides access to the Quick
Test Professional VBScript methods, including a description of each object, a
list of the methods associated with each object, description syntax, and an example
of usage for each object and method.
·
Quick Test Professional Shortcut Key Reference Card—provides a list of
commands that you can execute using shortcut keys.
·
Quick Test Professional Automation Object Model Reference
— (available from the Quick Test Professional
Start menu program folder and from the Quick Test Professional Help
menu) provides syntax, descriptive information, and examples for the automation
objects, methods, and properties. It also contains a detailed overview to help
you get started writing Quick Test automation scripts.
Subscribe to:
Posts (Atom)