UFT Tutorial 11 - Enhancing Tests Part-1

UFT Tutorial 11 - Enhancing Tests Part-1

1) Overview of Test Automation

2) UFT Test Process

3) VBScript for UFT

4) UFT Test Process
    Generating basic Tests
        Record and Run Tests
        Pre-requisites to create Tests
        Types of Objects in UFT
        Object Repository
        Keyword driven methodology
        Types of steps in UFT Test
        Descriptive Programming
        UFT Test Methods
---------------------------------
Enhancing Tests
----------------
Inserting Transaction points (Start and End)
-----------------------------

Using Transaction points we can measure Test Transaction time.

We can measure entire Test transaction time as well as partial test transaction time.

Services Utility object for inserting transaction points.

Syntax:

Services.StartTransaction "Transaction Name"
Steps
----------
----------
--------
Servies.EndTransaction "Transaction Name"

Example:
                                                                                                                                                   
Services.StartTransaction "abcd"
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe","","C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\",""
WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").Set "john"
WpfWindow("HP MyFlight Sample Application").WpfEdit("password").SetSecure "566b834a207a21d896da"
WpfWindow("HP MyFlight Sample Application").WpfButton("OK").Click
Services.StartTransaction "Insert Order"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("fromCity").Select "Denver"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("toCity").Select "Frankfurt"
WpfWindow("HP MyFlight Sample Application").WpfImage("WpfImage_3").Click 7,8
WpfWindow("HP MyFlight Sample Application").WpfCalendar("Su").SetDate "14-Dec-2015"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("Class").Select "Business"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("numOfTickets").Select "3"
WpfWindow("HP MyFlight Sample Application").WpfButton("FIND FLIGHTS").Click
WpfWindow("HP MyFlight Sample Application").WpfTable("flightsDataGrid").SelectCell 3,0
WpfWindow("HP MyFlight Sample Application").Move 59,25
WpfWindow("HP MyFlight Sample Application").WpfButton("SELECT FLIGHT").Click
WpfWindow("HP MyFlight Sample Application").WpfEdit("passengerName").Set "abcd"
WpfWindow("HP MyFlight Sample Application").WpfButton("ORDER").Click
WpfWindow("HP MyFlight Sample Application").Close
Services.EndTransaction "Insert Order"
Services.EndTransaction "abcd"
--------------------------------------------
Functional Test Result Analysis        Vs. Performance Test Result Analysis
----------------------------------------------------------------------------
Input: 3, 5                Login Functionality for 1000 concurrent users within 3 seconds
Addition Operation
Expected = 8                Factors to consider for Performance Testing
Actual =                AUT
                    Server response
                    Network Communicators etc...
-------------------------------------------------------------
VBScript built-in Function - Timer

It returns time in seconds that have elapsed since 12:00 AM Midnight based on local system time.

Usage:                   
---------
Variable1 = Timer (3600)
Statements/Steps
----------------
---------------
------------
Variable2 = Timer (3618)
Msgbox Variable2 - Variable1 (18)
-------------------------------------
Example:

