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 & Answers - Part - 3

Share This Post -

Sponsored Links:

How can we do the Analysis of Results in QTP?
The Test Results window contains a graphic and text summary of the results of a run as well as details of each step in the run.


To view the results of a run:
1. If the Test Results window is not already open, click the Results button or choose Automation (menu) > Results.
Tip: You can open the Test Results window as a standalone application from the Start menu. To open the Test Results window, choose Start > Programs > QTP Professional > Test Results Viewer.


1. If there are test results for the current test, they are displayed in the Test Results window.
2. If there are several test results for the current test, or if there are no test results for the current test, the Open Test Results dialog box opens. You can select the test results for any test, or you can search for the test results (results.xml) file anywhere in the file system. Click Open to display the selected results in the Test Results window.
Note: Results files for QTP Professional are saved with a .qtp file extension.
The following example shows the results of a test with three iterations:

(Click on the above image to see the large view)

2. You can view the results of an individual iteration, an action, or a step. When you select a step in the test results tree, the right side of the Test Results window contains the details of the selected step. Depending on your settings in the Run tab of the Options dialog box, the right side of the Test Results window may be split into two panes, with the bottom pane containing a still image (or in selected cases, other data) of the selected step. The right pane may also contain a movie of your application.


3. Viewing Results of Tests Run From Quality Center
When you run test sets containing QTP tests from Quality Center, the Quality Center server opens QTP on the host computer and runs the tests from that computer. All run results are then saved to the default location for those tests.


You can view the results of QTP tests run from Quality Center. If your results include a movie of your application, the movie can be viewed in Quality Center.
Answer 2: After creating the test, what is the purpose of running them?


The major Purpose of running the test scripts are Checking and testing the application. And confirm that there are no major bugs in the application and working fine as per the business rules.
Also we run the test scripts to update the test scripts by running the test in the update mode and debug the the script by running I debug mode.


See why QTP is majorly used?
HP QTP Professional software provides functional and regression test automation for major software applications and environments, including next-generation development technologies, such as Windows® Presentation Foundation, Web services, Macromedia Flex, Ajax, Delphi, PowerBuilder, .NET, J2EE and enterprise resource planning (ERP), and customer relationship management (CRM) applications.


HP QTP Professional offers a fresh approach to automated testing: It deploys the concept of keyword driven testing to radically simplify test creation and maintenance. Using keyword capabilities, your testers can build test cases by capturing flows directly from the application screens and applying robust capturing technology (record/replay). In addition, your power users get full access to the underlying test and object properties through an integrated scripting and debugging environment that is synchronized with the Keyword View capability for your complete testing cycle.


With HP QTP Professional, your quality assurance (QA) organization can:
- Empower the entire team to create sophisticated test suites with less training.
- Establish correct functionality across all environments, data sets, and business processes.
- Fully document and replicate defects for developers, helping them fix defects faster and meet production deadlines.
- Easily regression test ever-changing applications and environments.
- Deliver quality products and services and improve revenues and profitability.
- Enable tester workgroups to share automated testing assets across teams.


Answer 3: I have a Microsoft Access database that contains data I would like to use in my test. How do I do this?
The Expert View enables you to access databases using ADO and ODBC. Below is a sample test that searches for books written by an author in the "Authors" table of the database.


Dim MyDB
Dim MyEng
Set MyEng = CreateObject("DAO.DBEngine.35")
Dim Td
Dim rs
' Specify the database to use.
Set MyDB = MyEng.OpenDatabase("BIBLIO.MDB")
' Read and use the name of the first 10 authors.
Set Td = MyDB.TableDefs("Authors")
Set rs = Td.OpenRecordset
rs.MoveFirst
For i = 1 To 10
Browser("Book Club").Page("Search Books").WebEdit("Author Name").Set rs("Author")
Browser("Book Club").Page("Search Books").WebButton("Search").Click
Next


Answer 4: Can we create many external variable files with same names & different values?
Of course YES. For localization testing we are using this and this is very efficient way for localization testing.
With the same variable name and different variable values, one can create many external variable files. And using the different file each time, we can run the test as many times we want.


Answer 5: Can we use Data Driver to parameterize the VBScript functions in QTP?
You cannot use the Data Driver to parameterize the values of arguments for user-defined methods or VBScript functions.


Notes from From HP QTP User Guide:
Notes:
- When finding multiple occurrences of a selected value, QTP conducts a search that is case sensitive and searches only for exact matches. (It does not find values that include the selected value as part of a longer string.)
- You cannot use the Data Driver to parameterize the values of arguments for user-defined methods or VBScript functions.
Answer 6: How can we add the same comment to every action that we create?
If you want to add the same comment to every action that you create, you can add the comment to an action template


