50 QTP Interview questions set II


50 QTP Interview questions set II

Question 1. What is your Role and Responsibilities in the Current Company?

A-  My role  is Automation Test Engineer. My responsibilities are to work and handle both the Manual and Automation Activities, around 70% on Automation and 30% on Manual Testing.

My Responsibilities Include …. 1) Selection of Manual Test Cases for Automation.

2) Test Data Generation 3) Developing Automation Framework 4) Writing Generic and Application Specific Functions 4) Running Automation Scripts 5) Maintaining Scripts etc.

Question 2. What are the Tool Evaluation Criteria?

A- Tool Evaluation Criteria based on multiple factors like

1. Types of Environment Support.

2. Different types of Objects Identification.

3. Cost Effective

4. Resource Availability.

5. Ramp Up time

6. Report Mechanism

7. Third Party Application Support.

8. Compatibility with the other technology by providing Object Model Reference.

In addition to this we need to do POC (Proof of Concepts) on multiple selected tools by automating selected Test Cases / Scenarios which are covering all the aspects/functionality of our application or which are touching all the corners of applications.After this POC we can come to specific conclusion that which tool is better and covers most of the above points.

Question  3. How many Automation Scripts you are going to develop per day? OR How many manual Test Cases you are going to Automate per day?

A-Here we have to give diplomatic answer like ..

It depends on various factors like complexity of the Test Case, number of steps required to perform this test case, number of validation steps required, test data required as a prerequisite, all the required function should be in the function library etc.Based on all the above factors we can automate around 2 to 3 complex test cases and 3 to 7 normal test cases per day.

Question  4. What is Automation Object Model Reference in QTP?

A-The way we use QTP for automating the testing of our applications, we can use the automation object model of QTP to automate its own operations as well. With the help of objects, methods, and properties exposed by the automation object model of QTP along with standard programming elements like loops and conditional statements, we can write programs which can configure QTP options and run tests or instead of performing these operations manually using the QTP interface. Automation programs are useful for performing the same tasks several times or on multiple tests or components, or quickly configuring QTP according to the needs for a particular environment or application. Most of the dialog boxes in QTP have a corresponding automation object. Most of the options in dialog boxes can be set retrieved using the corresponding object property.

Question 5. What is the Difference between Action and Function?

A- 1. Action is Application Specific while Function is Generic.

2. Action Support only Primitive Data Type like Number, string, Boolean, date etc while Function supports all types of data type including Object, Arrays etc.

3. Action may return multiple output parameters while function returns only single value.

4. Syntax for calling action is RunAction  <ActionName>,< Iteration>,<[parameters]> while the syntax used for calling the function is call <FunctionName>< (*parameters+,…) >

5. When you save actions it saves its folder structure which contains particular Action folder, repository file , script file etc. but when you save function it saves as a simple textual file with extension either .vbs , .txt or .qfl.

Question 6. Which Manual Test Case’s you Picked as a best candidate for Automation?

A-Usually ,First we  target  all Smoke Test Cases for Automating BVT, and then we are moving towards  all P1 and then P2 test cases.

Question 7. How will you map your Manual Test Cases with Automation?

A-We have a Particular Section of Automation in QC where only those test cases are available which needs to automate. Our manual people selects only those test cases whose Automation status is Non Automated.

Question 8. What is mean by automation Framework? And why we need it?

A-Framework is nothing but set of Process / Practices that everyone in team should follow for the successful execution of Project.

Normal Set of Processes/Practices is…

1. Following Naming Conventions.

2. Used common Function Library across the team members.

3. If needed add the required functions into that function library.

4. Use of Folder Structure.

5. Put comments in your scripts wherever required.

6. Use of Shared Object Repositories.

7. Give proper name to your developed scripts.

8. All the scripts execution result we are either store in Backend

9. Wherever required we are generating the log file while execution of the scripts.

Question  9. Tell me the Different types of Automation Framework?

A-Below are the five different types of framework-

1. Test Script Modularity

2. Test Library Architecture

3. Keyword / Table Driven

4. Data Driven

5. Hybrid

Question 10. What are the different types of Ordinal Identifier?

A- Below are the three ordinal identifiers-

1. By Index – Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description.

