UFT Tutorial 9 - Descriptive Programming

UFT Tutorial 9 - Descriptive Programming
Descriptive Programming Or Programmatic Descriptions
 

Enter / Provide Objects information (Properties and Values) directly into statements /Steps is called Descriptive programming.

Object

Button, Edit box, Link, Radio button etc...

Property

Method
---------------------------
Test Run Process in OR based Test:

During test design UFT reads steps one by one and gets Object information from Object Repository based on that info performs operations on AUT.

Test Run Process in DP based Test:

During test design UFT reads steps one by one, objects information also available in the steps based on that info performs operations on directly AUT.

Tests based on descriptive programming are faster in execution than object repository based tests.

How to get Unique Properties Information

i) Based on UFT Object Identification Configuration

ii) Trial and error
--------------------------------------
         Recorded Test        Keyword driven Methodology
-----------------------------------------------------
Steps/Statements

Internal Process
---------------------------------------------------
OR based Test Vs.    DP
----------------------------
Test Object statements vary from OR based test and DP

Test Object Statements in OR based Test and Descriptive Programming:

i) Single Test Object statement
OR based Test

Syntax:

Test Object("Object Name").Method /Operation

Example:

WpfWindow("HP MyFlight Sample Application").Close
Browser("UFT Tutorial").Close

DP

Syntax:

Test Object("Property Name:=Property Value").Method / Operation

Or

Test Object("Property1 Name:=Property1 Value","Property2 Name:=Property2 Value" ).Method / Operation

Example:

WpfWindow("devname:=HP MyFlight Sample Application").Close
Browser("CreationTime:=0").Close

Note: Latest Browser Creation time is (n-1)

Oldest Browser Creation time is zero
--------------------------------------
Two Test Objects Step/Statement
OR based Test

Syntax:

Parent Test Object("Object Name").Child Test Object("Object Name").Method /Operation

Example:

Browser("Google").Page("Gmail - Free Storage and").Sync

WpfWindow("HP MyFlight Sample Application").WpfButton("Cancel").Click

DP

Syntax:

Test Object("Property Name:=Property Value").Method /Operation

Example:
WpfWindow("devname:=HP MyFlight Sample Application").WpfEdit("devname:=agentName").Set "john"

WpfWindow("devname:=HP MyFlight Sample Application").WpfButton("devname:=Cancel").Click

------------------------------------------------------------------
Descriptive programming Examples:

i) Write Descriptive code for Login Functionality in UFT Sample Application
Const  Login= "devname:=HP MyFlight Sample Application", AgentName ="devname:=agentName"
Const Password ="devname:=password", Ok = "text:=OK"
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow(Login).WpfEdit(AgentName).Set "john"
WpfWindow(Login).WpfEdit(Password).SetSecure "56679b3a2a6d481bb197"
WpfWindow(Login).WpfButton(OK).Click

For Centralized Maintenance of Objects:
a) Replace Test objects information (property and Property value) with constants

b) Create a library file and place constants

c) Associate the Library file to UFT, Create and execute Test scripts

d) Modify the Constants (if required) in the Library file)
-------------------------
1) Test Level Association

2) Tool Level Association

We can associate multiple library files also.
------------------------
'Load a Library file at runtime
ExecuteFile "C:\Users\G C REDDY\Desktop\Objects.vbs"
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow(Login).WpfEdit(AgentName).Set "john"
WpfWindow(Login).WpfEdit(Password).SetSecure "56679b3a2a6d481bb197"
WpfWindow(Login).WpfButton(OK).Click
----------------------------------------
'Load a Library file at run-timeExecuteFile "C:\Users\G C REDDY\Desktop\Objects.vbs"
Set x = WpfWindow(Login)
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
x.WpfEdit(AgentName).Set "john"
x.WpfEdit(Password).SetSecure "56679b3a2a6d481bb197"
x.WpfButton(OK).Click
-------------------------

ii) Write Descriptive code for Admin Login Functionality in Gcrshop(www.gcrit.com/build3/admin)
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe", "http://www.gcrit.com/build3/admin/"
Browser("CreationTime:=0").Page("title:=GCR Shop").Webedit("name:=username").Set "admin"
Browser("CreationTime:=0").Page("title:=GCR Shop").Webedit("name:=password").SetSecure "5667a5518162f85e4cacb42801141a12b87c19162edf81ca"
Browser("CreationTime:=0").Page("title:=GCR Shop").WebButton("name:=Login").Click

Code Optimization:
Set myPage = Browser("CreationTime:=0").Page("title:=GCR Shop")
SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe", "http://www.gcrit.com/build3/admin/"
myPage.Webedit("name:=username").Set "admin"
myPage.Webedit("name:=password").SetSecure "5667a5518162f85e4cacb42801141a12b87c19162edf81ca"
myPage.WebButton("name:=Login").Click
----------------------------------------

No comments:

Post a Comment