QTP Questions

Q1. what is keyword driven test ?

Keyword driven testing is a method in which each object is assigned a unique keyword. These keywords are put in to a file known as application map. It is a file containing definition of each keyword.
E.g. I am assigning a keyword USERID to below webbutton object
Benefits -
1. Maintenance is very easy --  if any object definition changes in application then you don't need to change your script, just change in application map.
2. Easy to use -- If you are beginner in QTP then also you can develop script.

Q2.Which environments are supported by QTP?
QTP supports the following environments
  • Active X
  • Delphi
  • Java
  • .Net
  • Oracle
  • People Soft
  • Power Builder
  • SAP
  • Siebel
  • Stingray
  • Terminal Emulator
  • Visual Basic
  • Visual Age
  • Web
  • Web Services

Q3. What are the types object Repositories in QTP.
QTP Supports 2 types of Object Repository
 1) Shared Object Repository (also called Global)
2) Per-Action Object Repository, (also called Local)
Per-Action Object Repository is used by default. The extension for Per-Action repository is ".mtr" .
Shared Object Repository is preferable while dealing with dynamic objects which are called in multiple tests. The extension is ".tsr"

Q4. Can we call QTP test from another test using scripting. Suppose there are 4 tests and I want to call these tests in a main script. Is this possible in QTP? 
Yes.  You can call 4 or even more scripts in your tests. For this, first you will need to make the Actions in the corresponding scripts re-usable. Then from the destination script you can make calls to these re-usable actions.

Q5. What are action split and the purpose of using this in QTP?
Action split is to divide an existing action into two parts. The purpose is to divide actions based on their functionality to improve code re-use.

Q6. Explain how QTP identifies object?
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.

Q7. How many types of recording modes in QTP? Which will be used when?
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 hash maps. 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.

Q8. How will you call from one action to another action?
We can call an action in 2 ways
1) Call to copy of Action. - In this, the Action Object Repository, Script and Datable will be copied to the destination Test Script.
2) 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.

Q9. What are Virtual Objects?
Your application may contain objects that behave like standard objects but are not recognized by QTP. You can define these objects as virtual objects and map them to standard classes, such as a button or a check box. QTP emulates the user's action on the virtual object during the run session. In the test results, the virtual object is displayed as though it is a standard class object.
For example, suppose you want to record a test on a Web page containing a bitmap that the user clicks. The bitmap contains several different hyperlink areas, and each area opens a different destination page. When you record a test, the Web site matches the coordinates of the click on the bitmap and opens the destination page.
To enable QTP to click at the required coordinates during a run session, you can define a virtual object for an area of the bitmap, which includes those coordinates, and map it to the button class. When you run a test, QTP clicks the bitmap in the area defined as a virtual object so that the Web site opens the correct destination page.

Q10. How to perform Cross platform testing and Cross browser testing using QTP? Can u explain giving some example?
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.

Eg. 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  Eg. Browser ("Core Values").GetROProperty("version") you can extract the Browser and its corresponding version. Ex: Internet Explorer 6 or Netscape 5. Based on this value you call the actions which are relevant to that browser.

Q11. What is logical name of the object?
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("Guru99") Here Guru99 is the logical name of the object.

Q12. What is descriptive programming?
Typically, an object and its properties must be recorded in the Object Repository to enable QTP to perform action s on it. 
Using descriptive programming, you do not store the object and its property values in the Object repository but mention the property value pair directly in the script.
The idea behind descriptive programming is not bypass the object repository but help recognize dynamic objects.

Q13. What are the properties you would use for identifying a browser & page when using descriptive programming?
You can use the name property
ex: Browser("name:="xxx"").page("name:="xxxx"").....

We can also use the property "micClass".
ex: Browser("micClass:=browser").page("micClass:=page")....

Q14. 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

Q15. Explain the keyword CreateObject with an example.
Creates and returns a reference to an Automation object
SYNTAX: CreateObject(servername.typename [, location])
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")