2. By Location – Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description i.e. pixel to pixel mapping.

3. By Creation Time (Only with the case of Browser) -Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description.


Question 11. On a Home Page there are two Links both are having same name and most of the properties are identical. If you want to click on the second link how will you do this?

A-I will use index property e.g.

Browser(“title:=Zoho CRM.*”).Page(“title:=Zoho CRM.*”).Link(“name:=ABC”,”index:=0”).click

Question  12. What is Virtual Object? When are you going to use it?

A-If QTP is not able to recognize the object then that object can be identified by virtual object.

We define a virtual object by:

  • Mapping it to a standard class
  •  Marking its boundaries
  • Assigning a parent object
  • Specifying a name to the object

Note: You can define virtual objects only for objects on which QuickTest Professional records Click or DblClick methods. Otherwise, the virtual object is ignored.

Question  13. Consider you have written 200 lines of script, how you will ensure that above 200 lines have successfully executed or not?

 A-We will use error handling in this case. The use of error handling will ensure whether the all the lines are executed or not.

Question  14. Which Scripting Language QTP Support? What is the significance of using Scripting Language? 

A-VB Script. Scripting language is interpreted run time, so no need to compile it.

Question  15. What is static and dynamic array, how to declare it and use it

A-The ReDim statement is used to size or resize a dynamic array that has already been formally declared using a Private, Public, or Dim statement with empty parentheses (without dimension subscripts). You can use the ReDim statement repeatedly to change the number of elements and dimensions in an array.

If you use the Preserve keyword, you can resize only the last array dimension, and you can’t change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension and still preserve the contents of the array.

The following example shows how you can increase the size of the last dimension of a dynamic array without erasing any existing data contained in the array.

ReDim QEWorksLinks(20, 20, 20)

ReDim Preserve QEWorksLinks (20, 20, 25)

Caution If you make an array smaller than it was originally, data in the eliminated elements is lost.

Practical Use: I want to store all the available links on the On Line Shoppe page in an array, But I am not aware of how many links that On Line Shoppe Page is having. In that case I will use dynamic array.

Question 16. What is DP or Descriptive Programming?

A-DP means without using any type of Object Repository. There are two types of DP

  • Static-For example,

‘open the Flight application
Invokeapplication”C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe”
‘Enter the Login id, pwd and Click the OK button.
Dialog(“text:=Login”).WinEdit(“attached text:=Agent Name:”).set”abcd”

  • Dynamic-For example, instead of entering:

Dialog(“Login”).WinEdit(“attached text:=Agent Name:”,”Index:=0″).set”abcd”

Set MyDescription = Description.Create()
MyDescription(“attached text”).Value = “Agent Name:”
MyDescription(“Index”).Value = 0

Question 17. How to Send Keyboard Input to an Application using QTP and VBSCript?

A-The example below uses the PressKey method to send keyboard input to an application.

  1. An example that presses a key using DeviceReplay. Set obj = CreateObject(“Mercury.DeviceReplay”) Window(“Notepad”).Activate obj.PressKey 63 The PressKey method uses the ASCII value for the key. 63 is the ASCII value for F5. Simply use ASC(“F5”) ASCII values for other keys: F1 – 59 , F2 – 60 , F3 – 61 , F4 – 62 ,F5 – 63 ,F6 – 64 ,F7 – 65 ,F8 – 66 ,F9 – 67 ,F10 – 68 ,F11 – 87 ,F12 – 88 etc

2.    An Example that presses key using WScript.Shell Object

