Google News
logo
QTP/UFT Interview Questions
Unified Functional Testing (UFT), originally known as QuickTest Professional (QTP), is software that automates functional and regression testing in software applications and environments.  
 
UFT = QTP + Service Tools
 
QTP (QuickTest Professional) supports Graphical User Interface(GUI) Windows and Web-based Testing only, but UFT Supports GUI and API Testing.
 
QTP is an automated functional testing tool that assists testers in running automated tests to find any flaws, defects, or gaps in the application under the test's expected outcomes. Mercury Interactive created it, which was eventually acquired by HP and is now MicroFocus.
Web, Java (Core and Advanced),.Net, WPF, SAP, Oracle, Siebel, PeopleSoft, Delphi, Power Builder, Stingray 1, Terminal Emulator, Flex, Web Services, Windows Mobile, VisualAge Smalltalk, Silverlight and mainframe terminal emulator.
This view is a tabular representation of all the objects and the actions that are performed on them. Every row in the table is a step performed on the AUT and can be modified. Some of the most common columns displayed are items, operations, values, and documentation.

Expert view : As the name indicates, this view is for technical users who would like to tweak the source code as per their requirements.
* UFT has record and playback capabilities.
* UFT has a very good object recognition technique.
* It records scripts on an active screen and assists testers in referring to screen object characteristics.

Integration and Support: 
 
* It facilitates continuous integration by connecting with Jenkins, Git, and other similar tools.
* The tool's integration with various platforms, such as .net and mainframe, is fantastic. It works with both new and old web technologies, as well as terminal emulators and Windows thick-client apps.
* UFT enables cross-browser testing and works with all major browsers, including Internet Explorer, Firefox, Chrome, and Apple Safari. d)Its connection with ALM allows us to store automation execution results in ALM and even schedule automation execution at a specific date and time.

* It works with XML.
*
It has an integrated development environment (IDE).
* It works with test management software such as Quality Center, Test Director, and Winrunner.
* Smoke, Regression, and Sanity are examples of suites that can be simply maintained.
* QTP allows for test reporting for analysis purposes.
* Through an active screen, you can improve existing tests even if you don't have Automated Ultrasonic Testing (AUT).
* It supports a variety of automation frameworks, including keyword-driven testing, modular testing, data-driven testing, and so on.
* UFT supports Business Process Testing (BPT), a component-based testing framework that provides a strong and efficient platform for manually and automatically testing complete business processes. Its component reusability feature makes the testing process very fast, and it combines manual and automation tests with less duplication.
QTP Supports 2 types of Object Repository
 
* Per-Action Object Repository, (also called Local)
*
Shared Object Repository (also called Global)

Local Object Repository : The default object repository is the Local Object Repository. It is action-specific and can only be used for one action at a time. When the application is not time-sensitive, a local object repository is preferred. The Local Object Repository can't be utilised again. In the local object repository, you can do a variety of things, including  :
* On the application under test, highlight an object saved in a repository.
* Check to see if a specific object in your AUT is saved in the Object Repository.
* Objects can be cut, copied, pasted, modified, and deleted.
* If you mistakenly changed the value of a property, you can edit its description using the update function in the application.

Shared Object Repository : When an application is dynamic and object descriptions change frequently, a global or shared object repository is preferred. In automation projects, shared object repositories are more typically utilised than local object repositories. However, when compared to a local object store, it has higher maintenance and administration costs.
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.
QTP supports 3 types of recording modes :
 