Q16. Can you switch between Per-Action and Shared Object Repository? If yes how?
Yes .We can switch. Go to Test--->Settings--->Resources. Here you have an option to choose repositories.

Q17. What is Object Spy? How to Use it?
Object Spy helps in determining the run & test time object properties & methods of the application under test.
You can access object spy directly from the toolbar or from the Object Repository Dialog Box.
It is very useful during Descriptive Programming

Q18. When ordinal identifiers alone can make an object unique then why they are not given top priority? Why it is first mandatory and next assistive. Why we cannot go for ordinal identifiers directly?
Consider the following -
a) If two objects are overlapped on each other than location based object recognition will fail.
b) If only index based recognition is used your script will work but script execution time will increase.
Hence mandatory and assistive properties are used.

Q19. What is the file extension of the code file in QTP?
Code file extension is script.mts

Q20. Explain in brief about the QTP Automation Object Model.
QTP Automation Object model deals with Automation of QTP itself. Almost all configuration and functionality provided by QTP is represented by QTP's Automation Object Model. Almost all dialog boxes in QTP have a corresponding automation object which can set or retrieved using the corresponding properties or methods in the Automation Object Model.QTP Automation Objects can be used along with standard VB programming elements like iterative loops or conditional statements to help you design a script of choice.

Q21. 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.

Q22. What is Step Generator?
Step Generator enables use to Add Test Steps in your script. Using step generator you can add steps to your script without actually recording it.

Q23. How to make QTP understand the difference amongst the  same type of objects .Suppose there are 5 check boxes in a page and I have to choose the 2nd one, how to do that through script?
You can use ordinal identifiers like index along with a little descriptive programming for object recognition.

Q24. What is Test Fusion Report ?
Test Fusion Report, displays all aspects of a test run and is organized in a Tree format.
It gives details of each step executed for all iterations.
It also gives Run-time data table, Screen shots and movie of the test run if opted. 

Q25. How can you handle exceptions in QTP?
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 statements.

Q26. What are the types of environment variables in QTP?
Environment variables in QTP are of three types:
1) Built-in (Read only)
2) User-defined Internal (Read only)
3) User-defined External (Read/Write)
 You Set the Environment Variable  using the following syntax 
Environment.Value( "name") = "Guru99"
You can Retrieve the Environment Variable using following syntax
Environment.Value("name") -- This will return name as Guru99
Environment.Value("OS")  -- This will return your system OS

Q27. What is the Difference between Bitmap Check point & Image Check point?

Bitmap checkpoint does a pixel to pixel comparison of an image or part of an image.
Image checkpoint does do a pixel to pixel comparison but instead compare image properties like alt text , destination url etc.

Q28. What is the difference between functions and actions in QTP?
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.
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.

Q29. What is keyword view and Expert view in QTP?
Keyword View is an icon based view which shows test steps in tabular format. It also automatically generates documentation for the test steps.
Expert View gives the corresponding VB Script statement for every test step in the Keyword view.

Q30. Explain QTP testing process?
Quick Test testing process consists of 6 main phases:
1)  Create yourtest 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.
2) 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.
3) 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.
4) Replay & Debug - After enhancements you will replay the script to check whether its working properly and debug if necessary.
5) Run your Tests - In this phase you will perform the actual execution of your Test Script.
6) Analyzing the test results - Once test run is complete, you will analyze the results in the Test Fusion report generated.
7) 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.

Q31. What are the different types of Test Automation Frameworks?
The types of Automation Frameworks are -
1) Linear Scripting - Record & Playback
2) The Test Library Architecture Framework.
3) The Data-Driven Testing Framework.
4) The Keyword-Driven or Table-Driven Testing Framework.

Q32. How will you check a web application for broken links using QTP?
You can use the Page Checkpoint which gives a count of valid/invalid links on a page.

