Dear readers, these QTP Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of QTP. As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer:
Based on the technologies, add-ins, and platforms, QTP chooses the environment to work on.
QTP can work on the given below environments −
|By default supported environments|
|Web||Active X||Visual Basic|
|Other supported environments|
|.Net (Windows & web form)||People Soft||Visual Age|
|Power Builder||Siebel||Web Services|
|SAP for Web||Stingray||Terminal Emulator|
|WPF||Standard Windows||SAP for Windows|
QTP Supports 2 types of Object Repository −
Shared Object Repository
Per-Action Object Repository
Shared Object Repository: It is also called a Global object repository, the best while using dynamic object and object description change frequently in a test, presented by the extension “".tsr". Testers usually prefer Shared object repository more than Local object repository while automating the test.
Per-Action Object Repository: It is a default object repository also called a Local object repository presented by the extension ".mtr”.
In QTP, logical name is a name that uniquely identify object with respect of other objects of the application while creating an object in the repository. QTP uses this object name to map the object presented in script with its corresponding description in the object repository by using this code−
Browser("Browser").Page("Tutorialspoint"). Here, Tutorialspoint is the logical name of the object.
Usually, QTP performs action on object and its properties that have been saved in the object repository.
Descriptive programming doesn’t facilitate users to store the object and its property values in the object repository, but facilitate users to directly mention the property value pair in the script. Descriptive programming is not to avoid the object repository, it facilitates users in recognizing the dynamic objects.
In descriptive programming, use the name property, for example −
Also use the property "micClass", for example,
Yes! You can record the application placed in a remote mechine via local browser not via remote like; citrix, but if you are still unable to record then it is better to install QTP and application on the same machine to maintain the same session.
The keyword “CreateObject” creates and returns a reference to the test object.
CreateObject (servername.typename [, location] )
servername − A required argument for the code, used to present the name of the application that provides objecst.
typename − A required argument for the code, used to present the type or class of the object to create.
location − An optional argument for the code, used to present the name of the network server where the object is to be created.
For example − Set IE = CreateObject("Chrome.Application")
Yes, it call be possible by creating the re-usable action to the corresponding test script and from the destination test script make calls to the re-usable actions test scripts.
In QTP, action split can be used to divide an important and existing action into two parts. Action can be divided into parts according to its functionality, so that; the code can be improved and reused for different purpose.
First, open QTP by selecting Java add-in, then perform the recording operation on the Java tree. If, you are not getting proper recording environment, then in the opened QTP tool, go to Tools Object Identification Java. In the tree objects make changes in compulsory and assistive properties to facilitate identification.
Cross platform testing and Cross browser testing can be possible by creating different actions in terms of different operating systems and Browsers.
Cross Platform Testing: The built-in Environment Variable helps in excavating-up the OS information. You can call the action based on the platform where the action have been recorded.
Cross Browser Testing: The code; Browser ("Core Values").GetROProperty ("version") helps in extracting the browser and its corresponding version, for example; IE 6, Mozilla Firefox 9 or Netscape 5. After extracting the browser, you can call the actions relevant to the particular browser.
Directly, you can connect to QC from UFT GUI window. To do so −
Go to file menu and choose (QC) quality center
Next, a window will open to enter QC’s url and other details– In this window, enter user id, password and project
Give above steps will facilitate you to connect to QC, later on you can execute the tests from QC itself.
Types of Automation Framework in UFT −
Linear − Using this framework you can create the test very easily, just you need to write a one single program without modularity in sequential steps.
Keyword driven − To create the test using this framework, you have to generate different keyword for different set of operations and refer these keywords to the main scripted code.
Data driven − It is used to execute same set of operations on multiple sets of data that are reserved in separate files, generally excel sheets.
Hybrid − A combination data driven and keyword driven framework
BPT − Here, programs are broken down into business components and programs are used with one or the other of the above types of frameworks.
Settoproperty stands for set test object property. Using this property, you can temporarily change the object values and its corresponding property value at runtime.
Round function in UFT is used to round the decimal value
Mydecimal = 8.2755555 Roundedvalue = Round(Mydecimal , 5) Print roundedvalue ‘it will print 8.275
Yes! User can switch from local to share object repository by opening QTP window, going to Test Settings Resources (provide an option to choose repositories).
In QTP, object’s properties help in identifying the GUI object. During recording, the object repository of the GUI objects stores the properties that have been defined in the Object Identification settings and while running the test, QTP compares the properties that have been stored in the object repository of the GUI objects with the on-screen properties to uniquely recognize the GUI object.
Execution of multiple test files (or series of files) together at a same time is known a batch testing. To execute the batch testing, QTP provides a tool “Batch Test Runner”. To function multiple files together in a tool, you just need to add a script of the test. After adding script, you don’t need to do anything manually, tool will automatically start opening and executing the test script one after the other.
There are many drawbacks of QTP −
Costly in terms of license and maintenance
Cannot run multiple threads/instances
Execution process is slow as compare to open source tools like Selenium
QTP license can only be renewed from HP only
There are 3 types of recording mode that QTP supports −
Normal (Contextual)recording mode
Low-level recording mode
Analog recording mode
Normal recording mode: A default recording mode which has been used in most of the automation activities. By using QTP's Test Object Model, it recognizes objects apart from their location on screen.
Low-level recording mode: In this mode, operation of mouse in x, y co-ordinates helps in recording the objects. It is capable in testing hashmaps and recording objects that can’t be identified by normal recording mode.
Analog recording mode: This recording mode records screen/application window on the basis of mouse and keyboard operations. It records the operations, like; drawing a picture, recording signature, drag and drop operations.
Keyword View is an icon based view, displays test steps in tabular format and automatically creates documentation for the test steps.
Expert View gives the corresponding VB Script statement for every test step in the Keyword view.
Although, QTP doesn’t give any built-in support to the database connectivity, VBScript language and ADODB objects helps in database connectivity.
There are certain things that must be known before connectivity −
Connection string of your server (will be differ from one server to another and can be build from www.connectionstrings.com)
To connect to the database, either; you can code the database connectivity command directly or you can use the SQLQuery tool provided by QTP.
During test or descriptive programming, object spy facilitates to identify & get the run & test time object properties & methods of the application. It can be access either directly from the toolbar or from the object repository.
The extension of the Code file is script.mts.
If a step declared as an optional, QTP thinks that the step is not mandatory to execute. If an optional step contains GUI objects, QTP executes that step. If an optional step doesn’t contain GUI objects, QTP avoids the optional step and move to the next step.
The types of Automation Frameworks are −
Linear Scripting - Record & Playback
Test Library Architecture Framework
Data-Driven Testing Framework
Keyword-Driven (or Table-Driven Testing Framework)
The Page Checkpoint in QTP displays numbers of count of valid/invalid link present in a page.
Although, QTP provides four types of result status; Pass, Fail, Done, and Waiting, a standard method of QTP “Reporter.Reportevent” sends custom messages to the test results window. “Reporter.Reportevent” can also send screenshot of result status to the test result window.
Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]
EventStatus = 0 or micPass, 1 or micFail, 2 or micDone, and 3 or micWarning
ReportStepName = (String) Name of the intended step in the report (object name).
Details = (String) Description of the report event. The string will be displayed in the step details frame in the report.
QTP Automation Object model completely deals with the automation process happens in QTP. Usually, QTP Automation Object model represents all configuration and functionality provided by QTP test. Almost all, QTP dialog boxes contains their corresponding automation object which can edited or regained by their corresponding properties or methods presented in Automation Object Model. User can use Automation Objects with standard VB programming elements (iterative loops or conditional statements) to design a desired script.
During runtime of the test, Text Output values capture text display on the application. In parameterization, text output values capture values display on each iteration, those values will be stored in the run-time data table for further help.
Step Generator adds steps to the test scripts with recording any process.
An action can be called in two ways −
Call to COPY of an Action: While copping the action (reusable and non-reusable actions), the action also copies checkpoints, parameterization, and the corresponding action tab in the Data Table of the calling test. In the Data Table of the calling test, you can do the modification to the copied action that modification would not give any affect to the other tests.
Call to an EXISTING Action: Here, You can make a call only to the "Reusable" actions. In the calling test, calls to an existing action will be in read-only mode. They can only be modified in the test in which they were created. It is easily manageable and can be used the same action in several test.
Test Fusion Report presents all features of a test application that comes in use while running the test. Test Fusion Report presents it-self as an organized tabular format. Also, it gives details of each and every step of the iterations, run-time data table and movie of the test run if selected.
The Run-time data table stores values, like; parameterized output, checkpoint values, output values, etc. It presents it-self with “xls” file extension and store it-self in the Test Results Folder. User can also access it from the Test Fusion Report.
Check point is a verification point that generates a PASS or FAIL status by comparing a specified property the current value and the expected value.
An output value is a value recorded while running a test and can be stored in a particular location like; either in a Datatable or in a variable. Unlike Checkpoints, it doesn’t compare two values to generate PASS/FAIL status.
In QTP, exceptions can be handled by using “recovery scenarios” and “On Error” statements.
To handle the exception in recovery scenario, you have to define three things −
Post Recovery Test-Run
To handle the exception by “On Error” statements – In the script, you have to use the “On Error Resume Next” and “On Error Go to 0” statement.
In QTP, Actions are written VB scripting language which doesn’t return any values. Functions are written VB scripting language which returns single value.
Every Action contains its own Object Repository, Data table, Active screen, etc where as function does not.
Function can be called in action, but action can’t be called in function.
In QTP, functions are saved with ".vbs" extention where as actions are saved with ".mts" extension.
Action is internal to QTP whereas Function is just lines of code with some/none parameters and a single return value.
Actions are sometime reusable but sometime not whereas functions are always reusable.
Use DIM keyword before a variable name to declare a variable and use SET keyword before a variable name to assign value to the variable
“Dim weight”, here DIM keyword is used to declare weight variable. Set weight = 40, here SET keyword is used to assign value “40” to the weight variable.
GetRoProperty is a standard method of QTP that fetches property values of a run -time object.
Sometimes, QTP is incapable in finding an object that matches to the corresponding object description. Or, sometime, QTP finds more than one objects match to the object description. So, to resolve this issue, QTP ignores the object descriptions and concentrates on the Smart Identification mechanism to identify the objects.
QTP's Smart Identification mechanism uses two types of properties to identify the objects − Base Filter Property & Optional Filter Property.
Base Filter Property - A property of a specific test object class whose values changes when the real meaning of the original object changes.
Optional Filter Properties - It also helps in identifying the objects of a particular class whose properties change often, but if they are no longer applicable, you can ignore it.
You can create a ZIP file of the scripts into your source computer that can be imported into QTP’s destination computer by using the "Generate Script" function. To avail this function, go to the Object Identification Test Settings Tools/Options tab.
No! We can’t open two instance of QTP in a single machine to work for, but QTP itself can work on multiple instances of the Application Under Test (AUT) and handles multiple IE browser windows simultaneously.
Syntax to import xls into QTP −
DataTable.ImportSheet "..\..\TestData\Input.xls",1,dtGlobalSheet Syntax to export xls into QTP, DataTable.ExportSheet "..\..\Results\Output.xls","Global"
SetToProperty is a standard method of QTP that temporarily changes the property of an object stored in the Object Repository.
The standard timing delay for web based application is 60 second that can be changed by Test Settings dialog box.
The correct syntax to write data to excel file in UFT is −
filepath = “C:\Bugs\Reports.xlsx” Set objExcel = CreateObject(“Excel.Application”) objExcel.Visible = True Set Wb= objExcel.Workbooks.Open (filepath) Wb.worksheets(1).Cells(1,1).Value = “TutorialPoints” read value from Excel file
TSR stands for Test Shared Repository, used to share object repositories.
Follow the given below steps to generate TSR file −
First, open object repository, and then go to file menu. Next, export local objects option and select it. UFT will open dialog box to save.tsr file; give the desired path to save the file.
The above steps will generate the .tsr file in UFT.
It is a standard built-in tool delivered by QTP to convert Actions into Business Process Components.
UFT provides three ways to get the count of rows from the webtable.
Using webtable object’s property − rowcount
Using HTML DOM + UFT
There are two ways to export data-table to excel −
DataTable.ExportSheet “C:\mysheet.xls” ( creates the new file in the absence of excel file)
QTP supports three types of Environment variables −
Built-in (Read only)
User-defined Internal (Read only)
User-defined External (Read/Write)
The given below syntax used to retrieve the Environment Variable
Environment.Value( "name") = "TutorialPoints" OR Environment.Value( "OS") = " TutorialPoints"
Environment.Value ("name") The syntax will return name as TutorialPoints
Environment.Value ("OS") This will return your system OS
In Bitmap checkpoint, user can compare two complete bitmaps as well as part of the bitmaps from a pixel to pixel.
In Image checkpoint, user can only check the Image property values
Difference between qfl and vbs files −
qfl is quick test function library file whereas vbs is Microsoft’s vbscript file
qfl is a non-executable file whereas vbs is an executable file
To use qfl file in UFT, you must associate qfl file from test setting, whereas vbs file can only be associated with “execute file” statement.
The correct syntax to write data to text file in UFT is −
Content = “TutorialPointsTutorials” Set Fo = createobject ("Scripting.FilesystemObject") Set f = Fo.openTextFile ("c:\myFile.txt",8,true) ' open in write mode f.Write (contents) f.Close Set f = nothing
The extension of a function library is “.QFL”.
QTP doesn’t perform iterations based on local data sheet, it performs iterations based on Global data sheet, so that; the test iterate will be only once on global datasheet.
The given below code help in sending email from outlook −
Set Outlook = CreateObject ("Outlook.Application") Dim Message 'As Outlook.MailItem Set Message = Outlook.CreateItem (olMailItem) With Message .Subject = Subject .HTMLBody = TextBody .Recipients.Add (aTo) Const olOriginator = 0 .Send End With
Follow the given below code to get data from database −
Set db = createobject (“ADODB.Connection”) db.Open “Provider = Microsoft.Jet.OLEDB.4.0;Data Source=G:\guru99\vb6\admission_project.mdb; Persist Security Info = False” Set rst = createobject (“ADODB.Recordset”) rst.Open “select*from Course”, db, 3 id = rst. RecordCount For i = 0 to id-1 Print rst.field (0) & rst.fields (1) & rst.fields (2) & rst.fields (3) rst.Movenext Next
Whenever, Object Repository grows, starts giving poor performance because of its increased size and UFT faces problem in identifying objects from object repository, descriptive programming (also known as Programmatic Description) provides a way to identifying objects and performing operations on objects that are not present in object repository. Descriptive programming includes property name and property value. It performs operation of objects of the application that are very dynamic, and to perform operation on the application at run-time without having the knowledge of object's unique properties.
Sometime, QTP doesn’t recognize objects of an application that have been considered as standard objects for an application. QTP considers those objects as virtual objects and map them to standard classes, those objects can be a button or a check box. During run time, QTP copies the user's action on the virtual object and the result of the test displays the virtual object as a standard class object.
Further you can go through your past assignments you have done with the subject and make sure you are able to speak confidently on them. If you are fresher then interviewer does not expect you will answer very complex questions, rather you have to make your basics concepts very strong.
Second it really doesn't matter much if you could not answer few questions but it matters that whatever you answered, you must have answered with confidence. So just feel confident during your interview. We at tutorialspoint wish you best luck to have a good interviewer and all the very best for your future endeavor. Cheers :-)