Thursday, June 24, 2010

QTP(Quick Test Pro) Interview Asked Technical Questions



QTP(Quick Test Pro) 

Interview Asked Technical Questions.




1)   What is Recovery Scenario? How many types of exceptions it can handle?
Ans:   Recovery Scenario is used for handling unexpected error during the test run. There are       mainly three steps in RS.
          Selecting Trigger Event, Selecting Recovery Step and Post Recovery Step.
          User can select following four types of trigger:
l  Pop-up window.
l  Object State changes (Property of object changed).
l  Test Run Error.
l  Application Crash.

Selecting Recovery Step, there are four types:
l  Keyboard or mouse operation.
l  Close Application Process.
l  Function Call.
l  Restart Windows.
         
Post Recovery Steps:
l  Repeat current step and continue.
l  Proceed to next step.
l  Proceed to next action.
l  Proceed to next action iteration.
l  Restart current test run.
l  Stop the test run.


2)   What is the difference between Recovery Scenario ans On Error Resume Next statement?
Ans:   Recovery Scenario is used to handle unexpected exception, the exceptions which we cannot           assume that at which place they will occur.
          Whereas “On Error Resume Next” statement is used where we are expecting an exception and we want to ignore the error, it is used to Enable/Disable Error Handling.


3)   What are the exceptions when Recovery Scenario will not be invoked?
Ans:   There are some of the cases where RS will not work.
l  Script Error: Error is not involving any Test Object won't fire RS like below code.
l  Example1 : X=2/0
l  Example2 : y=left(“Test”),-2)
l  Object not in object repository.
l  Modal dialog blocking execution, like msgbox “test”.
l  Associated library not found.
l  RS settings are not proper- Run->Setting->Recovery (Tab).

4)   How many types of actions are there in QTP?
Ans:   There are three types of actions are there in QTP.
l  Non-Reusable Action: can not called from other actions.
l  Reusable Action: can be called from other actions.
l  External Action: actions which is called from external test script.

5)   Types of Framework and describe the framework which you are using.
Ans:   There are basically three types of Frameworks used in QTP Automation.
l  Keyword Driven Framework: This framework provides generic keywords that can be used with any type of application. It also provides abstraction from the type of automation tool used and type of being application tested, e.g. - it can test a similar Web and Windows application with the same test case.
l  Data Driven Framework: Used when flow of the application remains constant, only the data changes. The data is provided by external medium e.g. - excel sheet, XML etc…
l  Hybrid Framework: A hybrid framework is the one which takes advantages from both Data Driven and keyword driven frameworks. These frameworks do not implement generic keywords but implement business logic keywords based on the application being tested. For ex – Login, Logout could be application specific keyword that can be used.

          The Framework which we use is a Hybrid framework and consists of mainly 7           components/folders.
          Lib- contains Library files.
          Env- contains XML files for Environment variable.
          RA- contains Re-usable actions.
          Settings- contains vbs file for qtp run time setting and reserved object.
          Dat- contains xls file for inputing data.
          ORep- contains shared object repository.
          Test- contains main scripts and calls RA and library functions.

6)   What is Descriptive Programming and what are the ways to do descriptive programming?
Ans:   Description Programming is used when we objects are not present/exist in the object
          Repository or we don't want to add object in OR, rather than this we want to describe the object properties programmatically.
          There are two ways to do Descriptive Programming.
l  By creating Description Object:
Example:
Set obj=description.create()
obj(“type”).value=”CheckBox”
set b=browser(“”).page(“”).frame(“”).childobjects(a)
c=b.cout 'to count total checkboxes in the frame

l  By manually assigning object description as string argument:
          Example:
          browser("micclass:=Browser").page("micclass:=Page","title:=Global Sales           Accounting").frame("name:=main").WebCheckBox(“chk1”).click

7)   What is Fusion Report?
Ans:   Fusion Report is nothing but a Result(XML,HTML file) generated by qtp after the execution          of the     test.
          Test Fusion Report displays all aspects of the test run: a high-level results overview,an       expandable Tree View of the test specifying exactly where application failures occurred, the      test data used, application screen shots for every step that highlight any discrepancies, and detailed explanations of each checkpoint pass and failure.

8)   Syntax of reporter.report event statement.
Ans:   Reporter.reportevent micpass,”Step Name”,”description”
          Reporter.reportevent micfail,”Step Name”,”description”