1. Normal mode also called Contextual
2. Low-level recording mode
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.
* Determine Testing needs : Define Testing Environment, Analyze Your Applications and Plan Actions
* Set up repositories : Local or Shared OR
* Define function libraries
* Generate test steps : Add steps, Add checkpoints
* Data drive your tests
* Run the tests
* SystemUtil.Run
SystemUtil.Run ( FileName, Parameters, Path, Operation )
Example : SystemUtil.Run(“iexplorer.exe”,http://www.google.com)
SystemUtil.Run(“test.txt”, “”,”C:\”,”1”)
 
* InvokeApplication
Example : InvokeApplication “C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.google.com”
 
* Creating a shell object using VB Script
Example : Create a “WScript.shell” object.
Dim testshell
Set testshell= CreateObject (“Wscript.shell”)
testshell.run "%windir%\notepad"
We can call an action in 2 ways
 
* Call to copy of Action : In this ,the Action Object Repository , Script and Datable will be copied to the destination Test Script.

* 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.
UFT has a lot of functionality, but it's also quite straightforward to understand and train employees on. The following are a few excellent features that offer a lot of value to scripting:
 
* Test Combinations Generator (TCG) : This software assists in the creation of test configurations by utilising test parameters and their possible values to generate different data combinations.

* Insight Recording :  It recognises controls solely based on their look, rather than their native properties. This can be handy for testing controls in environments where UFT isn't supported, or even on a distant machine running a non-Windows operating system. UFT recognises the controls in the application by matching them to the images saved with each of the Insight test objects when it runs the test or component.

* UFT offers built-in reporting capabilities as well as the ability to create customised output files that show exactly where a test step failed and when it did so, as well as the timestamp.

* Runtime objects for Windows are supported. We can use the Windows Runtime application to record and perform tests. With the Windows Runtime application, we may create object repositories.
You will need to create separate Actions which take care of different OS and Browsers
 
Cross Platform Testing : Using the Built in Environment Variable you can dig up the OS information.
 
Ex : Platform = Environment(“OS”). Then based on the Platform you need to call the actions which you recorded on that particular platform.
 
Cross Browser Testing :  Using this code Ex : 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(“freetimelearn”) Here freetimelearn is the logical name of the object.
In UFT, a checkpoint is a point where the current value of an Object's specified properties is compared to the intended value. If the present and predicted values are equal, the status is PASS; otherwise, the status is FAIL.
 
Following are the different types of checkpoints available in UFT :
 
Standard Checkpoint : During a run session, it compares the expected values of object properties captured during recording to the object's current values.

Page Checkpoint : A Page Checkpoint is a Standard Checkpoint established for a web page. It's used to count how many links and images are on a page. Page Checkpoints can be used to monitor Load Time, or the time it takes for a web page to load.

Bitmap Checkpoint : A Bitmap Checkpoint is a checkpoint that allows a user to examine the bitmap of an image or a complete web page. It compares real and expected images on a pixel-by-pixel basis.

Image Checkpoint : An image checkpoint allows you to inspect properties such as an online image's source file location. Unlike Bitmap Checkpoint, image checkpoint does not allow you to examine pixels (bitmaps).

Text Checkpoint : A text checkpoint is a tool for ensuring that expected text in a web page or application is present. This text could be from a specific area of the app or a small portion of the text on the screen.

Accessibility Checkpoint : It ensures that Web-based technologies and information systems follow the World Wide Web Consortium's (W3C) instructions and recommendations. These guidelines make it simple for impaired people to use the internet.

Database Checkpoint : A Database Checkpoint runs a query in real-time, and the database values are saved as intended. During runtime, the identical query is repeated and the actual and expected values are compared.

Table Checkpoint : A Table Checkpoint allows you to examine the contents of cells in a table (grid) that appears in your environment on the fly. You can also inspect table parameters such as row height, cell width, and so on. Table Checkpoint is similar to Database Checkpoint in that it allows you to save your work.

XML Checkpoint : You may verify XML Data, XML Schema, and XML Data using XML Checkpoints.
Descriptive programming is used to perform operations on an AUT object whose definition isn't recorded in the Object Repository. You can use this approach to skip the Object Repository and provide the Object Description directly in the statement. An object name is merely a way to link a scripted item to its description in a repository. The script should run even if the object name in your script and object repository is changed.
 
Following are the different types of descriptive programming:
 
Static Descriptive Programming : In the Static Method, you specify an object's attribute in the following pattern for object identification.
property:=values,
This format is known as a property value pair, and it is delimited by inverted commas. If your object has many descriptions for identification, use commas to separate them.
 
Dynamic Descriptive Programming : The second way to accomplish the same goal is to use Dynamic Descriptive Programming. It will be highly tedious to specify all the property value pairs for each sentence if your script uses the descriptive programming object candidate several times. In such instances, you might take advantage of QTP's Description Class. A description object's syntax is as follows :
Set MyDescription = Description.Create();
MyDescription("property").Value = "property-value";​
16 .
Without using both the record and system utility script, how can you open a notepad window?
This can be done by specifying the path of the notepad (location of the note.exe) on the “Windows Applications” Tab, which is in the “Record and Run Settings” window.
17 .
What is the purpose of OR (Object Repository) In QTP?
In QTP, the Object Repository contains text fields, radio buttons, images, texts, edit boxes, combo boxes, and lists, etc. With this Object Repository, QTP identifies the objects and acts on them.
On the off chance that the recorded portrayal doesn't empower QTP to recognize a particular object then QTP utilizes the "smart ID" method. It utilizes the accompanying extra properties to distinguish the object : 
 
Base Filter Properties : The arrangement of properties that can't be changed without changing the article type 
 
Optional Filter Properties : Additional properties which assist distinguish the article remarkably. 
You can use the name property
 
Ex : Browser(“name:=”xxx””).page(“name:=”xxxx””)…..
 
(OR)
 
We can also use the property “micClass”.
 
Ex : Browser(“micClass:=browser”).page(“micClass:=page”)….
20 .
Can we record an application running on a remote machine using QTP?
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
Creates and returns a reference to an Automation object
 
Syntax : CreateObject(servername.typename [, location])
 
Arguments :
 
servername : Required. The name of the application providing the object.
 
typename : Required. The type or class of the object to create.
 
location : Optional. The name of the network server where the object is to be created.
 
Example : Set IE = CreateObject(“InternetExplorer.Application”)
22 .
What is the use of Text output value in QTP?
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.
QTP has a predetermined set of properties that it learns/stores for every class of object it identifies.
 
There are 3 aspects to this :
 
Mandatory Properties : This is the list of properties for a certain class that QTP always stores. We could say that this is the object description. It also checks this in conjunction with the parent object to see if the description is sufficient to identify the object uniquely.

Assistive Properties : If the description of mandatory properties is insufficient to identify the Object, then a set of non-mandatory properties will be added to the description one after the other until there is enough data to identify the object.

Ordinal Identifier : If the assistive properties also do not result in the unique identification of an object a special ordinal identifier is added by QTP, such as the object’s location on the page or in the source code.
Method Description Syntax
AddSheet Adds the supplied sheet to the data table at runtime. DataTable.AddSheet (SheetName)
DeleteSheet The given sheet is removed from the run-time data table. DataTable.DeleteSheet( SheetID)
Export The Datatable is exported to a new file in the provided location. DataTable.Export(FileName)
ExportSheet Run-time export of a specific sheet of the Datatable. DataTable.ExportSheet(FileName, SheetName)
GetSheet The given sheet from the run-time data table is returned. DataTable.GetSheet(SheetID)
GetCurrentRow Returns the active row of the global sheet's run-time data table.2 DataTable.GetCurrentRow
GetParameterCount The number of columns in the run-time data is returned. DataTable.GetParameterCount
GetRowCount The number of rows in the Global Sheet's run-time data table is returned. DataTable.GetRowCount
GetSheetCount The total number of sheets in the run-time data table is returned. DataTable.GetSheetCount
SetCurrentRow Sets the current row's focus to the specified row number. DataTable.SetCurrentRow(RowNumber)
SetNextRow Sets the focus of the run-time data table's next row. DataTable.SetNextRow
SetPreviousRow Sets the previous row's focus in the run-time data. Table DataTable.SetPrevRow
OR is like a warehouse where all the objects in a test are stored. OR has the list of Objects that QTP learned during the recording process and the class to which they belong.
 
It stores a set of properties that uniquely identify the Object (description) and also names the object for the sake of identification in our test, based on its most prominent feature.
Standard window objects may be present in an application under test, but UFT may not recognise them. In certain cases, objects of the type button, link, or other can be declared as virtual objects (VO) so that user actions can be mimicked on the virtual objects during execution.
 
For example : Let's pretend we're automating a Microsoft Word scenario. We open the MS Word application and click on any of the ribbon icons. For example, on the Ribbon, the user selects the Insert tab, then selects the "Picture" button. Here, a button is recognised as a WinObject, emphasising the relevance of virtual objects.
 
Following are the limitations of virtual objects in UFT : 
 
* For analog or low-level recording, QTP does not allow virtual objects.
* Virtual Objects cannot have checkpoints added to them.
* Object Repository has no control over Virtual Objects.
* Although we map an object to a specific class (button or List), Virtual objects do not provide all of the original object's methods.
* Virtual Objects are not supported by Object Spy.
* If the screen resolution changes as the coordinates change, the test will fail.
* Virtual objects should be recorded correctly if the application window is the same size as the screen.
27 .
Are Shared ORs read-only?
By default, shared ORs are open as read-only. In order to open and edit them, you will have to open them from the Object Repository Manager.
 
“ORM -> File -> Enable Editing”
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.
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.
Round function in UFT is used to round the decimal value :
 
For example :
Mydecimal = 8.2755555

Roundedvalue = Round(Mydecimal , 5)

Print roundedvalue ‘it will print 8.275
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.
The "creation time" feature can be used to determine which browser instance was opened after another. This is nothing more than a counter for each browser instance that is launched. It starts at 0 for the first one and goes up from there. You can use the following code to close the second browser that has been opened :
Browser("creationtime:=1").Close
The timing interface between the Tool and the Application under test is known as the synchronization point. Synchronization point is a feature that allows you to set the time delay between two test script phases.
 
For example, clicking on a link may take 1 second to load the website, 5 seconds, or even 10 seconds to load completely. The response time of the application server, network bandwidth, and client system capabilities are all issues to consider. The script will fail if the time varies unless the tester manages the time discrepancies intelligently.
 
Following are the different ways of inserting a synchronization point in UFT :
 
WaitProperty : WaitProperty is a method that performs a sync using the property name, value and timeout value as input. Because it is a dynamic delay, this option is recommended.

Exist : Exist is a method that performs the sync using the Timeout value as an input. Because it is a dynamic delay, this option is recommended.

Wait : Wait is a hardcoded sync point that waits regardless of whether or not an event has occurred. As a result, using Wait is discouraged, but it can be useful for shorter wait times like 1 or 2 seconds. For example, wait(5) would denote that the system will wait for 5 seconds.

Sync Method :  The Sync Method is only suitable for web applications with a constant lag between page loads.

Inserting inbuilt Synchronization Points in QTP :
Step 1 : Enter into recording mode. If the user is not in Recording Mode, this option will be disabled.
Step 2 : Select "Design"-> "Synchronization Point".
Step 3 : We must choose the object that will serve as the Sync Point. The object window appears after you choose the object.
In QTP Exceptional handling is done by using
 
a) Recovery Scenarios.
b) Using “On Error” statement
 
