Pages

Custom Search

HP QTP Question Database: Q. 191 to 200

HP QTP Question Database: Q. 191 to 200

Q. 191: What is the advantage of using Index Property in Programmatic Descriptions?

The index property is quite useful test object property for uniquely identifying an object. The index test object property identifies an object based on the order in which it appears within the source code, where the first occurrence is 0.

Index property values are object-specific.

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

Q. 192: How can we run standard DOS commands in QTP tests?

We can run standard DOS commands in our QTP test or function using the VBScript Windows Scripting Host Shell object (WSCript.shell). For example, we can open a DOS command window, change the path to C:\, and run the DIR command using the following statements:

Dim oShell

Set oShell = CreateObject ("WSCript.shell")

oShell.run "cmd /K CD C:\ & Dir"

Set oShell = Nothing

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

Q. 193: What is the advantage of having User-Defined Functions?

If we have segments of code that we need to use several times in our tests, we create a user-defined function.

A user-defined function encapsulates an activity (or a group of steps that require programming) into a keyword. By using user-defined functions, our tests become shorter, and easier to design, read, and maintain. We can then call user-defined functions from an action by inserting the relevant keywords into that action.

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

Q. 194: What is a Function Library?

A function library is a Visual Basic script containing VBscript functions, subroutines, modules, and so forth.

We can use QTP to modify and debug any existing function libraries (such as .vbs or .txt files).

Using QTP, we can define and store our user-defined functions in a function library (saved as a .qfl file, by default)

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

Q. 195: What are the modes available to open a function library?

We can open a function library, only if you have read or read-write permissions for the file. We can open a function library in following two modes:

1) Edit Mode: Enables us to view and modify the function library. While the function library is open on our computer, other users can view the file in read-only mode, but they cannot modify it.

2) Read-only mode: Enables us to view the function library but not modify it. By default, when we open a function library that is currently open on another computer, it opens in read-only mode.

We can also open a function library in read-only mode if we want to review it, but we do not want to prevent another user from modifying it.

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

Q. 196: How can we debug a Function Library?

Before we can debug a function library, we must first associate it with a test and then insert a call to at least one of its functions. For example, we can use the Debug Viewer to view, set, or modify the current value of objects or variables in our function library.

We can step into all the functions, set breakpoints, stop at breakpoints, view expressions, and so forth.

We can begin debugging from a specific step, or we can instruct QTP to pause at a specific step.

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

Q. 197: What is Function Definition Generator?

Function Definition Generator is a feature of QTP, which enables us to generate definitions for new user-defined functions and add header information to them.

We can then register these functions to a test object, if needed. We fill in the required information and the Function Definition Generator creates the basic function definition for us. After we define the function definition, we can insert the definition in our function library and associate it with our test, or we can insert the definition directly in a test script in the Expert View. Finally, we complete the function by adding its content i.e. code.

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

Q. 198: What methodology QTP follows while running the tests?

If our test contains a global Data Table parameter, QTP runs the test once for each row in the Data Table.

If our test contains a Data Table parameter for the current action data sheet, QTP runs the action once for each row of data in that action data sheet.

We can also specify whether to run the first iteration or all iterations, for the entire test or for a specific action in the test; or to run the iterations for a specified range of data sets.

We can run the entire test from the beginning, or we can run part of it. We can designate certain steps as optional, to enable QTP to bypass them instead of aborting the run if these steps do not succeed.

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

Q. 199: How can we do part running of the test?

We can use the Run from Step option to run a selected part of our test.

This enables us to check a specific section of our application or to confirm that a certain part of our test runs smoothly.

With this option the test is run from the Expert View & test is made to run from the selected step until the end of the action. Using Run from Step in this mode ignores any iterations.

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

Q. 200: What are Optional Steps in testing?

An optional step is a step which is not required to successfully complete a run session.

For example, suppose that when recording a test, the application we are testing prompts us to enter a user name and password in a login window. When we run the test, however, the application does not prompt us to enter our user name and password because it retained the information that was previously entered. In this case, the steps that were recorded for entering the login information are not required and should, therefore, be marked optional.

No comments: