62
Q. 1: Tell me briefly about QTP? If you are going for a position related to QTP, you could expect this as the first question in the interview. The first step on the part of an interviewer is to make you comfortable with a basic question. Hence try to remember maximum portion from the following content that should be presented to the interviewer if situation arises. QTP is a graphical interface record-playback automation tool. It is able to work with any web, Java or windows client application. QTP enables you to test standard web objects and ActiveX controls. In addition to these environments, QTP also enables you to test Java applets and applications and multimedia objects on Applications as well as standard Windows applications, Visual Basic applications and .NET framework applications... QTP is Mercury Interactive Functional Testing Tool. Mercury QTP provides the industry's best solution for functional test and regression test automation - addressing every major software application and environment. This next-generation automated testing solution deploys the concept of Keyword-driven testing to radically simplify test creation and maintenance. Unique to QTP’s Keyword-driven approach, test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View. QTP enables you to test standard Windows applications, Web objects, ActiveX controls, and Visual Basic applications. You can also acquire additional QTP add-ins for a number of special environments (such as Java, Oracle, SAP Solutions, .NET Windows and Web Forms, Siebel, PeopleSoft, Web services, and terminal emulator applications). Q. 2: What’s the basic concept of QTP? QTP is based on two concepts like: a) Recording b) Playback Q. 3: Which scripting language used by QTP? QTP uses VB scripting. Q. 4: How many types of recording facility are available in QTP? QTP provides three types of recording methods like: a) Context Recording (Normal) b) Analog Recording c) Low Level Recording Q. 5: How many types of Parameters are available in QTP?

Qtp Interview Questions and answers

Embed Size (px)

DESCRIPTION

most asked interview questions

Citation preview

Page 1: Qtp Interview Questions and answers

Q. 1: Tell me briefly about QTP?

If you are going for a position related to QTP, you could expect this as the first question in the interview. The first step on the part of an interviewer is to make you comfortable with a basic question. Hence try to remember maximum portion from the following content that should be presented to the interviewer if situation arises.

QTP is a graphical interface record-playback automation tool. It is able to work with any web, Java or windows client application. QTP enables you to test standard web objects and ActiveX controls. In addition to these environments, QTP also enables you to test Java applets and applications and multimedia objects on Applications as well as standard Windows applications, Visual Basic applications and .NET framework applications...

QTP is Mercury Interactive Functional Testing Tool.

Mercury QTP provides the industry's best solution for functional test and regression test automation - addressing every major software application and environment. This next-generation automated testing solution deploys the concept of Keyword-driven testing to radically simplify test creation and maintenance. Unique to QTP’s Keyword-driven approach, test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View.

QTP enables you to test standard Windows applications, Web objects, ActiveX controls, and Visual Basic applications. You can also acquire additional QTP add-ins for a number of special environments (such as Java, Oracle, SAP Solutions, .NET Windows and Web Forms, Siebel, PeopleSoft, Web services, and terminal emulator applications).

Q. 2: What’s the basic concept of QTP?

QTP is based on two concepts like: a) Recording b) Playback

Q. 3: Which scripting language used by QTP?

QTP uses VB scripting.

Q. 4: How many types of recording facility are available in QTP?

QTP provides three types of recording methods like:

a) Context Recording (Normal) b) Analog Recording c) Low Level Recording

Q. 5: How many types of Parameters are available in QTP?

QTP provides three types of Parameters like:

a) Method Argument b) Data Driven c) Dynamic

Q. 6: What’s the testing process in QTP?

QTP testing process consist of seven steps like:

1) Preparing to recording 2) Recording 3) Enhancing your script

Page 2: Qtp Interview Questions and answers

4) Debugging 5) Run 6) Analyze 7) Report Defects etc.

Q. 7: How to Start recording using QTP?

Choose Test > Record or click the Record button.

When the Record and Run Settings dialog box opens, to do this;

1) In the Web tab, select Open the following browser when a record or run session begins.

2) In the Windows Applications tab, confirm that Record and run on these applications (opened on session start) is selected, and that there are no applications listed.

Q. 8: How to insert checkpoints to an image to check enable property in QTP?

Answer - 1: If all images are like push button than you can check the property enabled or disabled.

If you are not able to find that property than go to object repository for that object and click on add remove to add the available properties to that object.

And if you take it as image than you need to check visible or invisible property, there are no enable or disable properties for the image object.

Answer - 2: The Image Checkpoint does not have any property to verify the enable/disable property.

Important aspects that needs to be checked are:

a) Find out form the Developer if he is showing different images for activating/deactivating i.e. grayed out image. That is the only way a developer can show deactivate/activate if he is using an "image". Else he might be using a button having a headsup with an image.

b) If it is a button used to display with the headsup as an image you would need to use the object Properties as a checkpoint.

Q. 9: How to save your test using QTP?

Select File > Save or click the Save button.

The Save dialog box opens to the Tests folder.

Create a folder which you want to save to, select it, and click Open.

Type your test name in the File name field.

Confirm that Save Active Screen files is selected.

Click Save.

Your test name is displayed in the title bar of the main QTP window.

Q. 10: How to Run a Test using QTP?

Page 3: Qtp Interview Questions and answers

Step-1: Start QTP and open your test.

If QTP is not already open, choose Start > Programs > QuickTest Professional > QuickTest Professional.

# If the Welcome window opens, click Open Existing.

# If QTP opens without displaying the Welcome window, choose File > Open or click the Open button.

In the Open Test dialog box, locate and select your test, then click Open.

Step-2: Confirm that all images are saved to the test results.

QTP allows you to determine when to save images to the test results.

Choose Tools > Options and select the Run tab. In the Save step screen capture to test results option, select Always.

Click OK to close the Options dialog box.

Step-3: Start running your test.

Click Run or choose Test > Run. The Run dialog box opens.

Select New run results folder.

Accept the default results folder name.

Click OK to close the Run dialog box.

. 11: How to open a new test using QTP?

1) If QTP is not currently open:

Choose Start > Programs > QuickTest Professional > QuickTest Professional.

If the Welcome window opens, click Blank Test.

Otherwise, choose File > New, or click the New button.

A blank test opens.

2) If QTP is already open:

Check which add-ins are loaded by selecting Help > About QuickTest Professional.

If the Web Add-in is not loaded, you must exit and restart QTP.

When the Add-in Manager opens, select the Web Add-in, and clear all other add-ins.

Choose File > New, or click the New button.

A blank test opens.

Page 4: Qtp Interview Questions and answers

Q. 12: How to do load testing for web based Application?

1) Recording a scenario in QTP of web based application.

2) Make 100 copies of that scenario and run the test (scenario run for 100 times)

3) In that case, do the load of application on server.

4) The basic logic of running the copy 100 times is to create same scenario as if 100 users were working.

Q. 13: What is the extension of script and object repository files?

Object Repository : .tsr , Script : .mts, Excel : Default.xls

Q. 14: How to suppress warnings from the "Test results page"?

From the Test results Viewer "Tools > Filters > Warnings"...must be "Unchecked".

Q. 15: When we try to use test run option "Run from Step", the browser is not launching automatically why? This is default behavior.

Q. 16: What's the role of Checkpoints in QTP?

A checkpoint verifies that expected information is displayed in your application while the test is running. Checkpoint is basically a point in the test, which validates for truthfulness of a specific thing in the AUT.

There are different types of checkpoints depending on the type of data that needs to be tested in the AUT.

It can be text, image/bitmap, attributes, XML etc....

Q. 17: What types of checkpoints are offered by QTP?

There are 10 types of checkpoints you can insert in QTP:

1) Standard Checkpoint checks the property value of an object in your application or Web page. The standard checkpoint checks a variety of objects such as buttons, radio buttons, combo boxes, lists, etc.

2) Image Checkpoint checks the value of an image in your application or Web page. For example, you can check that a selected image’s source file is correct.

3) Bitmap Checkpoint checks an area of your Web page or application as a bitmap.

4) Table Checkpoint checks information within a table. For example, suppose your application or Web site contains a table listing all available flights from one place to another. You can add a table checkpoint to check that the time of the first flight in the table is correct.

5) Text Checkpoint checks that a text string is displayed in the appropriate place in your application or on a Web page.

6) Text Area Checkpoint checks that a text string is displayed within a defined area in a Windows application, according to specified criteria.

Page 5: Qtp Interview Questions and answers

7) Accessibility Checkpoint identifies areas of your Web site that may not conform to the World Wide Web Consortium (W3C) Web Content Accessibility Guidelines.

8) Page Checkpoint checks the characteristics of a Web page. For example, you can check how long a Web page takes to load or whether a Web page contains broken links.

9) Database Checkpoint checks the contents of a database accessed by your application.

10) XML Checkpoint checks the data content of XML documents in XML files or XML documents in Web pages and frames.

Q. 18: How to add a standard checkpoint in your test?

1) Start QTP and open your test.

In the Open Test dialog box, locate and select your test, then click Open.

2) Save the test as Checkpoint.

Select File > Save As. Save the test as Checkpoint.

3) Confirm that the Active Screen option is enabled.

If you do not see the Active Screen at the bottom of the QTP window, click the Active Screen button, or choose View > Active Screen.

4) Locate the page where you want to add a standard checkpoint.

5) Create a standard checkpoint.

In the Active Screen, right-click element in your application and choose Insert Standard Checkpoint.

6) Save the test.

Q. 19: 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.

1) Locate the page where you want to add a page checkpoint.

2) 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.

3) Save the test.

Page 6: Qtp Interview Questions and answers

Q. 20: How run time data (Parameterization) is handled in QTP?

You can enter test data into the Data Table, an integrated spreadsheet with the full functionality of Excel, to manipulate data sets and create multiple test iterations, without programming, to expand test case coverage.

Data can be typed in or imported from databases, spreadsheets, or text files.

21: What is keyword view and Expert view in QTP?

By QTP’s Keyword Driven approach, the test automation experts have full access to the underlying test and object properties, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View.

Advanced testers can view and edit their tests in the Expert View, which reveals the underlying industry-standard VBScript that QTP automatically generates.

Any changes made in the Expert View are automatically synchronized with the Keyword View.

Q. 22: How QTP recognizes Objects in AUT?

QTP stores the definitions for application objects in a file called the Object Repository.

As you record your test, QTP will add an entry for each item you interact with.

Each Object Repository entry will be identified by a logical name (determined automatically by QTP), and will contain a set of properties (type, name, etc) that uniquely identify each object.

Each line in the QTP script will contain a reference to the object that you interacted with, a call to the appropriate method (set, click, check) and any parameters for that method (such as the value for a call to the set method).

The references to objects in the script will all be identified by the logical name, rather than any physical, descriptive properties.

Q. 23: What are the types of Object Repositories in QTP?

QTP has two types of object repositories for storing object information:

1) Shared object repositories and

2) Action object repositories.

You can choose which type of object repository you want to use as the default type for new tests, and you can change the default as necessary for each new test.

The object repository per-action mode is the default setting. In this mode, QTP automatically creates an object repository file for each action in your test so that you can create and run tests without creating, choosing, or modifying object repository files.

However, if you modify values in an action object repository, your changes do not have any effect on other actions. Hence, if the same test object exists in more than one action and if you modify an object's

Page 7: Qtp Interview Questions and answers

property values in one action, you may need to make the same change in every action (and any test) containing the object.

Q. 24: If I give some thousand tests to execute in 2 days what do you do?

Adhoc testing is done. It covers the least basic functionality to verify that the system is working fine.

Q. 25: How to "Turn Off" QTP results after running a Script?

Goto "Tools > Options > Run Tab" and Deselect "View results when run session ends". But this suppresses only the result window, but a log will be created and can be viewed manually which cannot be restricted from getting created.

Q. 26: Explain the Test Fusion Report of QTP?

Once a tester has run a test, a TestFusion report displays all aspects of the test run. This is a high-level results overview, an expandable Tree View of the test specifying the following:

# Exactly where application failures occurred,

# Test data used# Application screen shots for every step that highlight any discrepancies# Detailed explanations of each checkpoint pass and failure.

By combining TestFusion reports with QTP, you can share reports across an entire QA and development team.

Q. 27: QTP supports which environments?

QTP supports functional testing of all enterprise environments, including Windows, Web, ..NET, Java/J2EE, SAP, Siebel, Oracle, PeopleSoft, Visual Basic, ActiveX, mainframe terminal emulators, and Web services.

Q. 28: What are the elements of QTP Window?

Before beginning creation of the tests,, it is essential to familiarize with the main QTP window.

The QTP window contains the following key elements:

1) Title bar: Displays the name of the currently open test.

2) Menu bar: Displays menus of QTP commands.

3) File toolbar: Contains buttons to assist you in managing your test.

4) Testing toolbar: Contains buttons to assist you in the testing process.

5) Debug toolbar: Contains buttons to assist you in debugging tests.

6) Test pane: Contains the Keyword View and Expert View tabs.

Page 8: Qtp Interview Questions and answers

7) Active Screen: Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.

8) Data Table: Assists you in parameterizing your test.

9) Debug Viewer pane: Assists you in debugging your test.

The Debug Viewer pane contains the Watch Expressions, Variables, and Command tabs.

(The Debug Viewer pane is not displayed when you open QTP for the first time.

You can display the Debug Viewer by choosing View < Debug Viewer.)

10) Status bar: Displays the status of the QTP application.

Q. 29: How does QTP identifies the object in the application?

QTP identifies the object in the application by LogicalName and Class.

For example: The Edit box is identified by

Logical Name : PSOPTIONS_BSE_TIME20

Class: WebEdit

Q. 30: If an application name is changes frequently i.e. while recording it has name "Window1" and then while running its "Windows2" in this case how does QTP handles?

QTP handles those situations using "Regular Expressions.

. 31: Briefly explain the utility of Table and Database Checkpoints?

By adding table checkpoints to your tests or components, you can check:

a) That a specified value is displayed in a cell in a table on your application. b) The contents of databases accessed by your application.

The results displayed for table and database checkpoints are similar. When you run your test or component, QTP compares the expected results of the checkpoint to the actual results of the run session. If the results do not match, the checkpoint fails.

You can check that a specified value is displayed in a cell in a table by adding a table checkpoint to your test or component. For ActiveX tables, you can also check the properties of the table object.

To add a table checkpoint, you use the Checkpoint Properties dialog box. Table checkpoints are supported for Web and ActiveX applications, as well as for a variety of external add-in environments.

You can use database checkpoints in your test or component to check databases accessed by your Web site or application and to detect defects. You define a query on your database, and then you create a database checkpoint that checks the results of the query.

Page 9: Qtp Interview Questions and answers

Database checkpoints are supported for all environments supported by QTP, by default, as well as for a variety of external add-in environments.

There are two ways to define a database query:

a) Use Microsoft Query. You can install Microsoft Query from the custom installation of Microsoft Office.

b) Manually define an SQL statement.

The Checkpoint timeout option is available only when creating a table checkpoint. It is not available when creating a database checkpoint

Q. 32: How do you check Bitmaps?

You can check an area of a Web page or application as a bitmap. While creating a test or component, you specify the area you want to check by selecting an object. You can check an entire object or any area within an object. QTP captures the specified object as a bitmap, and inserts a checkpoint in the test or component. You can also choose to save only the selected area of the object with your test or component in order to save disk space.

When you run the test or component, QTP compares the object or selected area of the object currently displayed on the Web page or application with the bitmap stored when the test or component was recorded. If there are differences, QTP captures a bitmap of the actual object and displays it with the expected bitmap in the details portion of the Test Results window. By comparing the two bitmaps (expected and actual), you can identify the nature of the discrepancy. For more information on test results of a checkpoint, see Viewing Checkpoint Results.

For example, suppose you have a Web site that can display a map of a city the user specifies. The map has control keys for zooming. You can record the new map that is displayed after one click on the control key that zooms in the map. Using the bitmap checkpoint, you can check that the map zooms in correctly.

You can create bitmap checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded).

The results of bitmap checkpoints may be affected by factors such as operating system, screen resolution, and color settings.

Q. 33: Briefly explain the utility of Text/Text Area Checkpoint?

In the Text/Text Area Checkpoint Properties dialog box, you can specify the text to be checked as well as which text is displayed before and after the checked text. These configuration options are particularly helpful when the text string you want to check appears several times or when it could change in a predictable way during run sessions.

In Windows-based environments, if there is more than one line of text selected, the Checkpoint Summary pane displays [complex value] instead of the selected text string. You can then click Configure to view and manipulate the actual selected text for the checkpoint.

QTP automatically displays the Checked Text in red and the text before and after the Checked Text in blue. For text area checkpoints, only the text string captured from the defined area is displayed (Text Before and Text After are not displayed). To designate parts of the captured string as Checked Text and other parts as Text Before and Text After, click the Configure button. The Configure Text Selection dialog box opens

Page 10: Qtp Interview Questions and answers

Checking XML :

XML (Extensible Markup Language) is a meta-markup language for text documents that is endorsed as a standard by the W3C. XML makes the complex data structures portable between different computer environments/operating systems and programming languages, facilitating the sharing of data.

XML files contain text with simple tags that describe the data within an XML document. These tags describe the data content, but not the presentation of the data. Applications that display an XML document or file use either Cascading Style Sheets (CSS) or XSL Formatting Objects (XSL-FO) to present the data.

You can verify the data content of XML files by inserting XML checkpoints. A few common uses of XML checkpoints are described below:

An XML file can be a static data file that is accessed in order to retrieve commonly used data for which a quick response time is needed—for example, country names, zip codes, or area codes. Although this data can change over time, it is normally quite static. You can use an XML file checkpoint to validate that the data has not changed from one application release to another.

An XML file can consist of elements with attributes and values (character data). There is a parent and child relationship between the elements, and elements can have attributes associated with them. If any part of this structure (including data) changes, your application's ability to process the XML file may be affected. Using an XML checkpoint, you can check the content of an element to make sure that its tags, attributes, and values have not changed.

XML files are often an intermediary that retrieves dynamically changing data from one system. The data is then accessed by another system using Document Type Definitions (DTD), enabling the accessing system to read and display the information in the file. You can use an XML checkpoint and parameterize the captured data values in order to check an XML document or file whose data changes in a predictable way.

XML documents and files often need a well-defined structure in order to be portable across platforms and development systems. One way to accomplish this is by developing an XML schema, which describes the structure of the XML elements and data types. You can use schema validation to check that each item of content in an XML file adheres to the schema description of the element in which the content is to be placed.

Q. 34: What are the Features & Benefits of QTP?

1) Key word driven testing

2) Suitable for both client server and web based application

3) VB script as the script language

4) Better error-handling mechanism

5) Excellent data driven testing features

6) Operates stand-alone, or integrated into HP Business Process Testing and HP Quality Center.

It introduces next-generation zero-configuration Keyword Driven testing technology in QTP allowing for fast test creation, easier maintenance, and more powerful data-driving capability.

Page 11: Qtp Interview Questions and answers

It identifies objects with Unique Smart Object Recognition, even if they change from build to build, enabling reliable unattended script execution.

It collapses test documentation and test creation to a single step with Auto-documentation technology.

It enables thorough validation of applications through a full complement of checkpoints.

Q. 36: What information does the columns in the Keyword View provide for each step?

As you recorded your test, QTP generated steps in the Keyword View representing each operation you performed in the Web browser.

The columns in the Keyword View show different information for each step, as follows:

1) Item: Displays the item for the step (test object, utility object, function call, or statement) in a hierarchical icon-based tree.

2) Operation: The operation to be performed on the item, for example, Click or Select.

3) Value: The argument values for the selected operation, for example, the mouse button to use when clicking the image.

4) Assignment: The assignment of a value to or from a variable so you can use the value later in the test.

5) Comment: Any textual information you want to add regarding the step, for example, Return to page used in first step of the test.

6) Documentation: Auto-documentation of what the step does, in an easy-to-understand sentence, for example, Click the "findFlights" image.

Q. 37: Why do we use Regular Expressions?

We create a text checkpoint for searching a specific text string. We can use regular expressions to increase the flexibility and adaptability of your tests.

Regular expressions enable QTP to identify objects and text strings with varying values.

You can use regular expressions when defining the properties of an object, the methods of an argument, when parameterizing a step, and when creating checkpoints with varying values.

Q. 38: Explain QTP Testing process ?

The QTP testing process consists of 6 main phases:

1) Create your test plan: Prior to automating there should be a detailed description of the test including the exact steps to follow, data to be input, and all items to be verified by the test. The verification information should include both data validations and existence or state verifications of objects in the application.

Page 12: Qtp Interview Questions and answers

2) Recording a session on your application: As you navigate through your application, QTP graphically displays each step you perform in the form of a collapsible icon-based test tree. A step is any user action that causes or makes a change in your site, such as clicking a link or image, or entering data in a form.

3) Enhancing your test:

# Inserting checkpoints into your test lets you search for a specific value of a page, object or text string, which helps you identify whether or not your application is functioning correctly.

Checkpoints can be added to a test as you record it or after the fact via the Active Screen. It is much easier and faster to add the checkpoints during the recording process.

# Broadening the scope of your test by replacing fixed values with parameters lets you check how your application performs the same operations with multiple sets of data.

# Adding logic and conditional statements to your test enables you to add sophisticated checks to your test.

4) Debugging your test: If changes were made to the script, you need to debug it to check that it operates smoothly and without interruption.

5) Running your test on a new version of your application: You run a test to check the behavior of your application. While running, QTP connects to your application and performs each step in your test.

6) Analyzing the test results: You examine the test results to pinpoint defects in your application.

7) Reporting defects: As you encounter failures in the application when analyzing test results, you will create defect reports in Defect Reporting Tool.

Q. 39: What is parameterizing of Tests?

When you test your application, you may want to check how it performs the same operations with multiple sets of data.

For example, you want to check how your application responds to ten separate sets of data. You could record ten separate tests, each with its own set of data.

Alternatively, you can create a parameterized test that runs ten times: each time the test runs, it uses a different set of data.

Q. 40: What is test object model in QTP?

The test object model is a large set of object types or classes that QTP uses to represent the objects in your application. Each test object class has a list of properties that can uniquely identify objects of that class and a set of relevant methods that QTP can record for it.

A test object is an object that QTP creates in the test or component to represent the actual object in your application. QTP stores information about the object that will help it identify and check the object during the run session.

A run-time object is the actual object in your Web site or application on which methods are performed during the run session.

Page 13: Qtp Interview Questions and answers

When you perform an operation on your application while recording, QTP:

# Identifies the QTP test object class that represents the object on which you performed the operation and creates the appropriate test object

# Reads the current value of the object’s properties in your application and stores the list of properties and values with the test object

# Chooses a unique name for the object, generally using the value of one of its prominent properties

# Records the operation that you performed on the object using the appropriate QTP test object method

QTP identifies the object that you clicked as a WebButton test object.

It creates a WebButton object with the name Find, and records the following properties and values for the Find WebButton:

It also records that you performed a Click method on the WebButton.

QTP displays your step in the Keyword View like this:

QTP displays your step in the Expert View like this:

Browser("Mercury Interactive").Page("Mercury Interactive").

WebButton("Find").

41: How to analyze the test results using QTP?

When QTP finishes running the test, the Test Results window opens.

Initially, the Test Results window contains two panes for displaying the key elements of your test run.

# The left pane displays the results tree, an icon-based view of the steps that were performed while the test was running. The results tree is organized according to the Web pages visited during the test run and can be expanded (+) to view each step.

The steps performed during the test run are represented by icons in the tree. You can instruct QTP to run a test or action more than once using different sets of data in each run. Each test run is called iteration, and each iteration is numbered. (The test you ran had only one iteration.)

# The right pane displays the test results details. The iteration summary table indicates which iterations passed and which failed. The status summary table indicates the number of checkpoints or reports that passed, failed, and raised warnings during the test.

View the test results for a specific step.

In the results tree, expand (+) Test Recording Summary > Recording Iteration 1 (Row 1) > Action1 Summary > your application > your test name.

The Test Results window now contains three panes, displaying:

Page 14: Qtp Interview Questions and answers

# The results tree, with one step highlighted

# The test results details of the highlighted step

# The Active Screen, showing a screen capture of the Web page on which the step was performed.

When you click a page in the results tree, QTP displays the corresponding page in the application view. When you click a step (an operation performed on an object) in the results tree, the corresponding object is highlighted in the application view. In this case, the Departing From text box is highlighted.

Q. 42: Briefly tell me about the checkpoints in QTP?

A checkpoint verifies that expected information is displayed in an application while the test is running. You can add eight types of checkpoints to your test for standard web objects using QTP.

1) A page checkpoint checks the characteristics of an application

2) A text checkpoint checks that a text string is displayed in the appropriate place on an application

3) An object checkpoint (Standard) checks the values of an object on an application

4) An image checkpoint checks the values of an image on an application

5) A table checkpoint checks information within a table on an application

6) An Accessibility checkpoint checks the web page for statutory compliance.

7) An XML checkpoint checks the contents of individual XML data files or XML documents that are part of your Web application.

8) A database checkpoint checks the contents of databases accessed by your web site

Q. 43: In how many ways we can add checkpoints to an application using QTP?

We can add checkpoints while recording the application or we can add after recording is completed using Active screen

To perform the second one The Active screen must be enabled while recording

Q. 44: Explain the Automation Object Model of QTP in brief?

Essentially all configuration and run functionality provided via the QTP interface is in some way represented in the QTP automation object model via objects, methods, and properties.

Although a one-on-one comparison cannot always be made, most dialog boxes in QTP 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 QTP automation object model, along with standard programming elements such as loops and conditional statements to design your program.

Page 15: Qtp Interview Questions and answers

Q. 45: Briefly explain the QTP Environment.

QTP environment uses the graphical interface and ActiveScreen technologies - A testing process for creating test scripts, relating manual test requirements to automated verification features - Data driving to use several sets of data using one test script.

Q. 46: Explain the concept as to how QTP identifies object.

During recording QTP looks at the object and stores it as test object.

For each test object QTP learns a set of default properties called mandatory properties, and look at the rest of the objects to check whether this properties are enough to uniquely identify the object.

During test run, QTP searches for the run time objects that matches with the test object it learned while recording.

Q. 47: Explain the Object Repositories types, Which & when to use?

Deciding Which Object Repository Mode to Choose

To choose the default object repository mode and the appropriate object repository mode for each test, you need to understand the differences between the two modes.

In general, the object repository per-action mode is easiest to use when you are creating simple record and run tests, especially under the following conditions:

You have only one, or very few, tests that correspond to a given application, interface, or set of objects.

You do not expect to frequently modify test object properties.

You generally create single-action tests.

Conversely, the shared object repository mode is generally the preferred mode when:

You have several tests that test elements of the same application, interface, or set of objects.

You expect the object properties in your application to change from time to time and/or you regularly need to update or modify test object properties.

You often work with multi-action tests and regularly use the Insert Copy of Action and Insert Call to Action options.

Q. 48: Can we script any test case with out having Object repository? Or Using Object Repository is a must?

No. You can script with out Object repository by knowing the Window Handlers, spying and recognizing the objects logical names and properties available.

Q. 49: How to execute a WinRunner Script in QTP?

a) TSLTest.RunTest TestPath, TestSet [, Parameters ] --> Used in QTP used for backward compatibility Parameters : The test set within Quality Center, in which test runs are stored.

Page 16: Qtp Interview Questions and answers

Note that this argument is relevant only when working with a test in a Quality Center project.

When the test is not saved in Quality Center, this parameter is ignored.

e.g : TSLTest.RunTest "D:\test1", ""

b) TSLTest.RunTestEx TestPath, RunMinimized, CloseApp [, Parameters ] TSLTest.RunTestEx "C:\WinRunner\Tests\basic_flight", TRUE, FALSE, "MyValue" CloseApp : Indicates whether to close the WinRunner application when the WinRunner test run ends. Parameters : Up to 15 WinRunner function argument

Q. 50: Why should we divide a test into three action calls?

When you create a new test, it contains a call to one action.

By dividing your tests into calls to multiple actions, you can design more modular and efficient tests.

51: How can we clear the AutoComplete?

1) In your Internet Explorer’s menu bar, choose Tools > Internet Options > Content tab.

2) Click AutoComplete in the Personal information area. The AutoComplete Settings dialog box opens.

3) In the Use AutoComplete for area, clear the User names and passwords on forms option.

4) Click OK to save your changes and close the AutoComplete Settings dialog box, then click OK again to close the Internet Options dialog box.

Q. 52: What is Object Spy in QTP?

Using the Object Spy, you can view the properties of any object in an open application.

You use the Object Spy pointer to point to an object.

The Object Spy displays the selected object’s hierarchy tree and its properties and values in the Properties tab of the Object Spy dialog box.

Q. 53: What is the Difference between Image check-point and Bit map Checkpoint?

Image checkpoints enable you to check the properties of a Web image. You can check an area of a Web page or application as a bitmap. While creating a test or component, you specify the area you want to check by selecting an object. You can check an entire object or any area within an object.