In Recovery scenario you have to define.
1. Triggered Events.
2. Recovery steps.
3. Post Recovery Test-Run.
 
At Script Level you can use the On Error Resume Next and On Error Go to 0 statement.
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.

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.
Quick Test testing process consists of some main phases are :
 
* 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.
 
* 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.
 
* 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.
 
* Replay & Debug : After enhancements you will replay the script to check whether its working properly and debug if necessary.
 
* Run your Tests : In this phase you will perform the actual execution of your Test Script.
 
* Analyzing the test results : Once test run is complete, you will analyze the results in the Test Fusion report generated.
 
* 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.
* The main feature of QTP i.e., “testing only GUI” lead to the upgrade for a newer version of the software.

* QTP contains very big tests, which lead to the consumption of more memory. Due to this, the CPU gets utilized for a longer time and this affects the system’s speed.

* The results of scripts executed in QTP are saved as HTML files instead of text (.txt) files. With this, the size of the result files or group of files will occupy more system space.
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.
There are three kinds of actions :
 
Non-reusable action : An action that can be called only in the test with which it is stored, and can be called only once.

Reusable action : An action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.

External action : A reusable action is stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for external action.
QTP has a unique feature called Smart Object Identification/recognition. QTP generally identifies an object by matching its test object and run-time object properties.
 