Start_Transaction = Timer
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").Set "john"
WpfWindow("HP MyFlight Sample Application").WpfEdit("password").SetSecure "566b834a207a21d896da"
WpfWindow("HP MyFlight Sample Application").WpfButton("OK").Click
WpfWindow("HP MyFlight Sample Application").WpfComboBox("fromCity").Select "Denver"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("toCity").Select "Frankfurt"
WpfWindow("HP MyFlight Sample Application").WpfImage("WpfImage_3").Click 7,8
WpfWindow("HP MyFlight Sample Application").WpfCalendar("Su").SetDate "14-Dec-2015"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("Class").Select "Business"
WpfWindow("HP MyFlight Sample Application").WpfComboBox("numOfTickets").Select "3"
WpfWindow("HP MyFlight Sample Application").WpfButton("FIND FLIGHTS").Click
WpfWindow("HP MyFlight Sample Application").WpfTable("flightsDataGrid").SelectCell 3,0
WpfWindow("HP MyFlight Sample Application").Move 59,25
WpfWindow("HP MyFlight Sample Application").WpfButton("SELECT FLIGHT").Click
WpfWindow("HP MyFlight Sample Application").WpfEdit("passengerName").Set "abcd"
WpfWindow("HP MyFlight Sample Application").WpfButton("ORDER").Click
WpfWindow("HP MyFlight Sample Application").Close
End_Transaction =Timer
Transaction_Time = End_Transaction - Start_Transaction
Msgbox Transaction_Time
Reporter.ReportEvent 2, "Res1", "Transaction Time is: " & Transaction_Time
---------------------------------
Define Test Result:
-------------------
> UFT provides Test Result for every test iteration if we use UFT tool features (checkpoints, Output values, Transaction points etc...)

> If we use our own logic (VBScript features) then we need to define Test result.

How TO Define Test result?

Using Reporter Utility object.

Example:

Reporter.ReportEvent 2, "Res1", "Transaction Time is: " & Transaction_Time

Reporter - It is an Utility Object

ReportEvent -Method / Operation

2 - Result Status

    Either 0 or micPass for Pass Status
    Either 1 or micFail for Fail Status
    Either 2 or micDone for Done Status
    Either 3 or micWarning for Warning Status

"Res1" -Result Step Name

"Transaction Time is: " - Details

& -concatenation Operator

Transaction_Time - It is a Variable
-------------------------------------------
Parameterization
----------------
What is Parameterization?

Replacing constant (Fixed) values using parameters is called Parameterization.

Purpose of Parameterization
    To pass single value
    To pass multiple values

What is Data driven Testing?

Testing the same functionality using multiple sets of Test data.

Why Data driven Testing?

Positive and Negative Testing.

Relation between Parameterization and Data Driven Testing?

We use Parameterization feature in Data Driven Testing.

For Data driven testing we pass multiple values only.

Either Passing single value or passing multiple values is called Parameterization.

How to Parameterize?

We can use either variables or Constants or Function Arguments or Environment variables or Data Table parameters or Action parameters or Dictionary keys as Parameters.

Ways of Parameterization
-----------------------------
i) Dynamic submission of Test data:

For i = 1 To 3 Step 1
Agent = InputBox("Enter Agent Name")
Password =InputBox("Password")
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe","","C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\",""
WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").Set Agent
WpfWindow("HP MyFlight Sample Application").WpfEdit("password").Set Password
Wait 2
WpfWindow("HP MyFlight Sample Application").WpfButton("OK").Click
WpfWindow("HP MyFlight Sample Application").Close
Next
-------------------------
Note: To enter Captcha fileds we use this method (Dynamic submission of Test Data)

ii) Using Data Table

Usage of Data Table
a) Enter Test Data directly into Data table and connect to the Test
b) Import Test Data from an external file (Text/Excel) and connect to the Test
c) Import Test Data from a Database and connect to the Test

Steps for Data Driven Testing using Data Table:
------------------------------------------------
i) Generate the basic test and run it once.

ii) Insert steps for Error handling.

iii) Launch Data Table and enter or import test data

iv) Connect Test data to the Test.
    Using Editor View
    Or
    Using Keyword view
    Or
    Using Data driver
v) Run the Test
-------------------------------
Connect Test Data using editor view:

DataTable(Column name or Column Id, Sheet name or Sheet id)

Example:
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").Set DataTable("Agent", dtGlobalSheet)
WpfWindow("HP MyFlight Sample Application").WpfEdit("password").Set DataTable("Pasword", dtGlobalSheet)
wait 2
WpfWindow("HP MyFlight Sample Application").WpfButton("OK").Click
WpfWindow("HP MyFlight Sample Application").Close
----------------------------------------------------

No comments:

Post a Comment