QTP captures the specified object as a bitmap, and inserts a checkpoint in the test or component. You can also choose to save only the selected area of the object with your test or component in order to save disk Space For example, suppose you have a Web site that can display a map of a city the user specifies. The map has control keys for zooming. You can record the new map that is displayed after one click on the control key that zooms in the map. Using the bitmap checkpoint, you can check that the map zooms in correctly.

You can create bitmap checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded).

Page 17: Qtp Interview Questions and answers

The results of bitmap checkpoints may be affected by factors such as operating system, screen resolution, and color settings.

Q. 54: In how many ways we can parameterize data in QTP?

There are four types of parameters:

a) Test, action or component parameters - enable you to use values passed from your test or component, or values from other actions in your test.

b) Data Table parameters - enable you to create a data-driven test (or action) that runs several times using the data you supply. In each repetition, or iteration, QTP uses a different value from the Data Table.

c) Environment variable parameters - enable you to use variable values from other sources during the run session. These may be values you supply, or values that QTP generates for you based on conditions and options you choose.

d) Random number parameters: enable you to insert random numbers as values in your test or component. For example, to check how your application handles small and large ticket orders, you can have QTP generate a random number and insert it in a number of tickets edit field.

Q. 55: How do you do batch testing in WinRunner & is it possible to do in QTP, if so explain - how?

Batch Testing in WinRunner is nothing but running the whole test set by selecting "Run Testset" from the "Execution Grid".

The same is possible with QTP also. If our test cases are automated then by selecting "Run Testset" all the test scripts can be executed. In this process the Scripts get executed one by one by keeping all the remaining scripts in "Waiting" mode.

Q. 56: How to use the Object spy in QTP?

There are two ways to Spy the objects in QTP

1) Through file toolbar: In the File toolbar click on the last toolbar button (an icon showing a person with hat).

2) Through Object repository Dialog: In Object repository dialog click on the button"object spy..."

In the Object spy Dialog click on the button showing hand symbol. the pointer now changes in to a hand symbol and we have to point out the object to spy the state of the object if at all the object is not visible.

or

When window is minimized then Hold the Ctrl button and activate the required window to and release the Ctrl button.

Q. 57: What is the file extension of the code file & object repository file in QTP?

File extension are:

Page 18: Qtp Interview Questions and answers

# Per test object rep :- filename.mtr

# Shared Oject rep :- filename.tsr

# Code file extension id script.mts

Q. 58: How do we create an Output Value using QTP?

1) Start QTP and open the Parameter test. 2) Save the test as Output.3) Confirm that the Active Screen option is enabled. 4) Select the text you want to use as an output value. 5) Set the output value settings. 6) Modify the table checkpoint. 7) Save the test.

Q. 59: What do you understand by a checkpoint being in red color? What do you do?

A red color indicates failure. Here we analyze the cause for failure whether it is a Script Issue or Environment Issue or a Application issue.

Q. 60: What do you call the window testdirector-testlab?

"Execution Grid". It is place from where we Run all Manual / Automated Scripts

61: How do you create new test sets in Test Director?

Login to Test Director.

Click on "Test Lab" tab.

Select the Desired folder under which we need to Create the Test Set. (Test Sets can be grouped as per module.)

Click on "New Test Set or Ctrl+N" Icon to create a Test Set.

Q. 62: Explain the concept of object repository and how QTP recognizes objects?

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 Ordianl identifier such as objects location on the page or in the source code.

Q. 63: What are the properties you would use for identifying a browser and page when using Descriptive Programming?

"name" would be another property apart from "title" that we can use.

OR

Page 19: Qtp Interview Questions and answers

We can also use the property "micClass".

For example: Browser("micClass:=browser").page("micClass:=page")....

Q. 64: I want to open a Notepad window without recording a test and I do not want to use SystemUtil.Run command as well How do I do this?

You can still make the notepad open without using the record or System utility script, just by mentioning the path of the notepad " (i.e., where the notepad.exe is stored in the system) in the "Windows Applications Tab" of the "Record and Run Settings window.

Q. 65: If an application name is changed frequently i.e. while recording it has name, in this case how does QTP handle it?

QTP handles those situations using ?Regular Expressions?. ...

Q. 66: How does QTP identify the objects in the application?

QTP identifies the object in the application by LogicalName and Class.

For example: The Edit box is identified by Logical Name: PSOPTIONS_BSE_TIME20 Class: WebEdit ...

Q. 67: IF we use batch testing, the result shown for last action only. Then how can I get result for every action.

You can click on the icon in the tree view to view the result of every action

Q. 68: How do we draw a brief comparison of WinRunner & QTP?

Although it is quite difficult to remember so much of the tabulated data as given below, however you can just glance through the contents & present the maximum out of it as per the memory in the event such a question is asked.

Environment Coverage Comparison:

Common environments shared by both WinRunner and QTP:

Web-Related Environments

IE, Netscape, AOL

  JDK, Java Foundation Classes, AWT

  Symantec Visual Café

  ActiveX Controls

ERP/CRM Oracle: Jinitiator, 11i, NCA

Custom Client Server Windows

Page 20: Qtp Interview Questions and answers

  C++/C

  Visual Basic

Operating Systems Windows 98, 2000, NT, ME, XP

Legacy 3270, 5250 Emulators

  VT100

Environments WinRunner Only:

Custom Client/Server PowerBuilder

  Forte

  Delphi

  Centura

  Stingray

  SmallTalk

ERP/CRM Baan

  PeopleSoft Windows

  Siebel 5, 6 GUI Clients

  Oracle GUI Forms

Environments QTP Only:

ERP/CRM SAP

  Siebel 7.x

  PeopleSoft 8.x

.Net WinForms

  WebForms

  .Net controls

Web Services XML, HTTP

Page 21: Qtp Interview Questions and answers

  WSDL, SOAP

  J2EE, .Net

Multimedia RealAudio/Video

  Flash

Feature Comparison:

Common features found in both WinRunner and QTP:

Record/Replay ODBC & Excel Connectivity

Code Editor & Debugger Recovery Manager

Shared Object Repository Rapid Object Import

Numerous Checkpoints Analog

Script & Function Libraries  

Environments for WinRunner Only:

Function Generator

Database Integration

Run Wizard TSL

MDI  

Environments for QTP Only:

ActiveScreen TestGuard

Tree View ScriptFusion

Data Table VBScript

Function Generator

Run Wizard

Q. 69: How to Import data from a ".xls" file to Data table during Runtime.

Datatable.Import "...XLS file name..."

DataTable.ImportSheet(FileName, SheetSource, SheetDest)

Page 22: Qtp Interview Questions and answers

DataTable.ImportSheet "C:\name.xls" ,1 ,"name"

Q. 70: How to export data present in Datatable to an ".xls" file?

DataTable.Export "....xls file name..."

71: What can be the Syntax to call one script from another? And what can be the Syntax to call one "Action" in another?

RunAction ActionName, [IterationMode , IterationRange , Parameters]

Here the action becomes reusable on making this call to any Action.

IterationRange String Not always required. Indicates the rows for which action iterations will be performed. Valid only when the IterationMode is rngIterations. Enter the row range (i.e. "1-7"), or enter rngAll to run iterations on all rows.

If the action called by the RunAction statement includes an ExitAction statement, the RunAction statement can return the value of the ExitAction's RetVal argument.

Q. 72: How to export QTP results to an ".xls" file?

By default it creates an "XML" file and displays the results

Q. 73: How the exception handling can be done using QTP

It can be done by using the Recovery Scenario Manager which provides a wizard that guides you through the process of defining a recovery scenario.

The wizard could be accessed in QTP> Tools-> Recovery Scenario Manager .......

Q. 74: How many types of Actions are there in QTP?

There are three kinds of actions:

1) Non-reusable action: an action that can be called only in the test with which it is stored, and can be called only once.

2) Reusable action: an action that can be called multiple times by the test with which it is stored (the local test) as well as by other tests.

3) External action: a reusable action stored with another test. External actions are read-only in the calling test, but you can choose to use a local, editable copy of the Data Table information for the external action.

Q. 75: How do we analyze the Checkpoint results?

By adding standard checkpoints to your tests or components, you can compare the expected values of object properties to the object's current values during a run session. If the results do not match, the checkpoint fails.

Q. 76: How do we handle Run-time errors?

Page 23: Qtp Interview Questions and answers

On Error Resume Next: causes execution to continue with the statement immediately following the statement that caused the run-time error, or with the statement immediately following the most recent call out of the procedure containing the "On Error Resume Next" statement.

This allows execution to continue despite a run-time error.

You can then build the error-handling routine inline within the procedure.

Using "Err" object msgbox "Error no: " & " " & Err.Number & " " & Err.description & " " & Err.Source & Err.HelpContext

Q. 77: What are the different scripting languages you could use when working with QTP ?

Visual Basic (VB),XML, JavaScript, Java, HTML

Q. 78: How to handle dynamic objects in QTP?

QTP has a unique feature called Smart Object Identification/recognition. QTP generally identifies an object by matching its test object and run time object properties. QTP may fail to recognize the dynamic objects whose properties change during run time. Hence it has an option of enabling Smart Identification, wherein it can identify the objects even if their properties changes during run time.

Check this out - If QTP is unable to find any object that matches the recorded object description, or if it finds more than one object that fits the description, then QTP ignores the recorded description, and uses the Smart Identification mechanism to try to identify the object. While the Smart Identification mechanism is more complex, it is more flexible, and thus, if configured logically, a Smart Identification definition can probably help QTP identify an object, if it is present, even when the recorded description fails.

The Smart Identification mechanism uses two types of properties:

Base filter properties: The most fundamental properties of a particular test object class; those whose values cannot be changed without changing the essence of the original object.