QTP may fail to recognize the dynamic objects whose properties change during run time. Hence there is an option to enable Smart Identification, wherein it can identify the objects even if their properties change during run time.
 
Check this out :
If QuickTest is unable to find any object that matches the recorded object description, or if it finds more than one object that fits the description, then QuickTest ignores the recorded description and uses the Smart Identification mechanism to try to identify the object.
 
While the Smart Identification mechanism is more complex and more flexible, thus, if configured logically, a Smart Identification definition can probably help QuickTest identify an object, if it is present, even when the recorded description fails.
 
The Smart Identification mechanism uses two types of properties :
 
Base filter properties : The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object. For example, if a web link’s tag was changed to any other value, then you could no longer call it the same object.

Optional filter properties : Other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.
Object Repository : It displays a tree of all objects in the current component or in the current action or entire test( depending on the object repository mode you selected). We can view or modify the test object description of any test object in the repository or add new objects to the repository.
 
* QuickTest learns the default property values and determines in which test object class it fits. If this is not enough, it adds assistive properties, one by one, to the description until it has compiled a unique description.
 
* If no assistive properties are available, then it adds a special Ordinal identifier such as the object’s location on the page or in the source code.
There are two ways to Spy the objects in QTP :
 
Thru file toolbar : In the File ToolBar, click on the last toolbar button (an icon showing a person with a hat).