To create an action template:
1. Create a text file containing the comments, function calls, and other statements that you want to include in your action template. The text file must be in the structure and format used in the Expert View.
2. Save the text file as ActionTemplate.mst in your \dat folder. All new actions you create contain the script lines from the action template.
Note: Only the file name ActionTemplate.mst is recognized as an action template.


Answer 7: How can we check a current data value with a value stored in a database in QTP?
Date base Checkpoint in QTP: You create a database checkpoint based on the results of the query (result set) you defined on a database. You can create a check on a database to check the contents of the entire result set, or a part of it. QTP captures the current data from the database, saves this information as expected data, and inserts a database checkpoint into the test. This checkpoint is displayed in the Expert View as a DbTable.Check CheckPoint statement and as a step in the Keyword View, as follows:


(Click on the image to see clear view)


When you run the test, the database checkpoint compares the current data in the database to the expected data defined in the Database Checkpoint Properties dialog box. If the expected data and the current results do not match, the database checkpoint fails. You can view the results of the checkpoint in the Test Results window.


You can modify the expected data of a database checkpoint before you run your test. You can also make changes to the query in an existing database checkpoint. This can be useful if you move the database to a new location on the network.


Answer 8: How can we check if an environment variable exists or not?
(Source: QA Forums)
When we use Environment("Param1").value then QTP expects the environment variable to be already defined.
But when we use Environment.value("Param1") then QTP will create a new internal environment variable if it does not exists already. So to be sure that variable exist in the environment try using Environment("Param1").value.
If you need to test for the existence of an environment variable, you might consider using:
if not "%var%"=="" @echo var=%var%
While this works, a better method is:
if defined var @echo var=%var%
Try this little test:
@echo off
setlocal
if not "%var%"=="" @echo line 3 %var%
if defined var @echo line 4 %var%
set var=hello world
if not "%var%"=="" @echo line 6 %var%
if defined var @echo line 7 %var%
endlocal


Answer 9: Can I store functions and subroutines in a function library?
You can define functions within an individual test, or you can create one or more VBScript function libraries containing your functions, and then call them from any test or use them in any component.


You can also register your functions as methods for QTP test objects. Your registered methods can override the functionality of an existing test object method for the duration of a run session, or you can register a new method for a test object class.


Answer 10: How can we check the contents of tables in our application in QTP?
By adding table checkpoints to the test, we can check the content of tables displayed in the application. For example, we can check that a specified value is displayed in a certain cell. Certain environments also support checking the properties of the table object.
For example, a check that a table has the expected number of rows and columns. A table checkpoint can also be created by inserting a standard checkpoint on a table object.


Answer 11: How we check the databases accessed by our application in QTP?
The contents of a database accessed by your application can be checked by Database Checkpoint. Database checkpoints are supported for all add-in environments


Answer 12: How can we check the location of a cell to be checked in a Column of a table?
The settings in the Cell Identification tab determine how QTP locates the cells to be checked. The settings in this tab apply to all selected cells.
The Cell Identification tab includes the following options:
i. Identify columns : Specifies the location of the column (in your actual table) containing the cell(s) to which you want to compare the expected data.
· By position. (Default) Locates cells according to the column position. A shift in the position of the columns within the table results in a mismatch.
· By column name. Locates cells according to the column name. A shift in the position of the columns within the table does not result in a mismatch. (Enabled only when the table contains more than one column.)
ii. Identify rows : Specifies the location of the row (in your actual table) containing the cell(s) to which you want to compare the expected data.
· By row number. (Default) Locates cells according to the row position. A shift in the position of any of the rows within the table results in a mismatch.
· By selected key column(s). Locates the row(s) containing the cells to be checked by matching the value of the cell whose column was previously selected as a key column. A shift in the position of the row(s) does not result in a mismatch. If more than one row is identified, QTP checks the first matching row. You can use more than one key column to uniquely identify any row.


Note: A key symbol is displayed in the header of selected key columns.


iii. Use value match criteria to identify data in the key column: Instructs QTP to use the verification type settings from the Settings tab as the criteria for identifying data in the key column.
Enabled only when you select to identify rows By selected key column(s).


Answer 13: How do I make the QTP test prompt the user for input while it is running ?
The VBScript InputBox function enables you to display a dialog box that prompts the user for input and then continues running the test. You can use the value that was entered by the user later in the run session. For more information on the InputBox function, refer to the VBScript Reference.


The following example shows the InputBox function used to prompt the user for a password.


Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").Set "administrator"
Passwd = InputBox ("Enter password", "User Input")
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("password").Set Passwd