For example, if a Web link's tag was changed from to any other value, you could no longer call it the same object.

Optional filter properties: Other properties that can help identify objects of a particular class as they are unlikely to change on a regular basis, but which can be ignored if they are no longer applicable.

Q. 79: Explain the keyword createobject with an example?

Creates and returns a reference to an Automation object

syntax: CreateObject(servername.typename [, location])

Arguments

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.

Page 24: Qtp Interview Questions and answers

Q. 80: What is a Run-Time Data Table? Where can I find and view this table?

# In QTP, there is data table that is at runtime.

# In QTP, select the option View->Data table.

# This is an excel file, which is stored in the folder of the test created, its name is Default.xls by default.

. 81: How to do we do the scripting? Is there any inbuilt functions in QTP as in QTP-S? What is the difference between them? How to handle script issues?

Yes, there's an in-built functionality called "Step Generator"

in Insert->Step->Step Generator -F7, which will generate the scripts as u enter the appropriate steps.

Q. 82: What is the difference between checkpoint and output value?

An output value is a value captured during the test run and entered in the run-time but to a specified location.

For example: Location in Data Table[Global sheet / local sheet]

Another difference is that a checkpoint only checks for the specific attribute of an object in AUT while Output value can output those attributes value to a column in data table.

Q. 83: Types of properties that QTP learns while recording?

a) Mandatory b) Assistive

In addition to recording the mandatory and assistive properties specified in the Object Identification dialog box, QTP can also record a backup ordinal identifier for each test object.

The ordinal identifier assigns the object a numerical value that indicates its order relative to other objects with an otherwise identical description (objects that have the same values for all properties specified in the mandatory and assistive property lists).

This ordered value enables QTP to create a unique description when the mandatory and assistive properties are not sufficient to do so.

Q. 84: Can you quickly tell me the Differences between QTP and Winrunner?

a) QTP is object bases Scripting (VBS) where Winrunner is TSL (C based) Scripting.

b) QTP supports ".NET" application Automation not available in Winrunner

c) QTP has "Active Screen" support, which captures the application, not available in WR.

d) QTP has "Data Table" to store script values, variables which WR does not have.

e) Using a "point and click" capability you can easily interface with objects, their definitions and create checkpoints after having recorded a script – without having to navigate back to that location in your application like you have to with WinRunner. This greatly speeds up script development.

Page 25: Qtp Interview Questions and answers

Q. 85: What are the commonly used Excel VBA functions?

Common functions are:

# Coloring the cell

# Auto fit cell

# Setting navigation from link in one cell to other saving

Q. 86: How does Parameterization and Data-Driving relate to each other in QTP?

To datadrive we have to parameterize.i.e. we have to make the constant value as parameter, so that in each iteraration(cycle) it takes a value that is supplied in run-time datatable.

Through parameterization only we can drive a transaction(action) with different sets of data.

Running the script with the same set of data several times is not advisable.

Q. 87: What is the difference between Call to Action and Copy Action?

Call to Action: The changes made in Call to Action will be reflected in the original action (from where the script is called).

Copy Action: The changes made in the script, will not effect the original script(Action)

Q. 88: How to verify the Cursor focus of a certain field?

Use "focus" property of "GetRoProperty" method"

Q. 89: What are the limitations of XML Checkpoints?

HP has determined that 1.4MB is the maximum size of a XML file that QTP can handle

Q. 90: How to make arguments optional in a function?

This is not possible, as default VBS doesn't support this. Instead you can pass a blank string and have a default value if arguments are not required.

. 91: How to add a text checkpoint to your test to check whether 'welcome' is displayed in your welcome page.

1) Locate the page where you want to add a text checkpoint.

2) Create a text checkpoint.

In the Active Screen, under your page highlight the text welcome. Right-click the highlighted text and choose Insert Text Checkpoint. The Text Checkpoint Properties dialog box opens.

When Checked Text appears in the list box, the Constant field displays the text string you highlighted. This is the text QTP looks for when running the test.

Page 26: Qtp Interview Questions and answers

Click OK to accept the default settings in this dialog box.

QTP adds the text checkpoint to your test. It is displayed in the Keyword View as a checkpoint operation on your welcome page

3) Save the test.

Q. 92: How can you execute and analyze a Test with Checkpoints?

1) Expand the test and review your test:

Choose View > Expand All or use the * shortcut key on your number keypad.

2) Start running your test:

Click Run or choose Test > Run. The Run dialog box opens. Ensure that New run results folder is selected. Accept the default results folder name. Click OK. When the test run is completed, the Test Results window opens.

3) View the test results:

When QTP finishes running the test, the Test Results window opens.

The test result should be Passed, indicating that all checkpoints passed.

If one or more checkpoints had failed, the test result would be Failed.

4) View the results of the page checkpoint:

In the Details pane, you can review the details of the page checkpoint, which lists the items checked.

5) View the results of the table checkpoint:

In the Details pane, you can review the details of the table checkpoint. You can also review the values of the table cells (cell values that were checked are displayed in black; cell values that were not checked are displayed in gray).

6) View the results of the standard checkpoint:

In the Details pane, you can review the details of the standard checkpoint, which lists the properties that were checked and their values. The checkpoint passed because the actual values of the checked properties match the expected values.

7) View the results of the text checkpoint:

In the Details pane, you can review the details of the text checkpoint. The checkpoint passed because the actual text matches the expected text.

8) Close the Test Results window. Choose File > Exit.

Q. 93: How do you define a Data Table Parameter for QTP?

Page 27: Qtp Interview Questions and answers

1) Start QTP and open the Checkpoint test.

2) Save the test as Parameter.

3) Confirm that the Active Screen option is enabled.

4) Confirm that the Data Table option is enabled.

5) Select the text to parameterize.

6) Set the parameterization properties.

Q. 94: How do you add a runtime parameter to a datasheet?

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")

Q. 95: How to change the run-time value of a property for an object?

SetTOProperty changes the property values used to identify an object during the test run.

Only properties that are included in the test object description can be set

Q. 96: How to retrieve the property of an object?

This can be done by using "GetRoProperty".

Q. 97: How to open any application during Scripting?

SystemUtil , object used to open and close applications and processes during a run session.

A SystemUtil.Run statement is automatically added to your test when you run an application from the Start menu or the Run dialog box while recording a test

E.g : SystemUtil.Run "Notepad.exe" SystemUtil.CloseDescendentProcesses ( Closes all the processes opened by QTP )

Q. 98: How to covert a String to an integer?

CInt()---> a conversion function available.

Q. 99: Inserting a Call to Action is not Importing all columns in Datatable of globalsheet. Why?

Inserting a call to action will only Import the columns of the Action called

Q. 100: Differentiate between the two types of Object Repositories of QTP.

Page 28: Qtp Interview Questions and answers

Object repository is used to store all the objects in the application being tested.

There are two types of object repositories, 1) Per action and 2) Shared.

In shared repository only one centralized repository is there for all the tests.

Where as in per action, for each test a separate per action repository is created.

101: What the differences are and best practical application of each of the Object Repositories?

Per Action: For Each Action, one Object Repository is created.

Shared: One Object Repository is used by entire application

Q. 102: Explain the difference between Shared Repository and Per Action Repository?

Shared Repository: Entire application uses one Object Repository, that similar to Global GUI Map file in WinRunner

Per Action: For each Action, one Object Repository is created, like GUI map file per test in WinRunner

Q. 103: Have you ever written a compiled module? If yes tell me about some of the functions that you wrote.

I had used the functions for capturing the dynamic data during runtime.

Function used for Capturing Desktop, browser and pages.

Q. 104: How do you hide the Add-In Manager so that it will not be displayed while launching QTP?

a) Uncheck "Show on Startup" checkbox in the Add-In Manager

b) Uncheck "Display Add-In Manager on Startup" in the General tab of Options dialog box.

Q. 105: Can you do more than just capture and playback in QTP?

I have done dynamically capturing the objects during runtime in which no recording, no playback and no use of repository is done at all.

It was done by the windows scripting using the DOM(Document Object Model) of the windows.

Q. 106: Can you quickly summarize QTP – Some of the salient features & benefits?

Although it is a bit difficult to remember so much of the information as given below, however you can just glance through the contents & present the maximum out of it as per the memory in the event such a question is asked.

Following description has been taken from the Mercury Interactive "How it Works" section of the QTP web page:

Page 29: Qtp Interview Questions and answers

QTP provides an interactive, visual environment for test development. Mercury QTP allows even novice testers to be productive in minutes. You can create a test script by simply pressing a Record button and using an application to perform a typical business process. Each step in the business process is automated documented with a plain-English sentence and screen shot. Users can easily modify, remove, or rearrange test steps in the Keyword View.

QTP can automatically introduce checkpoints to verify application properties and functionality, for example to validate output or check link validity. For each step in the Keyword View, there is an ActiveScreen showing exactly how the application under test looked at that step. You can also add several types of checkpoints for any object to verify that components behave as expected, simply by clicking on that object in the ActiveScreen.

You can then enter test data into the Data Table, an integrated spreadsheet with the full functionality of Excel, to manipulate data sets and create multiple test iterations, without programming, to expand test case coverage. Data can be typed in or imported from databases, spreadsheets, or text files.

Advanced testers can view and edit their test scripts in the Expert View, which reveals the underlying industry-standard VBScript that QTP automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.

Once a tester has run a script, a TestFusion report displays all aspects of the test run: a high-level results overview, an expandable Tree View of the test script 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. By combining TestFusion reports with Mercury Quality Management, you can share reports across an entire QA and development team.

QTP also facilitates the update process. As an application under test changes, such as when a "Login" button is renamed "Sign In," you can make one update to the Shared Object Repository, and the update will propagate to all scripts that reference this object. You can publish test scripts to Mercury Quality Management, enabling other QA team members to reuse your test scripts, eliminating duplicative work.