Thru ObjectRepository Dialog : In the Object Repository dialog click on the button “object spy…” In the Object, spy Dialog click on the button showing the hand symbol. The pointer now changes into a hand symbol and we have to point out the object to spy the state of the object. If at all the object is not visible or the window is minimized then hold the Ctrl button and activate the required window and release the Ctrl button.
You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during a test run. The recovery scenario manager provides a wizard that guides you through the defining recovery scenario.
 
The recovery scenario has three steps :
 
* Triggered Events
* Recovery steps
* Post-Recovery Test-Run
UFT : Functional, regression, and service testing are the most common uses for the tool. UFT allows testers to automate user behaviours on a web or client-based computer application, as well as test and uncover defects that may arise as a result of such actions. This holds true for the identical operations performed on different people, data sets, Windows operating systems, and browsers. Automation with QTP/UFT, if properly planned and executed, can save a lot of time and money.

Selenium : Selenium is an open-source umbrella project providing a collection of web browser automation technologies and libraries. Without having to learn a test scripting language, Selenium provides a playback tool for building functional tests (Selenium IDE). It also includes a test domain-specific language (Selenese) for writing tests in JavaScript (Node.js), C#, Groovy, Java, Perl, PHP, Python, Ruby, and Scala. Most recent web browsers can then be used to run the tests. Selenium is available for Windows, Linux, and Mac OS X. It's free software distributed under the Apache License 2.0.
Unified Functional Testing (UFT) Selenium 
It is a Micro Focus commercial tool, thus it requires a licence and is costly. It's an open-source testing tool, therefore there's no need for a licence and it's completely free.
It's used for client-server application testing. It can test both web and desktop applications. Only web applications can be automated with Selenium.
Only the QTP IDE can be used to create QTP tests. Selenium can be used with a variety of IDEs, including Visual Studio, Eclipse, and Netbeans.
Only VB scripts are supported by HP UFT. Selenium supports a wide range of programming languages, including Java,.NET, Ruby, Perl, PHP, and many others.
A built-in object repository is included with HP UFT. In HP ALM, creating and maintaining object repositories is a breeze. Although Selenium lacks a built-in object repository, objects can be maintained using the UI element user extension.
HP UFT is compatible with test management software such as HP Quality Center. Selenium is not compatible with any such test management software.
UFT Testing supports all forms of dialogue boxes. It partially supports dialogue boxes.
It supports a variety of environments, including SAP, Oracle, and.NET, but users must acquire an add-on licence for each of them. It allows you to add plug-ins to provide functionalities that Selenium doesn't give by default.
Because of the licencing fees, automation testing is costly. Selenium web automation testing is less expensive.
HP QTP provides excellent technical support. Because it is an open-source project, it receives no formal support.
Only VBScript is supported by HP QTP. Hence Test Automation using an Object-Oriented Approach gets difficult. Selenium supports Object-Oriented Programming Languages such as Java.
HP QTP is more user-friendly, and scripts may be written faster. It's a simple tool with limited capabilities. The development and maintenance of a script take more time.
Backward compatibility has a lot of power. The most recent version of HP ALM supports code that was written five years ago. In Selenium, the API evolves with each new Selenium release. As a result, test scripts must be modified.
The example demonstrated here explains how to read registry key in UFT
Create a shell object

