Untitled Document
Untitled Document
Key Features:
UFT vs Selenium
App Support Web, Desktop, SAP, Java, etc. Web applications only
UFT is best for enterprises needing full test lifecycle support for desktop, legacy, and complex apps. Selenium is better for web
automation, especially when cost or language flexibility is a concern.
UFT Architecture
3. Test Interface
GUI with Keyword View and Expert View
Data Table and Debugging tools
4. Add-in Layer
Plug-ins for specific technologies (Web, Java, SAP, .NET, etc.)
Must be selected at UFT launch
5. Integration Layer
Connects with ALM, Jenkins, test management, CI/CD tools.
UFT Add-ins
Add-in Purpose
Panes in UFT
● Test Pane: Where your test is built (main workspace
● Object Repository Pane: Lists all objects used in the test
● Data Table Pane: Holds test data (similar to Excel)
● Debug Viewer Pane: Helps during test debugging
● Output Pane: Shows results of print/log commands
● Active Screen Pane: Snapshot of the app for reference
Expert View -
● Shows the VBScript code behind each step
● Gives full control over logic, loops, and error handling.
● You can switch between the two views.
Browser("Gmail").Navigate "https://gmail.com".
Action Pane
Organizes the test into Actions
Each action is like a mini-test with its own steps and logic
You can create:
● Reusable Actions (called in multiple tests)
● Non-reusable Actions (used only once)
Helps structure large tests into logical parts (e.g., Login, Search, Logout)
Data Table
Embedded spreadsheet (like Excel)
Used for data-driven testing
Has two types:
● Global Sheet: Shared by all actions
● Local Sheet: Specific to one action
You can use parameters like DataTable("Username", dtGlobalSheet)
✅ Playback: Run the test, and UFT will automatically enter credentials and click login.
2. Analog Recording
Use Case: Capture mouse movements & drawing actions (e.g., signing on a digital pad).
Steps:
Select Record → Analog Recording.
Choose Record relative to screen or window.
Perform drawing or signature on the application.
Stop recording.
Auto-Generated UFT Code
Additional Steps:
1. UFT uses an Object Repository to store the objects it interacts with during recording.
2. Active Screen: UFT takes a snapshot of each step so you can insert more steps later.
3. You can edit or delete recorded steps as needed.
4. Recording is great for beginners, but descriptive programming and modular scripting are better for long-term
automation.
Keyword View:
WebButton("Next") Click
Types of Repositories:
Local Object Repository: Specific to one test, stored within the test script. Automatically created for each action. Stored
inside the test. Simple and automatic
Shared Object Repository: Can be reused across multiple tests (stored as .tsr files). Better for large projects, reusable, easy
to maintain
Object Spy: A tool used to inspect object properties and methods.
Local Object Repository (LOR) Stores objects only for a specific test When objects are unique to a test case
Shared Object Repository (SOR) A common object repository that can be used in When multiple test cases need to interact with
multiple tests the same objects
Step 1: Open the Object Repository
Open UFT One.
Go to Resources → Object Repository (Shortcut: Ctrl + R).
Here, you can see all objects stored for your test.
You can add objects manually or by recording. Using Normal Recording (Automatically Captures Objects)
Using Object Spy (Manually Add Objects). Object Spy allows you to inspect object properties & methods.
Steps to Use Object Spy
1. Open UFT and click Tools → Object Spy (Shortcut: Alt + F12).
2. Click the "Hand Icon" (Drag & Drop) over the object.
3. UFT will display object properties like:
○ Name (e.g., "LoginButton")
○ Class (e.g., "WebButton")
○ Properties (e.g., html id, inner text, xpath)
4. Click "Add to Repository" to store it.
5. ✅
Example: Inspecting a Login Button
Browser("title:=Login Page").Page("title:=Login Page").WebButton("name:=Login").Click
Task Steps
View Object Repository Ctrl + R
Add Objects Manually Object Spy (Alt + F12) → Click "Add to Repository"
Scope Only for a specific test Can be used across multiple tests
Editing Can be modified within the test Needs Object Repository Manager
3. Action Mode:
An Action in UFT is like a mini-test or a block of steps that performs a specific task
Purpose: Breaks test scripts into smaller, reusable units for modular scripting.
Types of Actions:
Reusable Action: Can be called multiple times within or across tests.
Non-Reusable Action: Used only within the test where it is created.
External Action: Reusable actions stored in other test scripts.
Browser("title:=Example").Page("title:=Login").WebEdit("name:=username").Set "testuser"
Browser("title:=Example").Page("title:=Login").WebEdit("name:=password").SetSecure "password123"
Browser("title:=Example").Page("title:=Login").WebButton("name:=Login").Click
Reusability Yes, across multiple tests No, only in the same test Yes, from another test
Use Case Login, Navigation, Common Workflows One-time test steps Shared Test Actions
Output Sends data from the action back E.g., result from a DB query
Steps to Add Parameters:
Open the action
Go to Edit → Action → Action Properties
Click on the Parameters tab
Add Input or Output parameters
1. Record or manually add the step where UFT clicks the login button.
2. In UFT, go to Design → Checkpoint → Standard Checkpoint.
3. Click the Login button in the application.
4. Select the "Text" property and set the expected value as "Login".
5. UFT inserts this checkpoint into the script.
6. Browser("title:=Login Page").Page("title:=Login Page").WebButton("name:=Login").Check CheckPoint("Login")
7. UFT will compare the actual button text with "Login" and report if they match.
Text Checkpoint: Validates static text on the application. (headings, labels, etc.).
Verify Error Message on Login Failure
Try logging in with incorrect credentials.
Go to Design → Checkpoint → Text Checkpoint.
Click on the error message displayed.
Set the expected value as "Invalid username or password".
UFT will insert the checkpoint.
Browser("title:=Login Page").Page("title:=Login Page").Check CheckPoint("Invalid Login Message")
If the error message matches "Invalid username or password", the test passes; otherwise, it fails.
Standard Checkpoint Verifies object properties (text, value, visibility, etc.) Checking button label or text in a field
Text Checkpoint Validates static text displayed on the application Checking error messages or page headings
Welcome John" appears within a certain
Text Area Similar to Text, but checks text in a specific area screen zone
Bitmap Checkpoint Compares screenshots (pixel by pixel) Verifying UI layout, images, and logos
Database Checkpoint Verifies database values by querying Checking if a user record is created in the
tables database
XML Checkpoint Validates XML content (structure & values) Checking API response XML files
Best Practices
Use Checkpoints to validate only critical features (avoid overuse)
Use Descriptive Programming for flexible checking
For dynamic content, use regular expressions or custom checks
Use Database Checkpoints to ensure backend data is correct
5. Parameterization Module
Purpose: Enables running test cases with multiple data sets (data-driven testing). Parameterization allows running a single
test script with multiple sets of data, eliminating the need for hardcoded values. This is crucial for data-driven testing where
the test needs to be executed multiple times with different inputs.
Methods of Parameterization:
Data Table Uses built-in Excel-like Data Table for parameterization Testing login with multiple usernames & passwords
Environment Variables Uses global/system variables to store values Storing URLs, credentials, or global settings
Random Number Generation Generates dynamic numbers during test execution Creating unique order IDs, random usernames
Database Connectivity Fetches test data from SQL, Oracle, etc. Validating data-driven workflows
Database Connectivity (Fetching data from DBs like SQL, Oracle, etc.)
Fetch User Credentials from SQL Database. Instead of using Excel, you can directly fetch test data from a database.
Steps to Use Database Parameterization
Connect UFT to the database.
Run a SQL query to fetch test data.
Store the result in a variable and use it in the script. UFT will fetch active users from the database, log them in one by one,
and test the login process.
rs.MoveNext
Loop
6. Synchronization Module
Purpose: Ensures the test execution waits for the application to be ready before performing actions. When automating tests,
sometimes UFT executes steps faster than the application responds, causing test failures. Synchronization ensures that
UFT waits until the application is ready before performing actions.
Methods of Synchronization:
1. Wait Statement: Wait (seconds) – Pauses execution for a fixed time.
Wait(5) ' Pauses the script for 5 seconds
Drawback: Not efficient—wastes time if the application loads faster.
2. Sync Method: Waits for the application to load (used for web apps). UFT waits until the browser has fully loaded
before clicking the Login button. Works only for web-based applications.
' Open browser
SystemUtil.Run "iexplore.exe", "http://example.com"
' Wait until the page loads completely
Browser("Example").Sync
' Now perform an action
Browser("Example").Page("Example Page").WebButton("Login").Click
Wait Statement Pauses execution for a fixed time When an application always takes a specific time to load
Sync Method Waits until the browser is completely loaded Used for web applications
Exist Method Waits for an object to appear before interacting with it When elements take variable time to load
Implicit (Smart) Wait Configures default wait time for object recognition When objects load at different speeds
Recovery Scenarios
A Recovery Scenario is a way to tell UFT what to do when unexpected events or errors occur during test execution. Think of it
as a safety net to keep your test from failing unexpectedly like:
● Application crashes
● Unexpected pop ups
● Missing windows
● Object not found errors
A Recovery Scenario is made up of 4 parts:
Step Description
Trigger Event What event/error should UFT detect? (e.g., popup, crash)
Recovery Operation What should UFT do to recover? (e.g., close popup, restart app)
Post-Recovery Test Run Option What to do after recovery? (repeat, next step, stop)
Name & Save Save and reuse across tests
Step Value
Trigger Popup Window: "Login Error"
Operation Click OK button
Post-Recovery Continue with next step
If-Else Condition
Dim score
score = 75
If score >= 50 Then
MsgBox "Pass"
Else
MsgBox "Fail"
End If
If score is 50 or above, it displays "Pass"; otherwise, "Fail"
While Loop
Dim count
count = 1
Do-While Loop
Dim num
num = 1
Dim result
result = AddNumbers(10, 20)
MsgBox "Sum: " & result ‘Displays "Sum: 30".
Reading from a File - Reads and displays "Hello, this is UFT automation!".
Dim fso, file, content
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("C:\testfile.txt", 1)
content = file.ReadAll
file.Close
MsgBox "File Content: " & content
Regular Expressions (RegExp) for dynamic object handling. Used for pattern matching.
Validate Email Using Regex. If email = "[email protected]", it displays "Valid Email".
Dim regex, email
Set regex = New RegExp
regex.Pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$"
regex.IgnoreCase = True
regex.Global = True
email = "[email protected]"
If regex.Test(email) Then
MsgBox "Valid Email"
Else
MsgBox "Invalid Email"
End If
Arrays and Dictionaries in UFT (VBScript)
2. Dictionaries in VBScript - A Dictionary is like a key-value pair store (similar to a Map or Hashtable).
Create a Dictionary:
Set dict = CreateObject("Scripting.Dictionary")
dict.Add "Name", "John"
dict.Add "Age", 30
Access or Modify:
MsgBox dict.Item("Name") ' Outputs: John
dict.Item("Age") = 31 ' Update value
Remove Items:
dict.Remove "Age"
Loop Through Dictionary:
For Each key In dict.Keys
MsgBox key & ": " & dict.Item(key)
Next
Working with Files and Folders in UFT (VBScript) to read/write files and manage folders.
2. Delete Folder:
fso.DeleteFolder "C:\Test\Results", True
3. List Files in a Folder:
Set folder = fso.GetFolder("C:\Test")
For Each file In folder.Files
MsgBox file.Name
Next
Arrays:
● Store multiple values
● Use UBound to loop through
● Use ReDim Preserve to resize
Dictionaries:
● Key-value pairs
● Great for structured data (e.g., login info)
File/Folder Operations:
● Use FileSystemObject
● Create, read, write files
● Create/delete folders
● Loop through files and folders
Purpose: Allows object identification without using the Object Repository. This makes scripts more dynamic and flexible.
(DP) lets you bypass the Object Repository and identify objects directly in your script using their properties.
Identifying a Web Button Dynamically. - Finds Google Search button dynamically and clicks it.
Dim objDesc
Set objDesc = Description.Create
' Define object properties dynamically
objDesc("micclass").Value = "WebButton"
objDesc("html tag").Value = "INPUT"
objDesc("name").Value = "Google Search"
' Click the button dynamically
Browser("title:=Google").Page("title:=Google").WebButton(objDesc).Click
Advanced Example
Get All Links on a Page Dynamically. Retrieves all links on the Google page and displays their names.
Dim objDesc, links, i
' Define description for all links
Set objDesc = Description.Create
objDesc("micclass").Value = "Link"
' Get all link objects on the page
Set links = Browser("title:=Google").Page("title:=Google").ChildObjects(objDesc)
' Print the number of links
MsgBox "Total links: " & links.Count
' Print all link names
For i = 0 To links.Count - 1
MsgBox links(i).GetROProperty("text")
Next
1. Breakpoints
Add breakpoints to pause execution at a specific step.
Use F9 to toggle breakpoints.
4. Watch Variables
Add variables to the "Watch" window to track their values.
Reporting Tools:
Reporter Utility: Generates custom test reports.
Reporter.ReportEvent micPass, "Login Test", "Login was successful"
Generates pass/fail logs in the test results.
Reporter.ReportEvent micPass, "Login Test", "Login was successful"
Reporter.ReportEvent micFail, "Login Test", "Login failed - Invalid credentials"
11. HP ALM (Application Lifecycle Management): Integrates UFT for test management and defect
tracking.
HP ALM (formerly Quality Center) is used for:
1. Test Management – Organizing test cases, test plans, and execution history.
2. Defect Tracking – Logging and tracking bugs found during test execution.
3. Test Execution – Running UFT scripts directly from ALM.
4. Report Generation – Generating test reports and analyzing test coverage.
5. Steps to Integrate UFT with HP ALM
6. Before starting, ensure:
7. HP ALM is installed & running.
8. UFT has the ALM Add-in installed.
You can also launch UFT tests stored in ALM using a VBScript.
The script connects UFT to ALM, retrieves the test, and runs it automatically.
If the UFT test fails, you can log a defect in HP ALM. This script automatically logs a defect in ALM when a test fails.
12. A Regular Expression is a special sequence of characters that helps match patterns in text — especially useful
when object properties or values change dynamically (like session IDs, timestamps, or control names).
UFT allows using RegEx in:
● Object Repository
● Descriptive Programming
Checkpoints and output values
1: Match a dynamic title: Browser("title:=Flight Reservation.*").Page("title:=Flight Reservation.*").Sync
2: Match a changing button name: If a button’s label changes like "Submit Now", "Submit Form", etc., use:
WebButton("name:=Submit.*").Click
\w Any word character (A–Z, a–z, 0–9, _) \w+ → one or more word characters
` ` OR condition
Topic Example
● Jenkins
● Git
● Azure DevOps
● ALM/QC Integration
In UFT (Unified Functional Testing), you can capture error numbers using the Err object in VBScript.
15. Error Handling - The Err object provides details about runtime errors, including:
1. Err.Number → Returns the error number. captures the error and reports it in UFT’s result window.
2. Err.Description → Returns the error message.
3. Err.Source → Returns the source of the error.
The script attempts to open a non-existent file. Err.Number captures the "File Not Found" error and reports it.
1. Ordinal Identifiers - Ordinal Identifiers help UFT differentiate between similar objects when their properties alone are
not enough. Browser("creationtime:=1").Page("title:=Google").WebEdit("index:=0").Set "ChatGPT"
Type Description
CreationTime For browser objects, based on the time the browser was opened
2. Smart Identification - Used when UFT can’t find an object using normal properties.
It uses a backup strategy:
● Base filter properties (essential) and Optional filter properties (additional)
When used:
● Object is not found or multiple matches
● If enabled in Object Repository > Object Identification settings
3. Virtual Objects
Some UI elements (like custom buttons or shapes) are not recognized as standard objects by UFT.Virtual Objects allow you to
map areas on the screen and treat them like standard objects (like buttons). Use When:
● UFT doesn’t recognize an object
● It's not in the Object Repository
Steps:
1. Go to Tools → Virtual Object → New Virtual Object
2. Select the screen area (click and drag)
3. Assign it a type (Button, List, etc.)
4. Save it
Limitations:
● Screen resolution and layout must not change
● Doesn’t work well with dynamic UIs
You can also use dynamic descriptions to avoid using the Object Repository.
Technique Purpose
Tips:
1. You can make Excel visible with xlApp.Visible = True
2. Always release objects to avoid memory issues
Modes:
● 1 → Read
● 2 → Write
8 → Append
Task Method
To take a screenshot on error in UFT, save it in a custom folder, and use a timestamp as the file name, follow this
structured approach:
folderPath = "C:\UFT_Screenshots"
In UFT (Unified Functional Testing), both functions and subroutines are reusable code blocks used to modularize test scripts.
However, they differ mainly in how they handle return values.
18. Functions
Function Add(a, b)
Add = a + b
End Function
result = Add(5, 3) ' result will be 8
20. In UFT (Unified Functional Testing), GetROProperty, GetTOProperty, and SetTOProperty are methods used to
work with object properties. Here's a clear breakdown of what each does:
1. GetROProperty (Get Runtime Object Property)
● Retrieves the actual property value of an object at runtime, i.e., what UFT sees when the test runs.
● Useful when the UI changes dynamically.
● value = Browser("Browser").Page("Page").WebEdit("Username").GetROProperty("value")
● Example use case: To check the current text entered in a textbox during test execution.
● Returns the property value stored in the object repository or in the Descriptive Programming (DP) at the time the
script was written.
● It doesn't consider runtime changes.
● value = Browser("Browser").Page("Page").WebEdit("Username").GetTOProperty("name")
● To verify what UFT is using to identify the object.
Summary Table:
Method Description Scope
21. Frameworks are structured ways to design, develop, and execute automated test scripts. They improve reusability,
scalability, maintainability, and readability of test scripts.
2. Modular Framework
Description: Breaks the application under test into small, independent functions or modules.
Approach: Each module is tested with its own script.
Best For: Medium complexity apps.
Call Login()
Call SearchItem()
Call Logout()
Function Login()
' Code to login
End Function
3. Data-Driven Framework
Description: Test data is separated from test scripts and stored in external files (Excel, CSV, database).
Approach: One script runs with multiple data sets using parameterization.
Best For: Scenarios requiring multiple inputs.
For i = 1 To DataTable.GetRowCount
username = DataTable("User", dtGlobalSheet)
password = DataTable("Pass", dtGlobalSheet)
Call Login(username, password)
DataTable.SetNextRow
Next
4. Keyword-Driven Framework
Description: Uses keywords to represent actions in test scripts. Testers don’t write VBScript, just define
keywords and data.
Approach: Keywords (like Click, Set, Verify) are mapped to functions.
Best For: Teams with non-technical testers.
5. Hybrid Framework
Description: Combines two or more frameworks (usually keyword + data-driven + modular).
Approach: Most real-world UFT frameworks are hybrid for flexibility and power.
Best For: Complex applications and enterprise-level projects.
Ex. Structure
Modules: Login.vbs, Search.vbs
Data: Excel sheet
Keywords: Stored in data
Main Script: Calls functions based on keywords and data
A step-by-step guide to build a Hybrid Framework in UFT for automating invoice generation on taxtech.com
using different credentials from Excel. This hybrid framework combines modular, data-driven, and
keyword-driven elements.
Components:
Driver Script (Main.vbs): Controls the execution
Function Library (Functions.vbs): Stores reusable functions
Excel Files:
LoginData.xlsx: Stores usernames & passwords
InvoiceData.xlsx: Stores product details
Object Repository (OR.tsr): Stores UI objects (optional if using Descriptive Programming)
- InvoiceData.xlsx
Product Weight RatePerKg
Cement 50 12
Steel Rods 100 20
2: Create Function Library (Functions.vbs)
Function LaunchApp()
SystemUtil.Run "chrome.exe", "https://www.taxtech.com"
Browser("creationtime:=0").Page("title:=.*").Sync
End Function
Function Login(username, password)
With Browser("creationtime:=0").Page("title:=.*")
.WebEdit("name:=username").Set username
.WebEdit("name:=password").SetSecure password
.WebButton("name:=Login").Click
End With
End Function
With Browser("creationtime:=0").Page("title:=.*")
.WebEdit("name:=product").Set product
.WebEdit("name:=hsn").Set hsnCode
.WebEdit("name:=weight").Set weight
.WebEdit("name:=rate").Set rate
.WebButton("name:=Print").Click
End With
End Function
Function CloseBrowser()
Browser("creationtime:=0").Close
End Function
LaunchApp()
Login username, password
' Cleanup
oWBLogin.Close False
oLogin.Quit
Set oSheetLogin = Nothing
Set oWBLogin = Nothing
Set oLogin = Nothing
oWBInvoice.Close False
oInvoice.Quit
Set oSheetInvoice = Nothing
Set oWBInvoice = Nothing
Set oInvoice = Nothing
4: Object Repository (Optional) If not using Descriptive Programming, create an Object Repository:
Add fields: username, password, Login, product, hsn, weight, rate, gst, Print
Associate the OR with the test.
5: Run the Test:
Open UFT
Create a Test → Associate the .vbs files
Ensure Excel files are in the right location
Click Run
OPTIONAL ENHANCEMENTS:
Add Reporter logs: Reporter.ReportEvent micPass, "Login", "Logged in successfully"
Add Error Handling with On Error Resume Next and custom log files
Use Environment Variables for dynamic settings.
Integrate with ALM or Jenkins for CI/CD