UFT Tutorial 10 - Dynamic Programming, Test Methods

UFT Tutorial 10 - Dynamic Programming, Test Methods

Two types of Descriptive Programming
i) Static Programming

ii) Dynamic Programming
----------------------------

Dynamic Descriptive Programming:

Creating Description objects and generating steps using Description objects is called Dynamic programming.

Step 1: Create Description Objects
Syntax:

Set variable = Description.Create

Example:

Set Login = Description.Create
------------------------------------
Step 2: Enter properties information
Syntax:

Description Object("Property1 Name").Value ="Property1 Value"
Description Object("Property2 Name").Value ="Property2 Value"

Example:

Login("devname").value = "HP MyFlight Sample Application"
Login("height").value = 538
Login("width").value = 666
--------------------------------------
Step 3: Generate Steps using Description objects
Syntax:

Test Object(Description Object).method/Operation

Example:

WpfWindow(Login).Close
-------------------------------------------------
Write Dynamic Descriptive Programming for Login Functionality in UFT Sample Application.
'Create Description Objects
Set Login = Description.Create
Set Agent = Description.Create
Set Password = Description.Create
Set OK = Description.Create

'Enter Properties information
Login("devname").value = "HP MyFlight Sample Application"
Login("height").value = 538
Login("width").value = 666

Agent("devname").value = "agentName"
Agent("visible").Value = True
Agent("x").value = 131

Password("devname").Value = "password"
Password("y").value = 295

OK("devname").value = "okButton"
OK("name").Value = "OK"

'Generate steps using description objects
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow(Login).WpfEdit(Agent).Set "john"
WpfWindow(Login).WpfEdit(Password).SetSecure "566a34e600aabb3ed707"
WpfWindow(Login).WpfButton(OK).Click
------------------------------------------
'Load Library file at run-time.
ExecuteFile "C:\Users\G C REDDY\Desktop\Objects.vbs"
'Generate steps using description objects
SystemUtil.Run "C:\Program Files\HP\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow(Login).WpfEdit(Agent).Set "john"
WpfWindow(Login).WpfEdit(Password).SetSecure "566a34e600aabb3ed707"
WpfWindow(Login).WpfButton(OK).Click
-------------------------------------------
Assignments:

i) Write Descriptive Programming for "Customer Registration" functionality in GcrShop
Steps / Navigation
-------------------
1) Launch the Browser and navigate to http://www.gcrit.com/build3/

2) Click "create an account" link

3) Enter all mandatory fields

4) Click "Continue" Button
-------------------------------------
ii) Write Dynamic programming for "Login" functionality in GcrShop.
Steps / Navigation

1) Launch the Browser and navigate to http://www.gcrit.com/build3/

2) Click on "login" link

3) Enter "E-mailAddress"

4) Enter "Password"

5) Click "Sign in" Button
---------------------------------------
UFT Test Methods
1) Close Method
It closes an Object (Dialog box, Window, Browser window)

Syntax:

Object.Close

Example:

WpfWindow("HP MyFlight Sample Application").Close
Browser("Google").Close
---------------------------------------------
2) Click method
It clicks an Object (Buttons, Links)

Syntax:

Object.Click

Example:

Browser("Google").Page("Google").Link("Gmail").Click
WpfWindow("HP MyFlight Sample Application").WpfButton("Cancel").Click
--------------------------------------------
3) Set Method
i) Enter a value in to Edit box

Syntax:

Object.Set "value"

Example:
Browser("GCR Shop").Page("GCR Shop").WebEdit("firstname").Set "Samir"
--------------------------
ii) Check /Uncheck a Check box

Syntax:

Object.Set "ON/OFF"

Example:

Browser("GCR Shop").Page("GCR Shop").WebCheckBox("newsletter").Set "ON"
Browser("GCR Shop").Page("GCR Shop").WebCheckBox("newsletter").Set "OFF"
--------------------------------
4) SetSecure Method
It enters encoded value into Password object.

Syntax:

Object.SetSecure "Encoded value"

Example:

WpfWindow("HP MyFlight Sample Application").WpfEdit("password").SetSecure "566a3db47bdc516fe98c"
Browser("GCR Shop").Page("Gmail").WebEdit("Passwd").SetSecure "566a3de3f6f4032689e30805a000754f8b17aece1b48"
-------------------------------------------
5) Select Method
i) It selects a radio button from a Radio Group

Syntax:

Object.Select "item value"

Example:

Browser("GCR Shop").Page("GCR Shop").WebRadioGroup("gender").Select "f"

ii) It selects an item from a combo box or drop down box

Syntax:

Object.Select "item"

Or
Object.Select (index)

Example:
Browser("GCR Shop").Page("GCR Shop").WebList("country").Select "India"
Browser("GCR Shop").Page("GCR Shop").WebList("country").Select(2)
--------------------------------------
WpfWindow("HP MyFlight Sample Application").WpfComboBox("fromCity").Select (0)
WpfWindow("HP MyFlight Sample Application").WpfComboBox("toCity").Select "London"
-----------------------------------------------
Drop Down Box

Selects one item at a time.

List Box

Selects one or more items.

Combo Box
Selects an item or enters new item
---------------------------------------
6) GetVisibleText
It returns text value from an Object

Syntax:

Variable = Object.GetVisibleText

Example:

Agent = WpfWindow("HP MyFlight Sample Application").WpfEdit("agentName").GetVisibleText
Msgbox Agent
x = WpfWindow("HP MyFlight Sample Application").WpfButton("OK").GetVisibleText
Msgbox x
-----------------------------------------
7) GetROProperty method
It returns Run-time object property value

Syntax:

Variable = Object.GetRoProperty ("property name")

Example:
y = WpfWindow("HP MyFlight Sample Application").WpfButton("OK").GetROProperty("text")
Msgbox "Text Value " & y

z = WpfWindow("HP MyFlight Sample Application").WpfButton("OK").GetROProperty("enabled")
Msgbox "Enabled Value " & z

a = WpfWindow("HP MyFlight Sample Application").WpfButton("OK").GetROProperty("width")
Msgbox "Width is " & a
----------------------------------------
8) GetItemsCount
It returns items count from a combo box or list box

Syntax:

Variable = Object.GetItemsCount

Example:

itemsCount = WpfWindow("HP MyFlight Sample Application").WpfComboBox("fromCity").GetItemsCount
Msgbox itemsCount
---------------------------------
9) GetContent
It returns content from a combo box or list box

Syntax:

variable = Object.getContent

Example:

Content = WpfWindow("HP MyFlight Sample Application").WpfComboBox("fromCity").GetContent
Msgbox Content
------------------------------------------
10) GetItem
It returns an item based on item index from a list box or combo box

Syntax:
Variable = Object.getItem(item idex)

Example:
item = WpfWindow("HP MyFlight Sample Application").WpfComboBox("fromCity").GetItem(1)
Msgbox item
---------------------------------------
11) Sync (Only for web)
It waits for the browser to complete its current navigation.

Syntax:

Object.Sync

Browser("Personal Banking, Online").Page("Google").Sync
--------------------------------------
12) Navigate (Only for web)
It opens a specified url in the browser window

Syntax:

Object.Navigate "url"

Example:

Browser("Personal Banking, Online").Navigate ("www.yahoo.com")
--------------------------------------
13) CaptureBitmap method
It captures Screen shot during execution and stores in a specified location

Syntax:

Object.CaptureBitmap "path to store"

Example:
WpfWindow("HP MyFlight Sample Application").CaptureBitmap "C:\Users\G C REDDY\Desktop\Login.bmp"
-------------------------------------------

No comments:

Post a Comment