Set MyShell= CreateObject (“WScript.Shell”)

Read the value of key from the registry

RegValue =MyShell.RegRead (varpathofkey)

‘in above function we have to pass the path of key in registery’.

EX : HKCU\software\ie\settings

msgbox RegValue
There are three ways to get system environment variables in UFT
 
Use the WSH shell object
 
* Use WMI’s Win32_Environment Class
* Read variables from the registry
Set myShell = CreateObject (“WScript.Shell”)

WScript.Echo myShell.ExpandEnvironmentStrings( "%PATHEXT%" )

myShell=Nothing,​
Output : .BAT;.CMD;.VBS;. VBE;. JS;. JSE
 
Other user variable, like TEMP, overwrite their system counterpart
Set myShell = CreateObject( "WScript.Shell" )

WScript.Echo myShell.ExpandEnvironmentStrings( "TEMP=%TEMP%" )

myShell=Nothing
Output : TEMP:C:\DOCUME~1\You\LOCALS~1\Temp
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
Code 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 = “FreeTimeLearn” read value from Excel file
TSR means Test Shared Repository, it is created to share object repository.
 
To create TSR file, follow the steps
 
* Open object repository
* Go to file menu
* Go to export local objects option and select it

After that, UFT will ask you to store .tsr file. Give the path and save.  This will create .tsr file in UFT
There are major loops available in UFT :
 
* Do…..Loop : Do Loop will run a block of statements repeatedly
 
* For…..Next : For Next Loop will execute a series of statements until a specific counter value
 
* 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 various ways of handling errors in QTP. There are three possible types of errors, one would encounter, while working with QTP. They are :
 
* Syntax Errors
* Logical Errors
* Run Time Errors
 
Syntax Errors : Syntax errors are the typos or a piece of the code that does not confirm with the VBscripting language grammar. Syntax errors occur at the time of compilation of code and cannot be executed until the errors are fixed.
 
To verify the syntax, use the keyboard shortcut Ctrl+F7 and the result is displayed as shown below. If the window is not displayed one can navigate to "View" → "Errors".

Errors
Logical Errors : If the script is syntactically correct but it produces unexpected results, then it is known as a Logical error. Logical error usually does not interrupt the execution but produces incorrect results. Logical errors could occur due to variety of reasons, viz- wrong assumptions or misunderstandings of the requirement and sometimes incorrect program logics (using do-while instead of do-Until) or Infinite Loops.
 
One of the ways to detect a logical error is to perform peer reviews and also verify the QTP output file/result file to ensure that the tool has performed the way it was supposed to do.
 
