QTP10.com is a new and completely free website that offers help in all the versions of HP QTP (including latest version 10). More importantly, it offers free code for users of HP QuickTest Professioal. This site helps you in learning the basics of QTP and descriptive/advanced programming in (QTP) on various environments like - .Net, Infragistics, Web, Windows, etc.

Note -
This blog is NOT affiliated with HP / Hewlett-Packard in any way. The data/questions come from various sources and we have our own testing questions. I am just another Software Tester like you.

QTP Interview Questions and Answers - Part 2

Share This Post -

Sponsored Links:

Which scripting language used by QTP?
Most of the newbie are confuse about this. In many place you will find that QTP uses VBscript, java script and other scripting language.


Actually QTP is using only one language VB script. But it also provide access to its functions and properties thorough it object. That means you can use any other scripting language to access the QTP, but then you will not get the any benefit of its recording technique and other facilities provided by tool.


How many types of recording facility are available in QTP?
QTP provides three types of recording methods
a. Context Recording (Normal)
It's by default option.

b. Low Level Recording


This records somewhat more events than the above one. for example, suppose there is a application with Editbox that requires some input. So if you are using normal recording it will only record the charcter keys only and at one after you press TAB or after you start any other event. But if you are using Analog recording it will recorded some of non charcter keys too, like backspace Left Arrow, Right Arrow, etc...


This is generally used when you are not able to record any of the object properly or when you want to record other events too.


c. Analog Recording
this is much more sensitive then above two. Means it is recording much more events than above two. Suppose if you have a application like MS paint and you want to record some drawing with mouse you will not be able to do this with the above two. You require this option to enable.


There is a problem with this kind of recording that you will not be able to edit it once it will be recorded.


What is Page checkpoint and How to add a page checkpoint to your test?
The page checkpoint checks that the number of links and images in the page when you run your test is the same as when you recorded your test.


a. Locate the page where you want to add a page checkpoint.
b. Create a page checkpoint.
Right-click anywhere in the Active Screen, and choose Insert Standard Checkpoint. The Object Selection - Checkpoint Properties dialog box opens. Note that this dialog box may include different elements, depending on where you click in the Active Screen.
c. Save the test.


What is the Diff between Image check-point and Bit map Check point?
Image Checkpoints checks the properties of the image and not the Actual image. So Through image check points you can verify it index, ALT Tag, URL of the image.


While the Bitmap check points actually checks the image Comparing bit by bit. Through this you can check the whole image or part of the image.


How to close all the Internet explorer windows and their dialog boxes
SystemUtil.CloseProcessByName("IEXPLORE.exe")


How to open the browser through script?
a) To open Firefox
SystemUtil.Run "firefox.exe", URL, , , SHOW_MAXIMIZED


b) To open Internet Explorer
SystemUtil.Run "iexplorer.exe", URL, , , SHOW_MAXIMIZED
How to retrive the whole text of the page ?
var = Browser("title:= title").page("title:=title").Object.documentElement.innertext
OR
var = Browser("title:= title").page("title:=title").WebElement("html tag:=BODY").getROProperty("innertext")
How to add array and retrieve the Dictionary Object ?
Function DicDemo
Dim a, d, i, s, arr(2) ' Create some variables.
Set d = CreateObject("Scripting.Dictionary")
arr(0)=0
arr(1)=1
arr(2)=2
d.Add "Arr", arr
a = d.Items ' Get the items.
newarr=a(0)
For i=0 to ubound(newarr)
msgbox newarr(i)
Next
End Function
Call DicDemo
How to retrieve the static text of the Dialog Box
Dialog("text:=MyWindow").Static(nativeclass:=Static").GetROProperty("text")


OR


Dialog("text:=MyWindow").Static(nativeclass:=Static","Index:=0").GetROProperty("text")
How to store the double quoted text in the variable ?
strname= """puneet"""
msgbox strname
strname= chr(34)&"puneet"&chr(34)
msgbox strname


How to close all the opened browsers ?
While Browser("CreationTime:=0").Exist
Browser("CreationTime:=0").Close
Wend


Creation time is a special property associated with the Browser Object. The value of this property show the order in which the browser has opened. The First Browser that opens receives the Value 0. And so when you close the first Browser the value of this property in all the browser decrease by 1.


What is the file extension of the code file & object repository file in QTP?
Ans) for object repositories file the extension is .tsr
for code file the extension is .vbs


Explain the concept of object repository & how QTP recognizes objects?
Ans) Object Repository: 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 to add new objects to the repository.