Q33. What is a Run-Time Data Table? Where can I find and view this table?
Data like parameterized output , checkpoint values , output values  are stored in the Run-time Table. It is an xls file which is stored in the Test Results Folder.  It can also be accessed in the Test Fusion Report.

Q34. What is the difference between check point and output value.
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.

Q35. How would you connect to database using vbscript?
To connect to the database you must know
a) Connection string of your server
b) Username
c) Password
d) DNS name
You can code the database connectivity command directly or you can use the SQL Query tool provided by QTP.

Q36. What is QTP batch testing tool?
You can use the Batch testing tool to run multiple scripts. Once the scripts are added in the tool, it will automatically open the scripts and start executing them one after the other.
Q37. Key Word Driven Testing:
The Keyword Driven framework consists of the basic components given below
1. Control File
2. Test Case File
3. Startup Script
4. Driver Script
5. Utility Script

1. Control File a)Consists details of all the Test scenarios to be automated b)User will be able to select a specific scenario to execute based on turning on or off a flag in the Control File c) Control File is in the form of an excel worksheet and contains columns for Scenario ID,Execute (Y/N),Object Repository Path, Test Case File Path

2. Test Case File a)Contains the detailed steps to be carried out for the execution of a test case b) It is also in the form of an excel sheet and contains columns for Keyword, Object Name, Parameter

3. Startup Script a) The Starup script is utilised for the initialization and reads the control files b) It then calls the driver script to execute all the scenarios marked for execution in the control file

4. Driver Script a) It Reads the Test Case files. Checks the keywords and calls the appropriate utility script functions based on specific keyword b) Error Handling is taken care of in the driver script.

5. Utility Scripts a) Perform generic tasks that can be used across applications. It should not be application dependent Advantage of Framework.

  • The main advantage of this framework is the low cost for maintenace. If there is change to any test case then only the Test Case File needs to be updated and the Driver Script and Startup script will remain the same.
  • No need to update the scripts in case of changes to the application.
Q38. Data-driven testing (DDT) is a term used in the testing of computer software to describe testing done using a table of conditions directly as test inputs and verifiable outputs as well as the process where test environment settings and control are not hard-coded. In the simplest form the tester supplies the inputs from a row in the table and expects the outputs which occur in the same row. The table typically contains values which correspond to boundary or partition input spaces. In the control methodology, test configuration is "read" from a database.

In the testing of software or programs, several methodologies are available for implementing this testing. Each of these methods co-exist because they differ in the effort required to create and subsequently maintain. The advantage of Data-driven testing is the ease to add additional inputs to the table when new partitions are discovered or added to the product or System Under Test. The cost aspect makes DDT cheap for automation but expensive for manual testing. One could confuse DDT with Table-driven testing, which this article needs to separate more clearly in future
  • Data-driven testing is the creation of test scripts to run together with their related data sets in a framework. The framework provides re-usable test logic to reduce maintenance and improve test coverage. Input and result (test criteria) data values can be stored in one or more central data sources or databases, the actual format and organisation can be implementation specific.
The data comprises variables used for both input values and output verification values. In advanced (mature) automation environments data can be harvested from a running system using a purpose-built custom tool or sniffer, the DDT framework thus performs playback of harvested data producing a powerful automated regression testing tool. Navigation through the program, reading of the data sources, and logging of test status and information are all coded in the test script.

Q39. Test Script Modularity Framework

The test script modularity framework requires the creation of small, independent scripts that represent modules, sections, and functions of the application-under-test. These small scripts are then used in a hierarchical fashion to construct larger tests, realizing a particular test case.
Of all the frameworks, this one should be the simplest to grasp and master. It is a well-known programming strategy to build an abstraction layer in front of a component to hide the component from the rest of the application. This insulates the application from modifications in the component and provides modularity in the application design. The test script modularity framework applies this principle of abstraction or encapsulation in order to improve the maintainability and scalability of automated test suites.

No comments:

Post a Comment