9)   What is COM? And which COM objects you use in scripting?
Ans:   Microsoft COM (Component Object Model) technology in the Microsoft Windows-family of    Operating Systems enables software components to communicate. COM is used by developers   to create re-usable software components.
          Some COM components we use in scripting are:
l  Scripting.FileScriptingObject.
l  ADODB.Connection.
l  Excel.Application.
l  Wscript.Shell
         
10) How many Checkpoints are there, describe each checkpoint.
Ans:   There are total 8 types of checkpoints available in QTP.
l  Standard Checkpoint.
l  Bitmap Checkpoint.
l  Page Checkpoint.
l  Text Checkpoint.
l  Text Area Checkpoint.
l  Accessibility checkpoint.
l  XML checkpoints.
l  Database checkpoint.


11)What is Smart Identification Mechanism in QTP and how does it work?
Ans:   Smart Identification is a mechanism used when qtp unable to identify the recorded object   based on its recorded 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.
          We can disable Smart Identification during test run in Test Setting-> Run(Tab)

12) How many types of parameter are there in QTP?
Ans:   There are four types of parameters are there in QTP
l  Action Parameter.
l  Data Table.
l  Random Number.
l  Environment Variable.

13) Difference between call to existing action and call to copy of action.
Ans:   Call to Existing action will create a copy of called action in Read only mode and user cann't           modify it.
          Call to Copy of action creates a copy in current test and user can modify it.


14) How will qtp recognize two objects with same name?
Ans:   QTP doesn't allow to store two objects with same name.

15) Syntax on importing data sheet in datatable.
Ans:   To Import whole excel – datatable.import(“path”)
          To import particular sheet – datatable.importsheet(“path”,”sheetname”)


16) Types of object repositories in QTP?
Ans:   There are two types pf Object repositories are there in QTP mentioned below.
          Per Action Object Repository-> Accessible to the action only.
          Shared Object Repository-> Accessible to all actions and most recommended.


17) What is Object Spy and why it is used?
Ans:     Object spy is used for viewing object properties, the Object Spy also enables you to view     both the run-time object methods and the test object methods associated with an object       and to view the syntax for a selected method.


18) What is Virtual Object?
Ans:   There are some of the objects in our application which behaves like a standard object but   don't recognize by QTP, so these kind of object we can define as virtual objects and map   them to standard classes, such as button or checkbox.

19) What is Test Object and what is the difference between Test Object and Run Time Object.
Ans:   Test objects are the objects in your test that represent the objects in your website or           application. Runtime objects are the objects in your application during the test run.
          The Test object properties set is created and maintained by QuickTest. The Runtime        object           property set is created and maintained by the object creator (Microsoft for    Internet        Explorer objects, Netscape for Netscape objects, the product developer for       ActiveX         objects, etc.).

          Similarly, Test object methods are methods that QuickTest recognizes and records when     they are performed on an object while you are recording a test, and that QuickTest    performs when your test runs. Runtime object methods are the methods of the object in      your application as defined by the object creator(the developer!). You can access and        perform runtime object methods using the Object property



20) What is Synchronization and difference between Synchronization Point and Wait statement.
Ans:   If you don't want qtp to perform a step or checkpoint until and object achieves a certain     property, you should insert a Synchronization point to instruct qtp to pause the test or components until the object property value is not achieved.
          There is a slight difference between Synchronization and wait, please read the example:
          Synchronization-> Window("Calculator").WinButton("8").WaitProperty "enabled", True, 10000
          Wait-> wait(10)
          Above in Synchronization qtp wait for 10 seconds and one enabled property is achieved qtp           won't wait anymore and will go to next step.
          Whereas in wait statement we force qtp to wait for 10 seconds it will go to next statement          only after 10 seconds
         


21) What is Randomization and one example of Randomization.
Ans:   Randomize is a function used to initialize rnd function(rnd function generates random      number >=0 to <1 in vbscript).
          Example:
          Dim MyValue, Response
          Randomize   ' Initialize random-number generator.
          Do Until Response = vbNo
             MyValue = Int((6 * Rnd) + 1)   ' Generate random value between 1 and 6.
             MsgBox MyValue
             Response = MsgBox ("Roll again? ", vbYesNo)
          Loop
         

22) What is Low Level Recording ,why it is used?
Ans:   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 or component.
          Qtp will store the recorded objects as WinObject.