QTP supports functional testing of all popular environments, including Windows, Web, .Net, Visual Basic, ActiveX, Java, SAP, Siebel, Oracle, PeopleSoft, terminal emulators, and Web services.

People like QTP and now prefer implementing it over WinRunner. When you get into advance testing scenarios, QTP has more options and they are easier to implement compared to WinRunner in our opinion.

Do to the similarities in concept and features, an experienced WinRunner user can easily convert to QTP and quickly become an efficient Test Automation Engineer!

We recommend that existing customers begin all new development with QTP and use the built-in feature of calling WinRunner scripts from QTP for all existing WinRunner scripts that they already have. As older scripts require updates and time permits, we recommend replacing them with QTP scripts. Eventually you will be able to convert your test script library with all QTP scripts.

Pros:

# Will be getting the initial focus on development of all new features and supported technologies.

# Ease of use.

# Simple interface.

Page 30: Qtp Interview Questions and answers

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

# QTP 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 QTP.

# Parameterization easier than WinRunner.

# Can enhance existing QTP 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 QTP 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 QTP compared to WinRunner.

# Integrates with TestDirector and WinRunner (can kick off WinRunner scripts from QTP).

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.

Q. 107: Explain the terms "TEST" and " Business Component"

Page 31: Qtp Interview Questions and answers

Test: A collection of steps organized into one or more actions, which are used to verify that your application performs as expected. By default each test begins with a single action.

Business Component: A collection of steps representing a single task in your application.

Business components (also known as components) are combined into specific scenarios to build business process tests in Mercury Quality Center with Business Process Testing.

A component does not contain actions, you add steps directly to a component.

Q. 108: Can you quickly tell me - What is a checkpoint?

A checkpoint checks specific values or characteristics of a page, object, or text string and enables you to identify whether or not your Web site or application is functioning correctly.

A checkpoint compares the value of an element captured in your test when you recorded your test, with the value of the same element captured during the test run.

Q. 109: What do you mean by iteration?

Each run session that uses a different set of parameterized data is called an iteration.

Q. 110: What is output value?

An output value is a value retrieved during the run session and entered into your Data Table or saved as a variable or a parameter.

111: How many Add-ins comes by default with QTP?

There are 3 Add-ins comes with QTP: 1) ActiveX 2) Visual Basic 3) Web

Q. 112: What are the different views available in QTP? 1) Keyword View 2) Expert View

Q. 113: What is Active Screen?

The Active Screen provides a snapshot of your application, as it appeared when you performed a certain step during a recording session.

Q. 114: What are the key elements of a QTP window?

The QTP window contains the following key elements:

1) QTP title bar: Displays the name of the currently open test or component.

2) Menu bar: Displays menus of QTP commands.

3) File toolbar: Contains buttons to assist you in managing your test or component.

4) Testing toolbar: Contains buttons to assist you in the testing process.

5) Debug toolbar: Contains buttons to assist you in debugging your test or component (not displayed by default).

Page 32: Qtp Interview Questions and answers

6) Action toolbar: Contains buttons and a list of actions, enabling you to view the details of an individual action or the entire test flow.

7) Test pane: Contains the Keyword View and Expert View tabs.

8) Active Screen: Provides a snapshot of your application as it appeared when you performed a certain step during the recording session.

9) Data Table: Assists you in parameterizing your test or component. For a test, the Data Table contains the Global tab and a tab for each action. For a component, the Data Table contains single tab.

10) Debug Viewer pane: Assists you in debugging your test or component. The Debug Viewer pane contains the Watch Expressions, Variables, and Command tabs (not displayed by default).

11) Status bar: Displays the status of the QTP application.

Q. 115: How many tabs are available in Debug Viewer Pane?

The Debug Viewer pane contains three tabs to assist us in debugging our test or component like:

1) Watch Expressions: The Watch Expressions tab enables you to view the current value of any variable or other VBScript expression.

2) Variables: The Variables tab enables you to view the current value of all variables that have been recognized up to the last step performed in the run session.

3) Command: The Command tab enables you to execute a line of script in order to set or modify the current value of a variable or VBScript object in your test or component. When you continue the run session, QTP uses the new value that was set in the command.

Q. 116: How many toolbars QTP has?

QTP has Four built-in toolbars: 1) The File toolbar 2) The Testing toolbar

3) The Debug toolbar 4) Action toolbar

The Action toolbar is available in the Keyword View and contains options that enable you to view all actions in the test flow or to view the details of a selected action.

The Action toolbar is not available for components.

Q. 117: Explain the terms Password Encoder, Remote Agent, Test Batch Runner, Test Results Deletion tool?

Password Encoder: Enables you to encode passwords. You can use the resulting strings as method arguments or Data Table parameter values.

Remote Agent:: Determines how QTP behaves when a test or component is run by a remote application such as Quality Center.

Test Batch Runner: Enables you to set up QTP to run several tests in succession.

Page 33: Qtp Interview Questions and answers

Test Results Deletion Tool: Enables you to delete unwanted or obsolete results from your system according to specific criteria that you define.

Q. 118: Explain the terms Test Object Model, Test Object and Run-Time object?

The test object model is a large set of object types or classes that QTP uses to represent the objects in your application.

Each test object class has a list of properties that can uniquely identify objects of that class and a set of relevant methods that QTP can record for it.

A test object is an object that QTP creates in the test or component to represent the actual object in your application.

QTP stores information about the object that will help it identify and check the object during the run session.

A run-time object is the actual object in your Web site or application on which methods are performed during the run session.

Q. 119: What are assistive properties or an ordinal identifier?

When mandatory property values are not sufficient to uniquely identify the object within its parent object, QTP adds some assistive properties and/or an ordinal identifier to create a unique description.

You can retrieve or modify property values of the test object during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View.

You can retrieve property values of the runtime object during the run session by adding GetROProperty statements.

If the available test object methods or properties for an object do not provide the functionality you need, you can access the internal methods and properties of any run-time object using the Object property.

You can also use the attribute object property to identify Web objects in your application according to user-defined properties.

Q. 120: What is object Repository? Explain different types of Object Repositories?

QTP identifies objects in your application based on a set of test object properties. It stores the object data it learns in the object repository.

You can save your objects either in a shared object repository or in action object repository. In shared object repository mode, you can use one object repository file for multiple tests or components.

In object repository peraction mode, QTP automatically creates an object repository file for each action in your test.

Object repository per-action mode is not available for components.

121: How you can enhance your test?

Page 34: Qtp Interview Questions and answers

There is variety of options to enhance our test:

1) You can add checkpoints to your test. A checkpoint is a step in your test that compares the values of the specified property during a test run with the values stored for the same test object property within the test. This enables you to identify whether or not your Web site or application is functioning correctly.

2) You can parameterize your test to replace fixed values with values from an external source during your test run. The values can come from a Data Table, environment variables you define, or values that QTP generates during the test run.

3) You can retrieve values from your test and store them in the Data Table as output values. You can subsequently use these values as an input parameter in your test. This enables you to use data retrieved during a test in other parts of the test.

4) You can divide your test into actions to streamline the testing process of your Web site or application.

5) You can use special QTP options to enhance your test with programming statements. The Step Generator guides you step-by-step through the process of adding recordable and non-recordable methods to your test. You can also synchronize your test to ensure that your application is ready for QTP to perform the next step in your test, and you can measure the amount of time it takes for your application to perform steps in a test by defining and measuring transactions.

6) You can also manually enter standard VBScript statements, as well as statements using QTP test objects and methods, in the Expert View.

Q. 122: Explain different recording modes in QTP?

QTP’s normal recording mode records the objects in your application and the operations performed on them. This mode is the default and takes full advantage of QTP’s test object model, recognizing the objects in your application regardless of their location on the screen.

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, QTP 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. You cannot edit analog recording steps from within QTP.

Low Level Recording - enables you to record on any object in your application, whether or not QTP 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 tests in an environment or on an object not recognized by QTP.

You can also use low-level recording if the exact coordinates of the object are important for your test.

Q. 123: How do you display the DataTable or Active screen if they are not shown by default?

In Menu choose View → Active Screen or View → Data Table.

Page 35: Qtp Interview Questions and answers

Q. 124: What is a parameter?

A parameter is a variable that is assigned a value from an external data source or generator.

If you wish to parameterize the same value in several steps in your test or component, you may want to consider using the Data Driver rather than adding parameters manually.

Q. 125: How many types of parameters are there?

There are four types of parameters:

1. Test, action or component parameters: Test, action or component parameters enable you to use values passed from your test or component, or values from other actions in your test.

2. Data Table parameters: Data Table parameters enable you to create a data-driven test (or action) that runs several times using the data you supply. In each repetition, or iteration, QTP uses a different value from the Data Table.

3. Environment variable parameters: Environment variable parameters enable you to use variable values from other sources during the run session. These may be values you supply, or values that QTP generates for you based on conditions and options you choose.

4. Random number parameters: Random number parameters enable you to insert random numbers as values in your test or component.

Q. 126: What are the QTP workflow Phases?

Create, Display, Verify and Enhance, Integrate.

Alternatively it can be said that:

Create test suite, Create an engine, Automate test cases, Debug the script, Deploy the script to QA team.

Q. 127: What are the conditional statements provided in QTP?

For..Next,

While….wend,

For……loop,

Do….. While,

If… Else…. End If,

Select…. Case.

Q. 128: What is the first step to change the logical name of the object recorded by QTP?

Answer - 1: Identify the instances of the object in the script. {S1, S2…S10 - OR}

Answer - 2: Identify the instances of the object in the Object Repository{S_1, S_2…S_10}.

Page 36: Qtp Interview Questions and answers

Q. 129: What is the use of Information pane and Missing Resource pane?