QTP learns the default property values and determines in which test object class it fits. If it is not enough it adds assistive properties, one by one to the description until it has compiled the unique description. If no assistive properties are available, then it adds a special Ordinal identifier such as objects location on the page or in the source code.
What are the properties you would use for identifying a browser & page when using descriptive programming in QTP?


Ans) Title is the property we use.ex: Browser("Title:="xxx").page("Title:="xxxx").....
"Name" would be another property apart from "title" that we can use.


Ex: Browser ("name:="xxx"").page("name:="xxxx"").....
What are the different scripting languages you could use when working with QTP?


Ans) Visual Basic Script,XML,JavaScript,Java,HTML
Give me an example where you have used a COM interface in your QTP project?


[as per your project]


Explain the keyword createobject with an example.
Ans) Creates and returns a reference to an Automation object . create object creates handle to the instance of the specified object so that we program can use the methods on the specified object. It is used for implementing Automation(as defined by microsoft).


Explain in brief about the QTP Automation Object Model.
Ans) Essentially all configuration and run functionality provided via the QuickTest interface is in some way represented in the QuickTest automation object model via objects, methods, and properties. Although a one-on-one comparison cannot always be made, most dialog boxes in QuickTest have a corresponding automation object, most options in dialog boxes can be set and/or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods.
You can use the objects, methods, and properties exposed by the QuickTest automation object model, along with standard programming elements such as loops and conditional statements to design your program


What are the Features & Benefits of Quick Test Pro(QTP)..?


Ans) Operates stand-alone, or integrated into Mercury Business Process Testing and Mercury Quality Center.
Introduces next-generation “zero-configuration” Keyword Driven testing technology in QuickTest Professional  — allowing for fast test creation, easier maintenance, and more powerful data-driving capability
Identifies objects with Unique Smart Object Recognition, even if they change from build to build, enabling reliable unattended script execution
Collapses test documentation and test creation to a single step with Auto-documentation technology
Enables thorough validation of applications through a full complement of checkpoints


How to handle the exceptions using recovery scenario manager in QTP?
Ans) You can instruct QTP to recover unexpected events or errors that occurred in your testing environment during test run. Recovery scenario manager provides a wizard that guides you through the defining recovery scenario. Recovery scenario has three steps
1. Triggered Events
2. Recovery steps
3. Post Recovery Test-Run


What is the use of Text output value in QTP?
Ans) Output values enable to view the values that the application takes during run time. When parameterized, the values change for each iteration.Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.


13) QTP pros and cons
Ans) Pros:

• Ease of use.
• Simple interface.
• Presents the test case as a business workflow to the tester (simpler to understand).
• Numerous features.
• Uses a real programming language (Microsoft’s VBScript) with numerous resources available.
• QuickTest Pro is significantly easier for a non-technical person to adapt to and create working test cases, compared to WinRunner.
• Data table integration better and easier to use than WinRunner.
• Test Run Iterations/Data driving a test is easier and better implement with QuickTest.
• Parameterization easier than WinRunner.
• Can enhance existing QuickTest scripts without the “Application Under Test” being available; by using the ActiveScreen.
• Can create and implement the Microsoft Object Model (Outlook objects, ADO objects, FileSystem objects, supports DOM, WSH, etc.).
• Better object identification mechanism.
• Numerous existing functions available for implementation – both from within QuickTest Pro and VBScript.
• QTP supports .NET development environment (currently WinRunner 7.5 does not).
• XML support (currently WinRunner 7.5 does not).
• The Test Report is more robust in QuickTest compared to WinRunner.
• Integrates with TestDirector and WinRunner (can kick off WinRunner scripts from QuickTest).


Cons:
• Currently there are fewer resources (consultants and expertise) available due to QTP being a newer product on the market and because there is a greater Demand than Supply, thus fewer employee/consulting resources.
• Must know VBScript in order to program at all.
• Must be able to program in VBScript in order to implement the real advance testing tasks and to handle very dynamic situations.
• Need training to implement properly.
• The Object Repository (OR) and “testing environment” (paths, folders, function libraries, OR) can be difficult to understand and implement initially.

 

Related posts:

QTP Interview Questions and Answers - Part 1