23) Difference between InvokeApplication and SystemUtil.Run method.
Ans:   SystemUtil is an object which is used to control the application and processes during run    session. Run is one if the methods of Systemutil object to run the application.
          Syntax: systemutil.run file,[param],[dir],[op],[mode]
                   systemutil.run “test.tct,””,”c:\”,”Open”,”1”
          Example using Param:
                   systemutil.run “iexplore.exe”,”http://google.com
         
          InvokeApplication method can open only executable files and used primarily for      backward compatibility.
          Syntax: Invokeapplication “command”,[working folder to which command path refers]
          Example:
                   invokeapplication “\Program Files\Internet Explorer\iexplore.exe”,”c:”

24) Function to find Day of the week.
Ans:   weekdayname(date)
          code to find date of first day of current week:
          dateadd(“D”,-(weekday(date)),date)


25) What is QTP Object Model?
Ans:   You can use the QuickTest Professional Automation Object Model to write programs that      automate your QuickTest operations. The QuickTest Automation Object Model provides objects, methods, and properties that enable you to control QuickTest from another    application.
          The new QuickTest Professional Automation Object Model enables you to automate QTP       itself.
          Example:
          Dim App ‘As Application

          ‘ Launch QTP
          Set App = CreateObject(“QuickTest.Application”)
          App.Launch
          App.Visible = True

          ‘ Load an INI file with user-defined parameters
          App.Test.Environment.LoadFromFile “C:\Test_Params\environment_file1.ini” ‘ Set the value         of a specific user-defined Environment variable
         
          App.Test.Environment.Value(“newvariable”) = “new value”
          App.Test.Settings.Resources.Libraries.RemoveAll
          App.Test.Settings.Resources.Libraries.Add("E:\Automation\OMS\LIB\OMS.vbs")
          App.Test.Environment.LoadFromFile("E:\Automation\OMS\ENV\OMS.xml")
          Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results     Options object
          qtResultsOpt.ResultsLocation = "E:\Automation\OMS\RES" ' Set the results location

26) Types of Data Table in QTP.
Ans:   There are two types of data table available in QTP, namely.
l  Global data table.
l  Local data table or Per Action data table.

27) What is Object Repository Manager?
Ans:   The Object Repository Manager enables you to manage all of the shared object repositories           used in your organization from a single, central location, including adding and
          defining objects, modifying objects and their descriptions, parameterizing repositories to   make them more generic, maintaining and organizing repositories, merging repositories,
          and importing and exporting repositories in XML format.

          Each object repository contains the information that enables QuickTest to identify the        objects in your application. QuickTest enables you to maintain the reusability of your
          tests by storing all the information regarding your test objects in a shared object repository.           When objects in your application change, the Object Repository Manager provides a
          single, central location in which you can update test object information for multiple tests.


28) What is the use of “With” statement?
Ans:   With statement allows us to follow the series of statements without re-qualifying the object         or execute a series of statements on a single object.
          Example:
          with browser(“name”).page(“name”).frame(“name”).webbutton(“name”)

                             a=.getROproperty(“Enabled”) 'to get enable property
                             b=.getROproperty(“value”) ' to get value
                                 .click ' to click on webbutton
          End with


29) What is Dictionary Object and what is the use of Dictionary Object?
Ans:   Dictionary object is similar to typical array which can store AlphaNumeric values.
          Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually a integer or a string,       but can be anything except an array.
          Example:
          Dim dict ‘ Create a variable.
          Set dict = CreateObject(”Scripting.Dictionary”)
          dict.Add “Company”, “HP”           ‘ Adding keys and corresponding items.
          dict.Add “Tool”, “QuickTest Pro”
          dict.Add “Website”, “LearnQTP”
          dict.Add “Country”, “India”
         
          msgbox dict.item("Company")


30) How does QTP stores Objects in QTP and types of properties QTP stores.
Ans:   QTP stores objects in object repository with mandatory and assistive properties and ordinal           identifier like Index,Location and CreationTime(only for browser object).
          There are two types of object repositories are there in qtp Per Action OR and Shared OR.


31) Use of StrComp, InStr Functions and their return values.
Ans:   StrComp function is used for comparing two strings.
          Syntax: strcomp(“string1”,”string2”)
          Return values:
          0 if string1 is equal to string2.
          -1 if string1 is less than string2.
          1 if string1 is greater than string2.
          null if string1 or string2 is null.
          Instr function is used for finding the position of the first occurrence of one string within     another.
          Syntax: instr(start,”string1”,”string2”)
          Return values:
          If string2 is found in string1 then position at which string found.
          If string is not found then 0.
          if string1 is of 0 length then 0.
          if either of strings is null then null.
         