Answer 14: How can we check the location of a cell to be checked in a Row of a table?
The settings in the Cell Identification tab determine how QTP locates the cells to be checked. The settings in this tab apply to all selected cells.
Identify rows : Specifies the location of the row (in your actual table) containing the cell(s) to which you want to compare the expected data.


· By row number. (Default) Locates cells according to the row position. A shift in the position of any of the rows within the table results in a mismatch.
· By selected key column(s). Locates the row(s) containing the cells to be checked by matching the value of the cell whose column was previously selected as a key column. A shift in the position of the row(s) does not result in a mismatch. If more than one row is identified, QTP checks the first matching row. You can use more than one key column to uniquely identify any row.


Answer 15: How can we check the object property values in our application?
You can check the object property values in your Web site or application using standard checkpoints. Standard checkpoints compare the expected values of object properties captured during recording to the object's current values during a run session.
You use standard checkpoints to perform checks on images, tables, Web page properties, and other objects within your application or Web site.
Note: You can create standard checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded).


Answer 16: How can we compare objects among two object repositories in QTP?
Using the Object Repository Comparison Tool, you can compare two object repositories according to predefined settings that define how differences between objects are identified.
To compare two object repositories:
1. In QTP Professional, choose Resources > Object Repository Manager.
2. In the Object Repository Manager, choose Tools > Object Repository Comparison Tool. The New Comparison dialog box opens on top of the Object Repository - Comparison Tool window.
(click on the below image to see clear view)

Answer 17: How can we compare the image files in the Image Checkpoint in QTP?
Image checkpoints enable you to check the properties of a Web image. In the Image Checkpoint Properties dialog box, you can specify which properties of the image to check and edit the values of those properties. This dialog box is similar to the standard Checkpoint Properties dialog box, except that it contains the Compare image content option. This option enables you to compare the expected image source file with the actual image source file.


Answer 18: How can we create a QTP Test in Quality Center?
To create a business process test, the Subject Matter Expert selects (drags and drops) the components that apply to the business process test and configures their run settings.


Note: When you run a business process test from Quality Center, the test run may also be influenced by settings in the QTP Remote Agent.
Each component can be used differently by different business process tests. For example, in each test the component can be configured to use different input parameter values or run a different number of iterations.
If, while creating a business process test, the Subject Matter Expert realizes that a component has not been defined for an element that is necessary for the business process test, the Subject Matter Expert can submit a component request from the Test Plan module.


Answer 19: How can I record and run tests on objects that change dynamically from viewing to viewing?
Sometimes the content of objects in a Web page or application changes due to dynamic content. You can create dynamic descriptions of these objects so that QTP will recognize them when it runs the test.


Answer 20: How can we debug a Function Library?
Before you can debug a function library, you must first associate it with a component (via its application area) and then insert a call to at least one of its functions. For example, you can use the Debug Viewer to view, set, or modify the current value of objects or variables in your function library. You can step into functions (including user-defined functions), set breakpoints, stop at breakpoints, view expressions, and so forth. You can begin debugging from a specific step, or you can instruct QTP to pause at a specific step.
Note: During a debug session, all documents are read-only and cannot be edited. To edit a document during a debug session, you must first stop the debug session.


After you create a component or function library (including registered user functions), you should check that they run smoothly, without errors in syntax or logic. To debug a function library, you must first associate it with a component via its application area and then debug it from that component.


To detect and isolate defects in a component or function library, you can control the run session using the Pause command as well as various step commands that enable you to step into, over, and out of a specific step.


You can use the Debug from Step command to begin your debug session at a specific point in your component. You can also use the Run to Step command to pause the run at a specific point in your component. You can set breakpoints, and then enable and disable them as you debug different parts of your component or function library.


When the component or function library run stops at a breakpoint, you can use the Debug Viewer to check and modify the values of VBScript objects and variables. Also, if QTP displays a run error message during a run session, you can click the Debug button on the error message to suspend the run and debug the component or function library.
You can also use the Run from Step command to run your component or function library from a selected step to the end. This enables you to check a specific section of your application or to confirm that a certain part of your component or function library runs smoothly.


Notes:
- While the component and function libraries are running in debug mode, they are read-only. You can modify the content after you stop the debug session (not when you pause it). If needed, you can enable the function library for editing (File > Enable Editing) after you stop the session.
After you implement your changes, you can continue debugging your component and function libraries.
- If you perform a file operation (for example, open a different component or create a new component), the debug session is stopped.
- In QTP, when you open a component, QTP creates a local copy of the external resources that are saved to your Quality Center project. Therefore, any changes you apply to any external resource that is saved in your Quality Center project, such as a function library, will not be implemented in the component until the component is closed and reopened. (An external resource is any resource that was not created using QTP, such as, a function library created in an external editor.)