The Information pane provides a list of syntax errors in your test or function library scripts.

The Missing Resources pane provides a list of the resources that are specified in your test but cannot be found, such as missing calls to actions, unmapped shared object repositories, and parameters that are connected to shared object repositories.

Q. 130: What is the file extension of the code file & object repository file in QTP?

1) For code file the extension is .vbs 2) For object repository file the extension is .tsr 3) File extension for per action is (.mtr)

131: How to Merge Object repositories?

QTP Plus setup provides Repositories Merge Utility.

The Object Repository Merge Utility enables user to merge Object repository files into a single Object repository file.

Q. 132: Global Data sheet is having one record and Local Data sheet is having two records, how many times the test executes by default?The test executes once

Q. 133: Can you do more than just capture and playback in QTP?

We can do dynamic capturing the objects during runtime in which no recording, no playback and no use of repository is done at all.

It can be done by the windows scripting using the DOM(Document Object Model) provided by windows.

Q. 134: How do you find the number of columns in database table?

Answer -1: Fields.Count or Get the array size of the Record Set object. i.e. upper limit.

Answer -2: Use GetParameterCount method of DTSheet object

Q. 135: How can we write scripts without having GUI (meaning thereby you don't have any GUI and you want to write a script in QTP)?

We can do it by descriptive programming

Q. 136: What is the descriptive programming? & What is its use?

QTP uses its object repository to refer to objects present in your test and which have been recorded. If you wish to use objects that were not recorded and are not present in your object repository then we use descriptive programming.

Here QTP does not refer to object repository but the property name and value are mentioned in the code itself for QTP to use it

Page 37: Qtp Interview Questions and answers

For e.g. this is not Desc. prog. Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username") This is desc prog. Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

Q. 137: Explain the need to use analog recording in QTP?

This mode records exact mouse and Key Board operations you perform in relation to the screen / Application Window. This mode is useful for the operation, which you can record at Object Level, such as drawing a picture, recording signature.

The steps recorded using Analog Mode is saved in separated data file, QTP add to your Test a Run Analog File statement that calls the recorded analog File.

This file is stored with your action in which these Analog Steps are created.

The Step recorded in Analog mode can not be edited within QTP.

Q. 138: Can you explain Descriptive programming with some illustration in QTP?

Whenever QTP records any action on any object of an application, it adds some description on how to recognize that object to a repository of objects called object repository. QTP cannot take action on an object until unless its object description is in the Object Repository. But descriptive programming provides a way to perform action on objects that are not in Object repository

Object Identification: To identify an object during the play back of the scripts QTP stores some properties which helps QTP to uniquely identify the object on a page. Below screen shots shows an example Object repository.

Now to recognize a radio button on a page QTP had added 2 properties the name of the radio button and the html tag for it. The name the left tree view is the logical name given by QTP for the object. This can be changed as per the convenience of the person writing the test case. QTP only allows Unique logical name under same level of hierarchy.

The two objects in Browser->Page node are "WebTable" and "testPath", they cannot have the same logical name. But an object under some other node can have the same name. Now with the current repository that we have, we can only write operation on objects which are in the repository.

Some of the example operations are as under

Browser("Browser").Page("Page").WebRadioGroup ("testPath").Select "2"

cellData = Browser("Browser").Page("Page").WebTable ("WebTable").GetCellData (1,1)

Browser("Example2").Page("Page").WebEdit("testPath").Set "Test text"

Q. 139: When and why do we use descriptive programming?

Following are some of the situations when Descriptive Programming can be considered useful:

The objects in the application are dynamic in nature and need special handling to identify the object.

The best example would be of clicking a link, which changes according to the user of the application, Ex.

Page 38: Qtp Interview Questions and answers

"Logout <>".

When object repository is getting huge in size due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object.

When you don’t want to use object repository at all. Then the first question would be why not use the object repository?

Consider the following scenario, which would help understand why not use the Object repository

Scenario 1: Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing

Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be "Cancel", "Back" and "Next". Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page.

Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.

When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.

<<<<<< =================== >>>>>>

Q. 140: How can we use descriptive programming?

You can try to remember the maximum portion of the following useful content related to DP that can be shared with the interviewer, in case a situation arise.

There are two ways in which descriptive programming can be used

1) By creating properties collection object for the description.

2) By giving the description in form of the string arguments.

By creating properties collection object for the description: To use this method firstly you need to create an empty description.

Dim obj_Desc ‘Not necessary to declare

Set obj_Desc = Description.Create

Page 39: Qtp Interview Questions and answers

Now we have a blank description in "obj_Desc". Each description has 3-properties "Name", "Value" and "Regular Expression".

obj_Desc("html tag").value= "INPUT"

When you use a property name for the first time the property is added to the collection and when you use it again the property is modified. By default each property that is defined is a regular expression.

Suppose we have the following description

obj_Desc("html tag").value= "INPUT

" obj_Desc("name").value= "txt.*"

This would mean an object with html tag as INPUT and name starting with txt. Now actually that ".*" was considered as regular expression.

Hence if you want the property "name" not to be recognized as a regular expression then you need to set the "regularexpression" property as FALSE

obj_Desc("html tag").value= "INPUT"

obj_Desc("name").value= "txt.*"

obj_Desc("name").regularexpression= "txt.*"

This is how of we create a description. Now in the following way we can use it

Browser("Browser").Page("Page").WebEdit(obj_Desc).set "Test"

When we say .WebEdit(obj_Desc) we define one more property for our description that was not earlier defined that is it’s a text box (because QTPs WebEdit boxes map to text boxes in a web page).

If we know that we have more than 1-element with same description on the page then we must define "index" property for the that description

Consider the HTML code given below

INPUT type="textbox" name="txt_Name"

INPUT type="textbox" name="txt_Name"

Now the html code has two objects with same description. So distinguish between these 2 objects we will use the "index" property. Here is the description for both the object

For 1st textbox:

obj_Desc("html tag").value= "INPUT"

obj_Desc("name").value= "txt_Name

" obj_Desc("index").value= "0"

Page 40: Qtp Interview Questions and answers

For 2nd textbox:

obj_Desc("html tag").value= "INPUT"

obj_Desc("name").value= "txt_Name"

obj_Desc("index").value= "1"

Consider the HTML Code given below:

INPUT type="textbox" name="txt_Name"

INPUT type="radio" name="txt_Name"

We can use the same description for both the objects and still distinguish between both of them

obj_Desc("html tag").value= "INPUT"

obj_Desc("name").value= "txt_Name"

When I want to refer to the textbox then I will use the inside a WebEdit object and to refer to the radio button I will use the description object with the WebRadioGroup object.

Browser("Browser").Page("Page").WebEdit(obj_Desc).set "Test" ‘Refers to the text box

Browser("Browser").Page("Page").WebRadioGroup(obj_Desc).set "Test" ‘Refers to the radio button

But if we use WebElement object for the description then we must define the "index" property because for a webelement the current description would return two objects.

Hierarchy of test description:

When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onward within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have been described using programmatic descriptions, QTP cannot identify the object.

For example, you can use Browser(Desc1).Page(Desc1).Link(desc3), since it uses programmatic descriptions throughout the entire test object hierarchy.

You can also use Browser("Index").Page(Desc1).Link(desc3), since it uses programmatic descriptions from a certain point in the description (starting from the Page object description).

However, you cannot use Browser(Desc1).Page(Desc1).Link("Example1"), since it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the Link test object (QTP tries to locate the Link object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions).

Page 41: Qtp Interview Questions and answers

Getting Child Object:

We can use description object to get all the objects on the page that matches that specific description. Suppose we have to check all the checkboxes present on a web page. So we will first create an object description for a checkbox and then get all the checkboxes from the page

Dim obj_ChkDesc

Set obj_ChkDesc=Description.Create

obj_ChkDesc("html tag").value = "INPUT"

obj_ChkDesc("type").value = "checkbox"

Dim allCheckboxes, singleCheckBox

Set allCheckboxes = Browse("Browser").Page("Page").ChildObjects(obj_ChkDesc)

For each singleCheckBox in allCheckboxes

singleCheckBox.Set "ON"

Next

The above code will check all the check boxes present on the page. To get all the child objects we need to specify an object description i.e. we can’t use the string arguments that will be discussed later in the 2nd way of using the programming description.

Possible Operation on Description Object

Consider the following code for all the solutions

Dim obj_ChkDesc

Set obj_ChkDesc=Description.Create

obj_ChkDesc("html tag").value = "INPUT"

obj_ChkDesc("type").value = "checkbox"

141: How can we get the no. of descriptions defined in a collection?

By using obj_ChkDesc.Count

Q. 142: How can you remove a description from the collection?

obj_ChkDesc.remove "html tag" ‘would delete the html tag property from the collection

Q. 143: How can you check if property exists or not in the collection?

Page 42: Qtp Interview Questions and answers

The answer is that it’s not possible. Reason being whenever we try to access a property, which is not, defined its automatically added to the collection.

The only way to determine is to check its value that is use a if statement "if obj_ChkDesc("html tag").value = empty then".

Q. 144: How to browse through all the properties of a properties collection?

There are two ways to do it

1st Method:

For each desc in obj_ChkDesc

Name=desc.Name

Value=desc.Value

RE = desc.regularexpression

Next

2nd Method:

For i=0 to obj_ChkDesc.count - 1

Name= obj_ChkDesc(i).Name

Value= obj_ChkDesc(i).Value

RE = obj_ChkDesc(i).regularexpression

Next

Q. 145: How can you describe an object by giving the description in the form of the string arguments?

You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object’s name.

The general syntax is:

TestObject("PropertyName1:=PropertyValue1", "..." , "PropertyNameX:=PropertyValueX")

TestObject—the test object class could be WebEdit, WebRadioGroup etc….

PropertyName:=PropertyValue—the test object property and its value.