32) How can we execute a particular piece of code/statements in QTP?
Ans:   We can use Run From Step option to execute the code from desired step and it will execute        the code up to the end of the current action or if we want to stop the execution on a     particular step then we can use ExitAction or ExitTest statement.




33) How can we count total number of checkboxes on a webpage and check all the checkboxes without adding all the checkboxes in object repository?
Ans:   We have to create description object for that, below is the example.
          Set a=Description.Create
          'a("html tag").value="input"
          a("type").value="checkbox"
          Set b=Browser("Global Sales Accounting").Page("Global Sales           Accounting").Frame("main").childobjects(a)
          c=b.count        'count the total number of checkboxes
          msgbox c
          For i=0 to c-1
          ' to check name of the each checkbox
          msgbox b(i).getroproperty("html id")
          b(i).set "on"
          Next


34) Step Into, Step Out, Step Over debugging techniques and how do they work?
Ans:   Step Into:- Choose Debug > Step Into, click the Step Into button, or press F11 to run only the           current line of the active test or function library. If the current line of the active test or     function library calls another action or a function, the called action/function is displayed in   the QuickTest window, and the test or function library pauses at the first line of the called     action/function.

          Step Out :- Choose Debug > Step Out, click the Step Out button, or press SHIFT+F11 only    after using Step Into to enter an action or a user-defined function. Step Out runs to the end      of the called action or user-defined function, then returns to the calling test or function       library and pauses the run session.

          Step Over:- Choose Debug > Step Over, click the Step Over button, or press F10 to run only          the current step in the active test or function library. When the current step calls another        action or a user-defined function, the called action or function is executed in its entirety,      but the called action or function script is not displayed in the QuickTest window.
         
          Please open below link to know more about these debugging techniques with examples.
          http://qtp.blogspot.com/2008/09/qtp-step-into-step-out-step-over.html


35) What is the difference between checkpoint and Output value.
Ans:   Difference between checkpoint and output value:

          Check Point: It is nothing but a verification point allows the users to compare the expected           values with the actual values of the application. it allows to compare Obj properties,Text   values, Bitmap pictures etc. to perform the above job QTP contains 9 types of check points.


          Output Values: this option from Insert menu will be used to get the runtime output values of       the application objects either Text values or Property Values or Database values. It is used        instead of "GetROProperty" method.



36) What is Step generator and why it is used in QTP?
Ans:   You can add non-recordable functionality and otherwise enhance your test by adding and     modifying statements manually in the Keyword View, Expert View, or using the Step      Generator. You can mix recorded and programmed statements in the same test.
          It allows you to add Test Objects, Utility objects and functions from step generator dialog.

37) If your system is getting locked in every 5 minutes then how will you tackle this thing in QTP because qtp doesn't work when system is locked?
Ans:   There are two ways to overcome this problem.
          1) In QTP 9.1 or above there is a value in system registry which skip the environment check.
          Within regedit go to:

          HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest

          With MicTest highlighted you will see many registry settings. Scroll down the list until you get       to SkipEnvironmentChecks.

          Change the value of this registry setting to 1 (from 0).

          This will cause QTP to not check for the system being locked and will instead kick off your test. However, if the machine is logged off, it will not help. So make sure that the machine       you want to run the script on is locked and not logged off and you should be fine.

          Note: Some times this doesn't work based on system behavior, reason is unidentified...!!!

          2) we can use SendKeys method to press any key from keyboard after a specified time.
Example of SendKeys:
Set WshShell =  CreateObject("WScript.Shell")
WshShell.SendKeys "%^h"  ' Press ALT + CTRL + h


         


38) Should we automated the requirement which changes very frequently?
Ans:   No, because we have to execute the test cases once manually for changed requirement and          if we start automating the change which.


39) Write the functions to calculate the total occurrence of Letter “t” in word “testing”.
Ans:   There is no such function in qtp for finding a particular letter in a word, we have to apply some programming logic.
          Dim myarray
          myarray=split("testing","t") 'split the word with “t” and store in an array
          c=ubound(myarray,1) ' to count the number of items in array
          msgbox c





Check Page Rank of your Web site pages instantly:

This page rank checking tool is powered by Page Rank Checker service