set Wsh=CreateObject(“WScript.Shell”

Wsh.SendKeys {F5}

Here we are pressing the key functional key F5.

Question 18.  Write down a QuickTest Professional script for Message Boxes That Close Automatically? 

A-The function below shows a message box that disappears after the specified timeout (in seconds). The script execution then continues.

Public Sub MsgBoxTimeout (Text, Title, TimeOut)

Set WshShell = CreateObject(“WScript.Shell”)

WshShell.Popup Text, TimeOut, Title

End Sub If TimeOut is 0, it behaves just like a normal message box. If TimeOut is greater than 0, the dialog box disappears after the specified number of seconds.

 Question19. How to read PDF file using QTP?

A-There are two methods to do it: 1. You can use a 3rd party API for that. 2. Other method to use some DOS tools like PSVIEW which can convert PDF image to text. For third party API: If you have Acrobat Writer installed you use ArcoExch object to manipulate pdf files.

Function GetPDFPageCount(filename)

Dim pdfFile,Acroapp,pdf

‘PDF File preparations

Set Acro = CreateObject(“AcroExch.App”)

Set pdf = CreateObject(“AcroExch.PDDoc”)

pdf.Open filename,”temp”

Set pdfFile = pdf.GetPDDoc

GetPDFPageCount = pdfFile.GetNumPages

Set pdffile = nothing


End Function

Question 20. What is a Run-Time Data Table in QTP?

A-During the run session, QTP creates a Runtime Data Table, which is live version of the Data Table associated with our test. During the run session, QTP displays the run-time data in the Data Table pane so that we can see the changes taking place in the DataTable. When the run session ends, the Runtime Data Table closes, and the Data Table pane again displays the stored design-time Data Table. Data entered in the run-time DataTable during the run session does not get saved along with the test. The final data from the run-time Data Table gets displayed in the Run-Time Data Table in the Test Results window. Runtime Data Table is an excel file, which gets stored in the folder of the test created, its name is Default.xls by default.

Question 21. Working with File System Objects.
A-The following code displays how to create an instance of the FileSystemObject : Dim fso

set fso = CreateObject(“Scripting.FileSystemObject”)

In both of these examples, Scripting is the name of the type library and FileSystemObject is the name of the object that you want to create. You can create only one instance of the FileSystemObject object, regardless of how many times you try to create another.To gain access to an existing file:Dim fso, f1

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set f1 = fso.GetFile(“c:\test.txt”)
To set a variable to the CreateFolder function, use this syntax:
Public Sub CreateFolder Dim fso,fldr
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set fldr = fso.CreateFolder(“C:\QEworks”)
msgbox “Created folder: ” & fldr.Name
End Sub
To use GetFolder method:
Set fldr = fso.GetFolder(“c:\”)
Now that you have a handle to a Folder object, you can check its Name property.
msgbox “Folder name is: ” & fldr.Name
To find out the last time a file was modified, use the following syntax:
Dim fso,f1
Set fso = CreateObject(“Scripting.FileSystemObject”)
‘Get a File object to query.
Set f1 = fso.GetFile(“c:\detlog.txt”)
‘ Print information.
msgbox “File last modified: ” & f1.DateLastModified

Question 22. How to normalize the string?
A-The QE_Normalizestr function receives a string and returns the equivalent string in a regular expression.

Function QE_Normalizestr(OrgStr)
Dim TempStr
TempStr = Replace(OrgStr, “\”, “\\”)
TempStr = Replace(TempStr, “*”, “\*”)
TempStr = Replace(TempStr, “+”, “\+”)
TempStr = Replace(TempStr, “.”, “\.”)
QE_Normalizestr= Replace(TempStr, “?”, “\?”)
End function

msgbox QE_Normalizestr(“a+b*c.d?e”)

Question 23. How will you automate a window which while spying is not returning any property value?
A-In QTP point of view we automate applications where there is proper add-in. There are few cases where we can use win32 API and shell programming to achieve. In some cases we can use virtual object as well.

24. How do you find the color and font of all the links on the page?
A- By using below

set obj= Browser(“name:=MyQEworks”).Page(“Title:=QTP).Link(“name:=English:).object
msgbox obj.currentstyle.currentStyle.backgroundColor
msgbox obj.currentstyle.currentStyle.fontSize
msgbox obj.currentstyle.currentStyle.fontStyle
msgbox obj.currentstyle.currentStyle.fontFamily
msgbox obj.currentstyle.currentStyle.fontWeight

25. what are the disadvantages of smart identification.?

A-It is more time consuming and some time it yields wrong results also in case of dynamic environment.

26. How can you execute javascript on qtp?
A-HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\ScriptMgr
Create a new String value with name AltProgID and value “Mercury.JSScriptMgr” and change the value of “Create” to 1 Create a new child key inside the key HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\ScriptConstants {0ECD5785-BE7D-11d4-8EAF-11135659EC56}
Repeat the same steps for the below key HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration

Open C:\Program Files\Mercury Interactive\QuickTest Professional\bin\QTEditor.ini Add the below parameter to [General options] AllowJavaScript = 1 DisableVBScript = 1

27. Can we record a web based application on Mozilla?
A-You can record a web based application only on Internet Explorer and run it on either IE or Mozilla. If you perform record operation on Mozilla then it will treat it as a Window or WinObject as when QTP not able to recognize the objects it records those objects either as a window or winobject.
ex: Window(“Mozilla Firefox”).WinObject(“MozillaWindowClass”).Type “naveen”

28. How to copy Virtual Object Manager from one computer to another computer?
A-Checkout for .VOT files in dat foler of the installation

29. Can we use GetRoProperty method to get index or location of link in web application?

30. What is Analog recording, what is the difference between analog recording and low level recording?
A-Analog Recording. Enables you to record the exact mouse and keyboard operations you perform in relation to either the screen or the application window. In this recording mode, QuickTest records and tracks every movement of the mouse as you drag the mouse around a screen or window.
This mode is useful for recording operations that cannot be recorded at the level of an object, for
example, recording a signature produced by dragging the mouse.
Note: You cannot edit Analog Recording steps from within QuickTest.

Low Level Recording. Enables you to record on any object in your application, whether or not QuickTest recognizes the specific object or the specific operation. This mode records at the object level and records all run-time objects as Window or WinObject test objects. Use low-level recording for recording in an environment or on an object not recognized by QuickTest. You can also use low-level recording if the exact coordinates of the object are important for your test.
Note: Steps recorded using Low Level Recording mode may not run correctly on all objects.

31. How to perform Cross platform testing and Cross browser testing using QTP? Can u explain giving some example?
A-Our application support multiple Windows OS, Multiple DB Server , Multiple Web or Application Server and Multiple Browser, so we have a test bed set up for the multiple combinations of OS, DB Server, App Server/Web Server and Browser used by the customer.
QTP is installed on all those boxes and by using our Customized .NET application we are running our Automation suites on all those boxes.
We have written Execution Script Result Logging Function which passes all the information in the xml file like HostName , Logged In User Name, OS Name, DB Server Name, Passed Fail Result,Test Case name, Reason for Pass or Fail etc.
In order to Launch QTP on multiple Hosts we used VBScript CreateObject method and passed the QTP Object and Machine IP Address as a parameter. Out customized .NET tool was launching QTP on passed Host Name.

32. If an application name is changes frequently i.e while recording it has name “Win1” and then while running its “Win56” in this case how does QTP handles?
A-QTP handles those situations using “Regular Expressions”.

35. How to add a runtime parameter to a datasheet?
A-DataTable.LocalSheet The following example uses the LocalSheet property to return the local sheet of the run-time Data Table in order to add a parameter (column) to it. MyParam=DataTable.LocalSheet.AddParameter(“Time”, “5:45″)

36. Uninstall a software using vbscript , QTP?
A-This works for uninstalling most applications. In this example I will show how AutoCAD 2005 can be uninstalled using a VBScript.

Open Regedit and look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall search for the application and find a the product code that is in GUID format looking like this: {5783F2D7-0301-0409-0002-0060B0CE6BBA} It might be something else for you. The code below will uninstall AutoCAD 2005 as well as Express Tools.
Copy the code below into Notepad and give the file the extension vbs.
on error resume next
Set WshShell = CreateObject(“WScript.Shell”) ‘ Uninstall Express Tools
WshShell.Run “msiexec /x {5783F2D7-0311-0409-0000-0060B0CE6BBA} /q”,1,true ‘ Uninstall AutoCAD 2005
WshShell.Run “msiexec /x {5783F2D7-0301-0409-0002-0060B0CE6BBA} /q”,1,true

37. How to Create tables in MS Word? How to create tables in Microsoft word?
A-Set objWord = CreateObject(“Word.Application”)
const END_OF_STORY=6
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.TypeText “QETable”
Set objRange = objSelection.Range
objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(1)
objTable.Cell(1, 1).Range.Text = “This is cell 1.”
objTable.Cell(1, 2).Range.Text = “This is cell 2.”
objSelection.EndKey END_OF_STORY
objSelection.TypeText “QETable1”
Set objRange = objSelection.Range
objDoc.Tables.Add objRange, 1, 2
Set objTable = objDoc.Tables(2)
objTable.Cell(1, 1).Range.Text = “This is cell 1.”
objTable.Cell(1, 2).Range.Text = “This is cell 2.”
objSelection.EndKey END_OF_STORY

38. How to get the ASCII values for characters?
A-In the following example, Asc returns the ANSI character code of the first letter of each string:
Dim MyNumber MyNumber = Asc(“A”)
‘ Returns 65.
MyNumber = Asc(“a”)
‘ Returns 97.
MyNumber = Asc(“Apple”) ‘ Returns 65.

39. How to get Character fron ASCII value?
A-Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character.
The following example uses the Chr(type casting function) function to return the character associated with the specified character code:
Dim MyChar
MyChar = Chr(65) ‘ Returns A.
MyChar = Chr(97) ‘ Returns a.
MyChar = Chr(62) ‘ Returns >. MyChar = Chr(37) ‘ Returns %.

40. How to Access User-Defined Properties of Web Objects?
A-You can use the <property name> notation to access native properties of Web objects and use these properties to identify such objects with programmatic descriptions.

41. How to run VBS file from Command prompt?
There are several applications available for running automation programs. You can also run automation programs from command line using Microsoft’s Windows Script Host. For example, you could use the following command line to run your automation program: WScript.exe /E:VBSCRIPT myScript.vbs

42. What is the other way of making comments instead of single quote(‘) ?
A- “QEworks” : Rem Comment after a statement separated by a colon.

43. How to run commands in command prompt from qtp?
A-You can run standard DOS commands in your QuickTest test using the VBScript Windows Scripting Host Shell object (WSCript.shell).
For example, you can open a DOS command window, change the path to C:\, and execute the DIR command using the following statements:
Dim oSh
Set oSh = CreateObject (“WSCript.shell”)
oSh.run “cmd /K CD C:\ & Dir”
Set oSh = Nothing

44. what is optional step in QTP and when we can use it?
A-Causes a step to be bypassed if an object in that step is not found.

The following example uses the OptionalStep object to make the London selection from the Depart WebList an optional step.
OptionalStep- Browser(“Mercury Tours”).Page(“Find Flights”).WebList(“depart”).Select “London”

45. What is the alternative way to getROproperty?
A-object.QueryValue(property to get)
e.g. msgbox Browser(“title:=Zoho.*”).QueryValue(“name”)

46. How to get the number of childs in a tree ?
a) Object.children.lengthex: msgbox Browser(“xxx”).Page(“xxx”).Image(“xxx”).Object.children.length