Each property:=value pair should be separated by commas and quotation marks.

You can enter a variable name as the property value if you want to find an object based on property values you retrieve during a run session.

Page 43: Qtp Interview Questions and answers

Consider the following HTML Code:

INPUT type="textbox" name="txt_Name"

INPUT type="radio" name="txt_Name"

Now to refer to the textbox the statement would be as given below

Browser("Browser").Page("Page").WebEdit("Name:=txt_Name","html tag:=INPUT").set "Test"

And to refer to the radio button the statement would be as given below

Browser("Browser").Page("Page").WebRadioGroup("Name:=txt_Name","html tag:=INPUT").set "Test"

If we refer to them as a web element then we will have to distinguish between the two using the index property

Browser("Browser").Page("Page").WebElement("Name:=txt_Name","html tag:=INPUT","Index:=0").set "Test" ‘ Refers to the textbox Browser("Browser").Page("Page").WebElement("Name:=txt_Name","html tag:=INPUT","Index:=1").set "Test" ‘ Refers to the radio button

Q. 146: How can I check if a parameter exists in the Data Table or not?

The best way would be to use the following code:

on error resume next

val=DataTable("ParamName",dtGlobalSheet)

if err.number<> 0 then

'Parameter does not exist

else

'Parameter exists

end if

Q. 147: How can I make some rows colored in the data table?

You can't do it normally but you can use Excel COM API's for this purpose.

Following code explains some expects of Excel COM APIs

code:

Set xlApp=Createobject("Excel.Application")

set xlWorkBook=xlApp.workbooks.add

Page 44: Qtp Interview Questions and answers

set xlWorkSheet=xlWorkbook.worksheet.add

xlWorkSheet.Range("A1:B10").interior.colorindex = 34 'Change the color of the cells

xlWorkSheet.Range("A1:A10").value="text" 'Will set values of all 10 rows to "text"

xlWorkSheet.Cells(1,1).value="Text" 'Will set the value of first row and first col

rowsCount=xlWorkSheet.Evaluate("COUNTA(A:A)") 'Will count the # of rows which have non blank value in the column A

colsCount=xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st row

xlWorkbook.SaveAs "C:\Test.xls"

xlWorkBook.Close

Set xlWorkSheet=Nothing

Set xlWorkBook=Nothing

set xlApp=Nothing

Q. 148: What is Smart Identification? And when do you use it?

Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of the objects.

A very generic example as per the QTP manual would be, A photograph of a 8 year old girl and boy and QTP records identification properties of that girl when she was 8, now when both are 10 years old then QTP would not be able to recognize the girl. But there is something that is still the same, that is there is only one girl in the photograph. So it is a kind of PI (Programmed intelligence) not AI.

When should I use SMART Identification?

This is something that people don't think about too much. But the thing is that you should disable SI while creating your test cases. So that you are able to recognize the objects that are dynamic or inconsistent in their properties.

When the script has been created, the SI should be enabled, so that the script does not fail in case of small changes. But the developer of the script should always check for the test results to verify if the SI feature was used to identify a object or not. Sometimes SI needs to be disabled for particular objects in the OR, this is advisable when you use

SetTOProperty to change any of the TO properties of an object and especially ordinal identifiers like index, location and creationtime.

Q. 149: How can you associate a procedure to a test object class?

By the use of statement: RegisterUserFunc

Q. 150: What is a Recovery Scenario?

Page 45: Qtp Interview Questions and answers

Recovery scenario gives you an option to take some action for recovering from a fatal error in the test.

The error could range in from occasional to typical errors. Occasional error would be like "Out of paper" popup error while printing something and typical errors would be like "object is disabled" or "object not found".

A test case have more then one scenario associated with it and also have the priority or order in which it should be checked.

151: What does a Recovery Scenario consists of?

Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup window, any test error, particular state of an object or any application error.

Action: Action defines what needs to be done if scenario has been triggered. It can consist of a mouse / keyboard event, close application, call a recovery function defined in library file or restart windows. You can have a series of all the specified actions.

Post-recovery operation: Basically defined what need to be done after the recovery action has been taken. It could be to repeat the step, move to next step etc....

Q. 152: When do we use a Recovery Scenario and when to use "on error resume next"?

Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won't occur in your

QTP script but could occur in the world outside QTP, again the example would be "out of paper", as this error is caused by printer device driver.

"On error resume next" should be used when you know if an error is expected and don’t want to raise it, you may want to have different actions depending upon the error that occurred.

Q. 153: What are Library Files or VBScript Files? And How do we associate a library file with a test?

Library files are files containing normal VBScript code.

The file can contain function, sub procedure, classes etc.... You can also use executefile function to include a file at run-time also.

To associate a library file with your script go to Test->Settings... and add your library file to resources tab.

Q. 154: When to associate a library file with a test and when to use execute file?

When we associate a library file with the test, then all the functions within that library are available to all the actions present in the test.

But when we use Executefile function to load a library file, then the function are available in the action that called executefile.

By associating a library to a test we share variables across action (global variables basically), using association also makes it possible to execute code as soon as the script runs because while loading the script on startup QTP executes all the code on the global scope.

Page 46: Qtp Interview Questions and answers

We can use executefile in a library file associated with the test to load dynamic files and they will be available to all the actions in the test.

Q. 155: What is the difference between Test Objects and Run Time Objects?

Test objects are basic and generic objects that QTP recognize.

Run time object means the actual object to which a test object maps.

Q. 156: Can I change properties of a test object?

Yes. You can use SetTOProperty to change the test object properties.

It is recommended that you switch off the Smart Identification for the object on which you use SetTOProperty function.

Q. 157: Can I change properties of a run time object?

No (but Yes as well).

You can use GetROProperty("outerText") to get the outerText of a object but there is no function like SetROProperty to change this property.

But you can use WebElement().object.outerText="Something" to change the property.

Q. 158: What is the difference between an Action and a function?

Action is a thing specific to QTP while functions are a generic thing, which is a feature of VB Scripting. Action can have a object repository associated with it while a function can't.

A function is just lines of code with some/none parameters and a single return value while an action can have more than one output parameters.

Q. 159: Where do we use function or action?

The answer to this question depends on the scenario.

If you want to use the OR feature then you have to go for Action only.

If the functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action.

Code specific to QTP can also be put into function using Descriptive Programming.

Decision of using function / action depends on what any one would be comfortable using in a given situation.

Q. 160: Which object is used to read from text file?

Scripting.FileSystemObject"

Page 47: Qtp Interview Questions and answers

161: How do you know the no of links in a web page?

Answer -1: By Page Check point,

Answer-2: By following set of statements:

Set PageDesc = Description.Create

PageDesc("Class Name").Value = "Link"

Set Pages = Browser("Mercury Interactive").Page("Mercury Interactive").ChildObjects(PageDesc)

Number_of_pages = Pages.Count

If Number_of_pages = 0 Then

Reporter.ReportEvent micDone, "No links was found in the web page, ""

End If

Q. 162: How can I check if a checkpoint passes or not?

This can be done by the following code.

Code:

chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))

if chk_PassFail then

MsgBox "Check Point passed"

else

MsgBox "Check Point failed"

end if

Q. 163: My test fails due to checkpoint failing. Can I validate a checkpoint without my test failing due to checkpoint failure?

This can be done by the following code.

Code:

Reporter.Filter = rfDisableAll 'Disables all the reporting stuff

chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))

Reporter.Filter = rfEnableAll 'Enable all the reporting stuff

Page 48: Qtp Interview Questions and answers

if chk_PassFail then

MsgBox "Check Point passed"

else

MsgBox "Check Point failed"

end if

Q. 164: How can I import an environment from a file on disk?

Environment.LoadFromFile "C:\Env.xml"

Q. 165: How can I check if an environment variable exist or not?

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.

Q. 166: How to connect to a database?

This can be done by the following code.

Code:

Const adOpenStatic = 3

Const adLockOptimistic = 3

Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")

Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD=

"

objRecordset.CursorLocation = adUseClient

objRecordset.CursorType = adopenstatic

objRecordset.LockType = adlockoptimistic

ObjRecordset.Source="select field1,field2 from testTable"

Page 49: Qtp Interview Questions and answers

ObjRecordset.ActiveConnection=ObjConnection ObjRecordset.Open 'This will execute your Query

If ObjRecordset.recordcount>0 then

Field1 = ObjRecordset("Field1").Value

Field2 = ObjRecordset("Field2").Value

End if

Q. 167: How do you create a Template for every Actions?

Write the template script as "ActionTemplate.mst" in DAT folder of QTP Installation

Q. 168: Test -->Settings --> Run tab belongs to which sheet:

Global Data sheet

Q. 169: What is the first step in editing an object in the object repository?

Enable Editing

Q. 170: When using recovery scenario wizard, the first phase is to specify?

Triggered Events

171: While merging the two object repositories, what are the filter options available for target object repository?

Show all objects & show only objects with conflicting descriptions

Q. 172: What all the types of Triggered Events?

Popup window, object state, test run error, application crash

Q. 173: The method used to retrieve data from the weblist object is?GetItem method

Q. 174: Global Data sheet is having no records and Local Data sheet is having two records, how many times the test executes?One time

Q. 175: Breakpoint is used for?

Breakpoint pauses the test execution at Current Step and then proceed to next step when instructed.

Q. 176: A dot followed by object in expert view displays?Child objects and methods

Q. 177: How did you find whether script used the smart Identification or not?

It will show in the test result pane as a Warning

Q. 178: How to handle the exceptions using recovery scenario manager in QTP?

Page 50: Qtp Interview Questions and answers

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

Q. 179: What is the use of Text output value in QTP?

Output values enable to view the values that the application takes during run time. When paramaterised, 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.

. 180: Give me 2 examples of ADODB objects?

1) Recordset and 2) Connection.