Tuesday, November 17, 2015

Working with Reporter Objects

1.1.1        Report Event Method

Reports an event to the Test Report.
Syntax
Reporter.ReportEvent Event Status, ReportStepName, Details [, in]
Event Status – micPass, micFail, micDone, micWarning

1.1.2        Filter Property

Retrieves or sets the current mode for displaying events in the Test Results.
Syntax
To retrieve mode setting: Current Mode = Reporter. Filter
To set the mode: Reporter. Filter = New Mode
Mode - 0 or rfEnableAll, 1 or rfEnableErrorsAndWarnings,
2 or rfEnableErrorsOnly, 3 or rfDisableAll

1.1.3        Report Path Property

Retrieves the folder path in which the current test’s Test Results are stored.
Syntax Path = Reporter.ReportPath

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]
Loop
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.

Monday, September 7, 2015

Alternatives to Standard Recording


1.1 Analog Recording

                1.1.1 Analog Recording

Enables you to record the exact mouse and keyboard operations you perform in relation to either the screen or the application window.

In this recording mode, Quick Test records and tracks every movement of the mouse as you drag the mouse around a screen or window.

This mode is useful for recording operations that cannot be recorded at the level of an object, for example, recording a signature produced by dragging the mouse.

                1.1.2 Recording in Analog Mode





  • Click the Record buttonto begin recording.
  • Click the Analog Recording buttonor choose Test > Analog Recording. The Analog Recording Settings dialog box opens.

  • Select from the following options:
Record relative to the screen—records mouse movement or keyboard input relative to the coordinates of your screen, regardless of which application(s) are open.

Record relative to the following window—Quick Test records any mouse movement or keyboard input relative to the co-ordinates of the specified window.

  • If you choose to Record relative to the following window, click the pointing hand and click anywhere in the window on which you want to record in analog mode.

  • Click Start Analog Record. Perform the operations you want to record in analog mode.

  • When you are finished and want to return to normal recording mode, click the Analog Recording button or choose Test > Analog Recording to turn off the option.

Notes:
When you record in analog mode relative to the screen, the test run will fail if your screen resolution or the screen location on which you recorded your analog steps has changed from the time you recorded.
All of your keyboard input, mouse movements, and clicks are recorded and saved in an external file. When Quick Test runs the test, the external data file is called. It tracks every movement and click of the mouse to replicate exactly the operations you recorded.

If you chose to Record relative to the screen, Quick Test inserts the RunAnalog step under a Desktop parent item.
For example: Desktop.RunAnalog "Track9"

If you chose to Record relative to the following window, Quick Test inserts the RunAnalog step under a Window parent item. For example:
Window("Microsoft Internet").RunAnalog "Track8"

The track file called by the RunAnalog method contains all your analog data and is stored with the action.

Tip: To stop an analog step in the middle of a test run, click Ctrl + Esc, then click Stop in the test toolbar.

1.2 Low-Level Recording


Enables you to record on any object in your application whether or not Quick Test recognizes the specific object or the specific operation.

This mode records at the object level and records all run-time objects as Window or WinObject test objects.

Use low-level recording for recording tests in an environment or on an object not recognized by Quick Test or if the exact coordinates of the object are important for your test

                1.2.1 Recording in Low-Level mode

 

  • Click the Record buttonto begin a recording session.

 

  • Click the Low Level Recording buttonor choose Test > Low Level Recording.

  • When you are finished and want to return to normal recording mode, click the Low Level Recording button or choose Test > Low Level Recording to turn off the option.
Notes:
In low-level recording and your entire keyboard input and mouse clicks are recorded based on mouse coordinates. When test is run, the cursor retraces the recorded clicks.
Suppose you type the word mercury into a user name edit box and then click the Tab key while in normal recording mode. Your script are displayed as follows:

Browser("Mercury Tours").Page("Mercury Tours") .WebEdit("username").Set "mercury"
If you perform the same action while in low-level recording mode, the script is recorded as follows

Window("Microsoft Internet").WinObject("Internet Explorer_Se").Click 29,297
Window("Microsoft Internet").WinObject("Internet Explorer_Se").Type "mercury" + micTab

1.3 Configuring Web Event Recording

The Web Event Recording Configuration dialog box offers   three standard event-configuration levels.
By default, Quick Test uses the Basic recording -configuration level.
If Quick Test does not record all the events you need, you may require a higher event-configuration level.

Level

Description

 Basic
( Default )