47. What are the different ways to delay the execution steps in QTP?
A-There are 3 different ways

1) object.waitProperty ”propertyName”,”value”,”time in milli sec”
e.g. VBWindow(“name:=Login”).Activex(“name:=Actx”).WaitProperty(“text”,”Insert done…”,45000)
This is called conditional wait This will pauses the execution as long as the specified value of the property exist in the AUT or specified time out whichever is earlier

2) Wait(seconds)
e.g. wait(45) This is called unconditional wait.i.e it will wait for the specified time

3) Services.ThinkTime 10 Same as wait

48. How to minimize QTP while running?
A- Set qtApp = CreateObject(“QuickTest.Application”) qtApp.WindowState = “Minimized” Set qtApp = Nothing

49. Explain the check points in QTP?
A checkpoint verifies that expected information is displayed in a Application while the
test is running. You can add eight types of checkpoints to your test for standard web
Objects using QTP.

  • A page checkpoint checks the characteristics of a Application
  • A text checkpoint checks that a text string is displayed in the appropriate place on a Application.
  • An object checkpoint (Standard) checks the values of an object on a Application.
  • An image checkpoint checks the values of an image on a Application.
  • A table checkpoint checks information within a table on a Application
  • An Accessibility checkpoint checks the web page for Section 508 compliance.
  • An XML checkpoint checks the contents of individual XML data files or XML documents that are part of your Web application.
  • A database checkpoint checks the contents of databases accessed by your web site

Question 50.There is a excel file of 1 to 100 sheets how you will iterate through it?
A. R