UFT Interview
UFT Interview
UFT Interview
com
---------------------------------------------------------------------------------------------------------------------------------------------
To learn more about Add-ins and how to use them, watch this video tutorial.
Per-Action Object Repository is used by default. The extension for Per-Action repository is ".mtr" .
Shared Object Repository is preferable while dealing with dynamic objects which are called in multiple
tests. The extension is ".tsr"
3) Can we call QTP test from another test using scripting. Suppose there are 4 tests and I want to call
these tests in a main script. Is this possible in QTP?
Yes. You can call 4 or even more scripts in your tests.For this, first you will need to make the Actions
in the corresponding scripts re-usable.Then from the destination script you can make calls to these re-
usable actions.
Action split is to divide an existing action into two parts.The purpose is to divide actions based on their
functionality to improve code re-use.
Foremost you will select Java Add - In and launch QTP. Next step record operations on the Java Tree. If
you face an issue while recording, you can select Tools > Object Identification > Java, tree object and
make changes in mandatory and assistive properties to enable identification.
P a g e 1 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Tip: You can base you answer on similar lines for any other object of any environment. For example : If
the question is how will check SAP checkbox , You say , first I will select SAP Add in ... and so on.
QTP identifies any GUI Object based on its corresponding properties. While recording, QTP will
identify and store peculiar properties (as defined in the Object Identification settings) in the object
repository of the GUI object . At run-time, QTP will compare the stored property values with the on-
screen properties, to uniquely identify the GUI object.
7) How many types of recording modes in QTP? Which will be used when?
3.Analog mode
Normal Mode: It is the default recording mode and takes full advantage of QTP's Test Object Model. It
recognizes objects regardless of their position on -screen. This is the preferred mode of recoding and
is used for most of the automation activities.
Low-level recording mode: This mode records the exact x,y co-ordinates of your mouse operations. It
is helpful in testing hashmaps. It is useful for recording objects not identified by normal mode of QTP.
Analog mode: This mode records exact mouse and keyboard "movements" you perform in relation to
the screen / application window. This mode is useful for the operation such as drawing a picture,
recording signature., drag and drop operations.
1) Call to copy of Action. - In this ,the Action Object Repository , Script and Datable will be copied to
the destination Test Script.
2) Call to Existing Action. - In this, Object Repository , Script and Datable will NOT be copied but a call
(reference) would be made to the Action in the source script.
P a g e 2 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Your application may contain objects that behave like standard objects but are not recognized by QTP.
You can define these objects as virtual objects and map them to standard classes, such as a button or
a check box. QTP emulates the user's action on the virtual object during the run session. In the test
results, the virtual object is displayed as though it is a standard class object.
For example, suppose you want to record a test on a Web page containing a bitmap that the user
clicks. The bitmap contains several different hyperlink areas, and each area opens a different
destination page. When you record a test, the Web site matches the coordinates of the click on the
bitmap and opens the destination page.
To enable QTP to click at the required coordinates during a run session, you can define a virtual object
for an area of the bitmap, which includes those coordinates, and map it to the button class. When you
run a test, QTP clicks the bitmap in the area defined as a virtual object so that the Web site opens the
correct destination page.
10) How to perform Cross platform testing and Cross browser testing using QTP? Can u explain
giving some example?
You will need to create separate Actions which take care of different OS and Browsers
Using the Built in Environment Variable you can dig up the OS information.
Eg. Platform = Environment("OS"). Then based on the Platform you need to call the actions which you
recorded on that particular platform.
Using this code Eg. Browser("Core Values").GetROProperty("version") you can extract the Browser
and its correspondin version. Ex: Internet Explorer 6 or Netscape 5. Based on this value you call the
actions which are relevant to that browser.
Logical name is a name given by QTP while creating an object in the repository to uniquely identify it
from other objects in the application. This name would be used by the QTP to map the object name in
script with its corresponding description in the object repository. Ex:
Browser("Browser").Page("Guru99") Here Guru99 is the logical name of the object.
Typically ,an object and its properties must be recorded in the Object Repository to enable QTP to
perform action s on it. Using descriptive programming , you do not store the object and its property
values in the Object repository but mention the property value pair directly in the script.
P a g e 3 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
The idea behind descriptive programming is not bypass the object repository but help recogonize
dynamic objects.
13)What are the properties you would use for identifying a browser & page when using descriptive
programming?
ex: Browser("name:="xxx"").page("name:="xxxx"").....
OR
ex: Browser("micClass:=browser").page("micClass:=page")....
Yes .you can record remote application provided you are accessing application through the local
browser not via remoter like citrix.
If you are still unable to record it is advisable install QTP and application, on the same machine
Arguments
location : Optional. The name of the network server where the object is to be created.
16) Can you switch between Per-Action and Shared Object Repository? If yes how?
Yes .We can switch. Go to Test--->Settings--->Resources. Here you have an option to choose
repositories.
P a g e 4 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Object Spy helps in determining the run & test time object properties & methods of the application
under test.
You can access object spy directly from the toolbar or from the Object Repository Dialog Box.
18) When ordinal identifiers alone can make an object unique then why they are not given top
priority? Why it is first mandatory and next assistive. Why we cannot go for ordinal identifiers
directly?
a) If two objects are overlapped on each other than location based object recognition will fail.
b) If only index based recognition is used your script will work but script execution time will increase.
QTP Automation Object model deals with Automation of QTP itself. Almost all configuration and
functionality provided by QTP is represented by QTP's Automation Object Model . Almost all dialog
boxes in QTP have a corresponding automation object which can set or retrieved using the
corresponding properties or methods in the Automation Object Model.QTP Automation Objects can
be used along with standard VB programming elements like iterative loops or conditional statements
to help you design a script of choice.
Text Output values enable you to capture text appearing on the application under test during run-
time.
If parameterized, text output values will capture values appearing in each iteration which would be
stored in the run-time data table for further analysis.
Step Generator enables use to Add Test Steps in your script. Using step generator you can add steps to
your script without actually recording it.
P a g e 5 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
23) How to make QTP understand the difference amongst the same type of objects .Suppose there
are 5 check boxes in a page and I have to choose the 2nd one, how to do that through script?
You can use ordinal identifiers like index along with a little descriptive programming for object
recognition.
Test Fusion Report , displays all aspects of a test run and is organized in a Tree format.
It also gives Run-time data table, Screen shots and movie of the test run if opted.
a. Recovery Scenarios.
b. Using “On Error” statement
At Script Level you can use the On Error Resume Next and On Error Go to 0 statement.
P a g e 6 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Environment.Value("OS") -- This will return your system OS
27) What is the Difference between Bitmap Check point & Image Check point? Bitmap checkpoint
does a pixel to pixel comparison of an image or part of an image.
Image checkpoint does do a pixel to pixel comparison but instead compare image properties like alt
text , destination url etc.
Actions have their own Object Repository & Data Table. Actions help make your Test modular and
increase reuse. Example: You can divide your script into Actions based on functionality like Login,
Logout etc.
Functions is a VB Script programming concept and do not have their own Object Repository or Data
Table. Functions help in re-use of your code. Ex: You can create a Function in your script to
concatenate two strings.
Keyword View is an icon based view which shows test steps in tabular format. It also automatically
generates documentation for the test steps.
Expert View gives the corresponding VB Script statement for every test step in the Keyword view.
1) Create your test plan - This is preparatory phase where you identify the exact test steps, test data
and expected results for you automated test. You also identify the environment and system
configurations required to create and run your QTP Tests.
2) Recording a session on your application - During this phase , you will execute test steps one by one
on your AUT ,and QTP will automatically record corresponding VB script statements for each step
performed.
3) Enhancing your test - In this stage you will insert checkpoints , output values , parameterization ,
programming logic like if…else loops to enhance the logic of your test script.
4) Replay & Debug - After enhancements you will replay the script to check whether its working
properly and debug if necessary.
5) Run your Tests - In this phase you will perform the actual execution of your Test Script.
6) Analyzing the test results - Once test run is complete, you will analyze the results in the Test Fusion
report generated.
P a g e 7 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
7) Reporting defects - Any incidents identified needs to be reported. If you are using Quality Center ,
defects can be automatically raised for failed tests in QTP.
32) How will you check a web application for broken links using QTP?
You can use the Page Checkpoint which gives a count of valid/invalid links on a page.
33) What is a Run-Time Data Table? Where can I find and view this table?
Data like parameterized output , checkpoint values , output values are stored in the Run-time Table. It
is an xls file which is stored in the Test Results Folder. It can also be accessed in the Test Fusion
Report.
34) What is the difference between check point and output value.
Check point is a verification point that compares a current value for a specified property with the
expected value for that property. Based on this comparison, it will generate a PASS or FAIL status.
An output value is a value captured during the test run and can be stored in a specified location like
the Datable or even a variable. Unlike Checkpoints, no PASS/FAIL status is generated.
b) username
c) password
d) DNS name
P a g e 8 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
You can code the database connectivity command directly or you can use the SQL Query tool provided
by QTP.
You can use the Batch testing tool to run multiple scripts. Once the scripts are added in the tool ,
it will automatically open the scripts and start executing them one after the other.
As of QTP version 10
1) Huge Tests in QTP consume lots of memory and increase CPU utilization.
2) Since QTP stores results in HTML file (and not txt) the result folder sometimes becomes big.
A step when declared optional is not mandatory to be executed. If the corresponding GUI object is
present, QTP performs the operation on it. If the GUI object is not present, QTP bypasses the optional
step and proceeds to execute the next step.
Reporter.Reportvent is standard method provided by QTP to send custom messages to the test results
window.
Syntax
where
EventStatus = 0 or micPass
1 or micFail
2 or micDone
3 or micWarning
Results can assume any status like Pass , Fail , Warning etc. You can also send screenshot to the test
results window.
You declare using a DIM keyword. You assign value to the variable using the SET keyword.
P a g e 9 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Ex.
GetRoProperty is a standard method provided by QTP to fetch property values of a run -time object.
Typically, if even one of the on-screen object property does not match the recorded object property.
The test fails.
In smart identification, QTP does not give an error if the property values do not match, but uses Base
filter and Optional Filter properties to uniquely identify an object. In Smart identification, if a property
value does not match the script does not fail but it proceeds ahead to compare the next property.
Smart identification can be enabled in Object Identification Dialog box.
43) How would you export a Script from one PC to another in QTP?
We can make use of the "Generate Script" function available in Object Identification, Test Settings and
Tools/Options tab to create a zip of the script at the source computer. These zip files then can be
imported into QTP at the destination computer.
No. You can work with only single instance of QTP on the same machine. But QTP itself can work on
multiple instances of the Application Under Test (AUT). Ex: QTP can handle multiple IE browser
windows.
DataTable.ImportSheet "..\..\TestData\Input.xls",1,dtGlobalSheet
DataTable.ExportSheet "..\..\Results\Output.xls","Global"
SetToProperty changes property of an object stored in the Object Repository. However these changes
are not permanent.
47) What is the standard timing delay for web based application in QTP?
It is an in-built tool provided by QTP to convert Actions into Business Process Components.
50) If the Global Data sheet contains no data and the Local Datasheet contains two rows of data,
how many times will the test iterate?
The example demonstrated here explains how to read registry key in UFT
e.g. HKCU\software\ie\settings
msgbox RegValue
52) What are the ways in UFT to get system environment variables in UFT?
myShell=Nothing,
myShell=Nothing
53) Mention the steps required in UFT to send mail from outlook?
54) Explain how you can fetch data from database in UFT?
To fetch data from database in UFT, you have to follow the code below
55) What are the codes we can use to get files from ftp server in UFT?
To get ftp files from ftp server, you have to use below code
P a g e 12 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
b) get- To download single file from ftp server
MyShell.Run "%comspec% /c FTP -n -s:" & commandstoworkwithftp & " " & Site, 0,True
56) In UFT how you can prevent the system from getting locked?
To prevent system getting locked, any of the two ways can be used
• Create a simple vbs file having code to press numlock key and run that vbs file
• Edit one registry key “DisableLockWorkstation =1” to disable locking
Descriptive programming includes property name and property value. Whenever UFT is facing
difficulty in identifying objects from object repository, and instead the object is directly identified from
the script is known as descriptive programming.
58) In UFT explain the difference between qfl and vbs files?
a) qfl is quick test function library file while vbs is Microsoft’s vbscript
c) To use file in UFT associate qfl file from test setting, while to include vbs file use “execute file
statement”
filepath = “C:\Bugs\Reports.xlsx”
P a g e 13 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible= True
Set Wb= objExcel.Workbooks.Open (filepath)
Wb.worksheets(1).Cells(1,1).Value = “guru99” read value from Excel file
After that, UFT will ask you to store .tsr file. Give the path and save. This will create .tsr file in UFT
To connect with QC, UFT provides the option to connect QC directly from UFT GUI.
a) Go to file menu
Following above steps will allow you to connect with QC, later on you can execute the tests from QC
itself.
In order to ease the process of test automation using UFT, test automation is designed. There are
mainly three types of automation frameworks in UFT
Either through object repository or description programming, UFT identifies objects. Descriptive
programming is used in following scenarios
P a g e 14 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
a) It is used to remove duplicate objects. Same objects exists in different screens or windows of
your application. If you use OR in this case you have to store same object under different object
hierarchy in OR. To deal with such situation, descriptive programming is used
Settoproperty stands for set test object property. You can use this property to change the object
values at runtime. You can edit the property values during the runtime, but the changes that are
made are temporary.
Dim ArrayofDictionary(2)
First element of array
Set ArrayofDictionary(0)= createobject("scripting.dictionary")
ArrayofDictionary(0).Add "key1", "temp1"
ArrayofDictionary(0).Add "key2", "temp2"
Added keys in first dictionary
Second element of array as dictionary
Set ArrayofDictionary(1)= createobject("scripting.dictionary")
ArrayofDictionary(1).Add "key1", "temp1"
ArrayofDictionary(1).Add "key2", "temp2"
Added keys in second dictionary…..and so on
Array Dictionary
• Dynamic array is possible • There is no concept of dynamic
dictionary
P a g e 15 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Mydecimal = 6.3433333
Roundedvalue= Round(Mydecimal , 3)
Print roundedvalue, it will print 6.343
69) How to find the total number of rows in the webtable in UFT?
There are three ways which we can find the count of rows in the table in UFT
a) DataTable.Export (“C:\export.xls”)
b) DataTable.ExportSheet “C:\mysheet.xls” ( If excel file does not exist, new file is created)
P a g e 16 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
72) In datatable sheet in UFT, how to read a value from the cell?
b) In second step we define the parameter/column name from the sheet to read
Example:
For this example, we have set the row pointer to 2 in transaction sheet
Datatable.GetSheet(“Transactions”).SetCurrentRow(2)
Now, we have to specify that we want to read a value from the module_name column from the
transaction sheet
73) What are the loops available in UFT and what they do?
b) For…..Next : For Next Loop will execute a series of statements until a specific counter value
c) For……Each : In order to execute a series of statements for each statements for each object in
collection “For Each Loop” is used
While….Wend Loop : While Wend Loop is used to execute a series of statements as long as given
condition is true
There are three types of error that one will face in UFT
a) Syntax Errors
b) Logical Errors
c) Runtime Errors
75) What are the ways you can handle run time errors?
e) Recovery Scenarios
f) Report Object
Exitaction is used when we want to exit from a particular action, while exititeration is used to exit
from a particular action iteration of an action.
77) In QTP how you can remove the spaces from string?
You can use replace function to remove spaces from string in QTP
Itrim function can be used if only leading spaces from string needs to be removed
You can use rtrim function to remove trailing spaces from string
78) In QTP how you can get the last character from a string?
There are 4 ways through which we can add synchronisation points in QTP
a) Wait statement : This statement will pause the execution for x seconds until object comes up
b) Wait property : This method will wait until property of object takes particular value
c) Exist statement : This statement will wait until object becomes available
P a g e 18 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
d) Sync method: The code will wait until browser page is completely loaded. For web application
testing this method is used.
Syntax
Crypt.Encrypt(“Guru99”)
Example :
In this example, value in pwd variable is encrypted using the Crypt. Encrypt method.
pwd= “myvalue”
pwd = Crypt.Encrypt (pwd)
Browser(“myb”).WinEdit (“pwd”). SetSecure pwd
81) Mention what is the difference between Excecute file and loadfunction library?
In execute file, we can’t debug the statements. With loadfunction library, statements can be debug
and can also load multiple library files.
print (ubound(arr)+1)
Ubound returns the last index in array- so length of array will be +1. This will be total number of
elements in array
83) Mention what are the different types of recording modes in QTP? Which will be used when?
a) Normal mode : It is the default recording mode and used for most of the automation activities.
Regardless of their position on screen it recognizes objects.
b) Low level recording mode: It is useful for recording objects not identified by normal mode of
QTP. It records the exact x,y coordinates of your mouse operations.
c) Analog mode: This mode is useful for the operation such as recording signature, drawing a
picture, drag and drop operation.
P a g e 19 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
84) In what ways you can call from one action to another action?
There are two ways you can call from one action to another action
a) Call to copy of action: In this, the script and data-table, action object repository will be copied to
the destination Test Script
b) Call to existing Action: In this, script data-table and object repository are not copied instead a call
reference would be made to the action in the source script
85) What is Optional step in QTP? How you can add optional step in QTP?
When running a test, it test fails in opening a dialog box, QTP does not necessarily abort the test
run. It bye passes any step designated “optional” and continues running the test. By default QTP
automatically marks as optional steps that open certain dialog boxes. In order to set an optional step
in the keyword, right click and select “Optional Step”. The icon for optional step would be added in
next step. In the expert view to add optional step, add optional step to the beginning of the VBScript
statement.
B= A(2) ‘ B is now 30
Content = “Guru99”
Set Fo = createobject(“Scripting.FilesystemObject”)
Set f =Fo.openTextFile(“c:\abc.txt”, 8,true)
f.Write (contents)
f.Close
Set f= nothing
P a g e 20 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
88) When ‘option explicit’ keyword is used in QTP?
To specify that all variable must be declared before use in QTP, ‘Option Explicit’ keyword is used.
You must use “Exit For” statement to exit “for loop” in QTP. “Exit For” statement will get the control
out of the “for loop”
For count= 1 to 3
TempNum= mid(Tempstr,count,1)
If isnumeric(TempNum) Then
LenghtNum = LengthNum & TempNum
Else
Exit For
End If
Next
GetStrLenNumber = LengthNum
Size of an array in QTP will be found by using the following code Print (ubound(arr)+1)
qrs means “Quicktest Recovery Scenario”. By using recovery scenario manager we can handle
exceptions in test execution.In QTP using recovery scenario manager we can handle exceptions in test
execution. In QTP when you create a recovery scenario, you must save it in .qrs file. qrs file may have
any number of scenarios defined in it.
“Action 0” is created by default when you create a new test in QTP along with action 1. To determine
the sequence in which we call other actions 1,2,3 etc. action 0 is used.
To replace part of string in QTP we will use the code as shown below Example,
Str = (Guru99)
Suppose if you want to replace “99” with “88” then the code will
print replace(str,“99”, “88”) output will be “Guru88”
P a g e 21 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Various types of automation frameworks available in QTP are
a) Linear Scripting
95) What is ‘Object Spy’ and what is the function of object spy in QTP?
‘Object Spy’ is a feature in QTP by using which you can view both the test and run time object
properties and methods.
96) What is “GetROProperty” and what are the steps involved in using GetROProperty?
a) Record the object on which you want to use the GetROProperty in Object Repository
b) Identify the run time property for the recorded object which could be used
c) To retrieve the identified run time property and store the value in a variable
97) Explain how you can find the absolute value of the number in QTP?
To find out the absolute value of a number a built in function in QTP is available
Example- a= -1
Print abs(a) ‘output will be 1
To check whether if parameter exists in data table we will use the code
In keyword driven automation framework, the focus is mainly on keywords/functions and not the test
data. It means the complete focus is on creating functions which maps the functionality of the
application.
Xpath can be used to identify only web objects. We can use the following code to identify objects.
Set oPage=Browser(“myGoogle”).Page(“myGoogle”)
oPage.WebEdit(“xpath:=//INPUT[@name=‘nameofeditbox’]”).Set “search term”
‘Enter value in google edit box
Set fo = createobject(“Scripting.filesystemobject”)
fo.deletefile(“C:\xyz.xlsx”)
Set fo=nothing
World Wide Web Consortium (W3C) came up with some instructions and guidelines for Web-based
technology and information systems to make it easy for the disabled to access the web. For example
the standards make it mandatory to have an 'alt text' for an image. So a blind person who is accessing
the website, will use text - to -speech converters and atleast understand what the image is about if
not see it. All these standards are checked by Accessibility Checkpoints.
P a g e 23 | 24
https://www.guru99.com
---------------------------------------------------------------------------------------------------------------------------------------------
Guru99 Provides FREE ONLINE TUTORIAL on Various courses like
P a g e 24 | 24