•Always records click events on standard Web objects such as images, buttons, and radio buttons.
•Always records the submit event within forms.
•Records click events on other objects with a handler or behavior connected.
Records the mouse over event on images and image maps only if the event following the mouse over is performed on the same object and is dependent on the mouse over event.
Medium
Records click events on the <DIV>, <SPAN>, and <TD> HTML tag objects, in addition to the objects recorded in the basic level.
 High

Records mouse over, mouse down, and double-click events on objects with handlers or behaviors attached, in addition to the objects recorded in the basic level.

                1.3.1 To set Web Event Recording Configuration:


  • Choose Tools > Web Event Recording Configuration.
The Web Event Recording Configuration dialog box opens. Use the slider to select your preferred standard event-recording configuration.

·         Click OK.

1.4 Define a Virtual Object

You can teach Quick Test to recognize any area of your application as an object by defining it as a virtual object.
Virtual objects enable you to record and run tests on objects that are not normally recognized by Quick Test.
Using the Virtual Object Wizard, you can map a virtual object to a standard object class, specify the boundaries and the parent of the virtual object, and assign it a logical name.

                1.4.1 To define a virtual object:

·         With Quick Test open (but not in record mode), open your Web site or application and display the object containing the area you want to define as a virtual object.

·         In Quick Test, choose Tools > Virtual Objects > New Virtual Object. The Virtual Object Wizard opens. Click Next.

  • Select a standard class to which you want to map your virtual object.

  • Click Mark Object.
The Quick Test window and the Virtual Object Wizard are minimized. Use the crosshairs pointer to mark the area of the virtual object. You can use the arrow keys while holding down the left mouse button to make precise adjustments to the area you define with the crosshairs. Click Next.

  • Click an object in the object tree to assign it as the parent of the virtual object.

  • In the Identify object-using box, select how you want Quick Test to identify and map the virtual object.

If you want Quick Test to identify all occurrences of the virtual object, select parent only. Quick Test identifies the virtual object using its direct parent only, regardless of the entire parent hierarchy.

If you want Quick Test to identify the virtual object in one occurrence only, select entire parent hierarchy. Quick Test identifies the virtual object only if it has the exact parent hierarchy. Click Next.

  • Specify a name and a collection for the virtual object. Choose from the list of collections or create a new one by entering a new name in the Collection name box.

  • To add the virtual object to the Virtual Object Manager and close the wizard, select No and then click Finish.


Wednesday, August 26, 2015

Capture and Reuse Run Time data

Adding a Standard Output Value

You can create a standard output value from an object property value. When you run the test, Quick Test retrieves the current value of the property and enters it in the run-time Data Table as an output value.
To create a standard output value while recording:
  • Choose Insert > Output Value > Standard Output Value.
The mouse pointer turns into a pointing hand.
  • Click the object in your application.
If the location you clicked is associated with more than one object, the Select an Object dialog box opens.
  • Select the object for which you want to specify an output value.
  • Click OK.
The Output Value Properties dialog box opens.
  • Specify the settings for the output value.
  • Click OK to close the Output Value Properties dialog box.
  • An output value step is added to your test tree.

  Creating Image Output Values

You can create an image output value from the property value of a Web image. When you run the test, Quick Test retrieves the current value of the property and enters it in the run-time Data Table as an output value.
To create an image output value while recording:
  • Choose Insert > Output Value > Standard Output Value .
The mouse pointer turns into a pointing hand.
  • Click the image.
  • If the location you clicked is associated with more than one object, the Select an Object dialog box opens.
  • Select the Image item you want to specify for an output value.
  • Click OK.
The Image Output Value Properties dialog box opens.
  • Specify the settings for the output value.
  • Click OK to close the Image Output Value Properties dialog box.
  • An output value step is added to your test.

Creating Table Output Values

You can create a table output value from the contents of a table cell. When you run the test, Quick Test retrieves the current value of a table cell and enters it in the run-time Data Table as an output value.

To create a table output value while recording:
  • Choose Insert > Output Value > Standard Output Value. The mouse pointer turns into a pointing hand.
  • Click the table. If the location you clicked is associated with more than one object, the Select an Object dialog box opens.
    Select a Table item and click OK.
  • The Output Value Properties dialog box opens.
  • Specify the settings for the output value.
  • Click OK to close the Output Value Properties dialog box.
  • An output value step is added to your test tree.

Example: Consider the following problem for flight reservation application:
Create a new reservation and verify the reservation details.
Hint: you need order number to verify the reservation details.

Steps to solve the problem:
1. Create two actions à Create New Order and Open Order.
2. Create an output value for the order number field in Create New Order Action.
3. Parameterize Order Number in Open Order Action.