RunTime Errors : As the name states, this kind of error happens during Run Time. The reason for such kind of errors is that the script trying to perform something is unable to do so and the script usually stops, as it is unable to continue with the execution. Classic examples for Run Time Errors are −
 
* File NOT found but the script trying to read the file
* Object NOT found but the script is trying to act on that particular object
* Dividing a number by Zero
* Array Index out of bounds while accessing array elements
55 .
What are the different properties of ADODB?
The properties of ADODB include ADODB. Connection, ADODB. Command, ADODB.Fields, and ADODB.Recordset. 
There are various ways to handle run time errors
 
* Using test settings
 
* Using on error statement
 
* Using err Object
 
* Using Exit Statement
 
* Recovery Scenarios
 
* Report Object
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"
58 .
What is GetRoProperty?
GetRoProperty is a standard method of QTP that fetches property values of a run -time object.
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.
An Output Value step is used to capture the value from any field or value of any object property when the script execution is going on. Such values are stored in the desired location in the data table and can be used as input for the other fields or objects at another point in the test script.
 
There are four types of output values, which include :
 
* Standard Output value
* Text or Text Area Output Value
* Database output value and
* XML output value
Generally UFT supports three kinds of features.
 
Direct Features : Features that are built-in with a UFT tool window like Data Table, Object Spy, Step generator etc.

HP Integrated Tools :
These tools can be automatically installed if the UFT is installed. Example : Test Batch Runner, Password Encoder, etc.

Other Integrated Tools :
If we want to use these tools, then a user needs to install them. Example : VB Script, SQL etc.
Step Generator is the most useful and important built-in feature of UFT. It is used to add or create the steps in test scripts without recording. We can even record the disabled objects through the step generator. If we miss any steps during recording, then we can add the same with the help of the Step Generator.
* We cannot automate Test Cases that require human interference.

* Tests that need to be executed repeatedly should be automated.

* Tests that need to be tested with multiple sets of data are automated.

* Test cases are based on requirements that changes repeatedly cannot be automated.

* The newly designed Test Cases are not automated. They should be executed at least once manually.
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.
 
Syntax :
Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]
Whereas
 
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.
Synchronization point is the time interface between Tool and Application under test. Synchronization point is a feature to specify the delay time between two steps of the test script.
 
For example, clicking on a link may load the page is 1 second, sometimes 5 seconds or even it may take 10 seconds to load it completely. It depends on various factors such as the application-server response time, network bandwidth, and client system capabilities.
 
If the time is varying then the script will fail, unless the tester handles these time differences intelligently.
 
There are 4 ways through which we can add synchronisation points in QTP
 
* Wait statement :  This statement will pause the execution for x seconds until object comes up
 
* Wait property : This method will wait until property of object takes particular value
 
* Exist statement : This statement will wait until object becomes available
 
* Sync method : The code will wait until browser page is completely loaded. For web application testing this method is used.
Crypt object in QTP is used to encrypt a strings.
 
Syntax : Crypt.Encrypt(“FreeTimeLearn”)
 
Example :
 
In this example, value in pwd variable is encrypted using the Crypt. Encrypt method.
 
Then this encrypted value is entered into editbox.
pwd= “myvalue”
pwd = Crypt.Encrypt (pwd)
Browser(“myb”).WinEdit (“pwd”). SetSecure pwd
Array can be defined in 3 ways in QTP
 
* Fixed size array in QTP
Dim A (10) – single dimension

Dim MyTable (5,10) – multi-dimension
 
* Dynamic array-size not fixed
 
Dim MyArray()ReDim MyArray(25)
 
* Using Array Function in QTP
A= Array (10, 20,30)

B= A(2) ‘ B is now 30
GetROProperty” is an in built method used to retrieve runtime value of an object property.
 
To use GetRoProperty it involves four steps :
 
Record the object on which you want to use the GetROProperty in Object Repository
 
* Identify the run time property for the recorded object which could be used
 
* To retrieve the identified run time property and store the value in a variable
 
* Use this value for further deductions