Pages

Thursday, 9 February 2012

HP QTP - QuickTest Prof. 10.0 Question Bank - Part 4

Q. 151: What is the purpose of Text and Text Area Output Values in QTP?
We can use text output values to output text strings displayed in an application. When creating a text output value, we can output a part of the object’s text. We can also specify the text before and after the output text.
We can use text area output values to output text strings displayed within a defined area of a screen in a Windows-based application.
<<<<<< =================== >>>>>>
Q. 152: What is the purpose of Table Output Values in QTP?
Table output values are a subset of standard output values, described above. We can use table output values to output the contents of table cells. For some types of tables, we can specify a row range from which to choose the table cells. During the run session, QTP retrieves the current data from the specified table cells according to the settings that we specified and outputs the values to the Data Table.
<<<<<< =================== >>>>>>
Q. 153: What is the purpose of Database Output Values in QTP?
We can use database output values to output the value of the contents of database cells, based on the results of a query that we define on a database. We can create output values from the entire contents of the result set, or from a part of it. During the run session, QTP retrieves the current data from the database and outputs the values according to the settings that we specified.
<<<<<< =================== >>>>>>
Q. 154: What is the purpose of XML Output Values in QTP?
We can use XML output values to output the values of XML elements and attributes in XML documents.
For example, suppose that an XML document in a Web page contains a price list for new cars. We can output the price of a particular car by selecting the appropriate XML element value to output.
<<<<<< =================== >>>>>>
Q. 155: How the output values are stored during the run sessions?
When we define an output value, we can specify where and how each value is stored during the run session. We can output a value to:
1) A test or action parameter
2) The run-time Data Table
3) An environment variable
Output values are stored only for the duration of the test, and are not saved with the test.
<<<<<< =================== >>>>>>
Q. 156: How do we store output values in Test and Action Parameters?
We can output a value to an action parameter, so that values from one part of a run session can be used later in the run session, or be passed back to the application that ran the test.
For example, suppose we are testing a shopping application that calculates our purchases and automatically debits our account with the amount that we purchased. We want to test that the application correctly debits the purchase amount from the account each time that the action is run with a different list of items to purchase. We could output the total amount spent to an action parameter value, and then use that value later in our run session in the action that debits the account.
<<<<<< =================== >>>>>>
Q. 157: How do we store output values in Run-time Data Table?
The option to output a value to the run-time Data Table is especially useful with a data-driven test that runs several times. In each repetition, or iteration, QTP retrieves the current value and stores it in the appropriate row in the run-time Data Table.
<<<<<< =================== >>>>>>
Q. 158: How do we store output values in Environment Variable?
When we output a value to an internal user-defined environment variable, we can use the environment variable input parameter at a later stage in the run session.
We can output values only to internal user-defined environment variables and not to external or built-in environment variables, which are read-only.
For example, suppose we are testing an application that prompts the user to input an account number on a Welcome page and then displays the user’s name. We can use a text output value to capture the value of the displayed name and store it in an environment variable.
<<<<<< =================== >>>>>>
Q. 159: In what situations we output a value for a step in a test action?
1) If at least one output parameter is defined in the action, the default output type is Test/action parameter and the default output name is the first output parameter displayed in the Action Properties dialog box.
2) If no output parameters are defined in the action, the default output type is Data Table and QTP creates a new Data Table output name based on the selected value.
<<<<<< =================== >>>>>>
Q. 160: What are the options available when outputting a value to the Data Table?
1) Name: Specifies the name of the column in the Data Table in which to store the value. QTP suggests a default name for the output. We can select an existing output name from the list, or create a new output name by using the default output name or entering a valid descriptive name.
We can define a new name containing letters, numbers, periods, and underscores. The first character of the output name must be a letter or an underscore. The output name must be unique in the Data Table sheet.
2) Location in Data Table: When outputting values for a test, specifies whether to add the Data Table column name in the global or current action sheet in the Data Table.
Q. 161: What is a Regular Expression?
A regular expression is a string that specifies a complex search phrase. By using special characters, such as a period (.), asterisk (*), caret (^), and brackets ([ ]), we can define the conditions of a search.
<<<<<< =================== >>>>>>
Q. 162: What is the use of Regular expressions in QTP?
Regular expressions enable QTP to identify objects and text strings with varying values. We can use regular expressions in situations like:
1) Defining the property values of an object in dialog boxes or in programmatic descriptions
2) Parameterizing a step
3) Creating checkpoints with varying values
For example, we can use a regular expression if we want to create a text checkpoint on a date text string, but the displayed date changes according to the current date. If we define the date as a regular expression, the checkpoint checks that the captured text string matches the expected date format, rather than checking the exact date value.
<<<<<< =================== >>>>>>
Q. 163: How do we use Regular Expressions in Checkpoints?
When creating a standard checkpoint to verify the property values of an object, we can set the expected value of an object’s property as a regular expression so that an object with a varying value can be verified.
For example, suppose we want to check that every window and dialog box in our application contains the name of our application followed by a hyphen (-) and a descriptive title. We can add a checkpoint to each dialog box object in our test to check that the first part of the title contains the name of our application followed by a hyphen.
<<<<<< =================== >>>>>>
Q. 164: What are the values for which we can define the regular expression?
We can define a regular expression for a constant value, a Data Table parameter value, an Environment parameter value, or a property value in a programmatic description.
<<<<<< =================== >>>>>>
Q. 165: What is the purpose of including Programming Statements in Tests?
We add steps which contain programming logic to the recorded framework just to increase the power and flexibility of the testing process.
<<<<<< =================== >>>>>>
Q. 166: What are the contents of the Programming Statements used in tests?
Programming statements usually contain:
1) Recordable test object methods: These are operations that a user can perform on an application.
2) Non-recordable test object methods: These are operations that users cannot perform on an application. We use these methods to retrieve or set information, or to perform operations triggered by an event.
3) Run-time methods of the object being tested.
4) Various VBScript programming commands that affect the way the test runs, such as conditions and loops. These are often used to control the logical flow of a test.
5) Supplemental statements, such as comments, to make our test easier to read, and messages that appear in the test results, to alert us to a specified condition.
<<<<<< =================== >>>>>>
Q. 167: How can we increase the Readibility of our Tests?
We can improve the readability of our test using With statements. We can instruct QTP to automatically generate With statements as we record. But even after our basic test is recorded, we can convert its statements, in the Expert View, to With statements—by selecting a menu command.
<<<<<< =================== >>>>>>
Q. 168: What is the use of Transaction Statement?
With the help of transaction statements we can measure the time i.e how long it takes certain parts of our test to run.
<<<<<< =================== >>>>>>
Q. 169: What steps can be defined in Step Generator?
1) Test object methods and properties
2) Utility object methods and properties
3) Calls to library functions, VBScript functions, and internal script functions
<<<<<< =================== >>>>>>
Q. 170: How can we incorporate decision-making into the tests?
We can control the flow of our test with conditional statements. Using conditional If...Then...Else statements, we can incorporate decision-making into our tests.
The If...Then...Else statement is used to evaluate whether a condition is true or false and, depending on the result, to specify one or more statements to run. Usually the condition is an expression that uses a comparison operator to compare one value or variable with another.
Q. 171: How can we do the nesting of If...Then...Else statement?
The If...Then...Else statement can be nested to as many levels as you need. It has the following syntax:
If condition Then statements [Else elsestatements] End If
Or, we can use the block form syntax:
If condition Then
[statements]
[ElseIf condition-n Then
[elseifstatements] . . .
[Else
[elsestatements]
End If
<<<<<< =================== >>>>>>
Q. 172: What is the use of Looping Statements?
We can control the flow of our test with loop statements. Using loop statements, we can run a group of steps repeatedly, either while or until a condition is True. We can also use loop statements to repeat a group of steps a specific number of times.
<<<<<< =================== >>>>>>
Q. 173: What type of Loop Statements are available in Keyword View?
1) While...Wend. Performs a series of statements as long as a specified condition is True.
2) For...Next. Uses a counter to perform a group of statements a specified number of times.
3) Do...While. Performs a series of statements indefinitely, as long as a specified condition is True.
4) Do...Until. Performs a series of statements indefinitely, until a specified condition becomes True.
<<<<<< =================== >>>>>>
Q. 174: What is the purpose of having comments in the tests?
A comment is an explanatory remark in a program. When we run a test, QTP does not process comments. We can use comments to explain sections of our tests to improve readability and to make them easier to update.
While editing our test, we can directly add comments in the Keyword View or in the Expert View. We can also add comments to function libraries. We can modify comments at any time directly in the Keyword View or the Expert View, or using the Comment Properties dialog box.
<<<<<< =================== >>>>>>
Q. 175: How can we add the same comment to every action that we create?
We can add the same comment to every action that we create, by adding the comment to an action template.
<<<<<< =================== >>>>>>
Q. 176: What is Synchronization of Tests in QTP?
Synchronization activity in the test ensures that QTP waits until our application is ready before performing a certain step. This is helpful in handling anticipated timing problems like:
When we run a test, our application may not always respond with the same speed. For example, it might take a few seconds:
1) For a progress bar to reach 100%
2) For a status message to appear
3) For a button to become enabled
4) For a window or pop-up message to open
<<<<<< =================== >>>>>>
Q. 177: What is a Synchronization Point in QTP?
A synchronization point, instructs QTP to pause the test until an object property achieves the value we specify. When we insert a synchronization point into our test, QTP generates a WaitProperty statement in the Expert View.
<<<<<< =================== >>>>>>
Q. 178: What are the ways by which we can make QTP to wait?
1) By inserting a synchronization point.
2) By inserting Exist or Wait statements that instruct QTP to wait until an object exists or to wait a specified amount of time before continuing the test.
3) By modifying the default amount of time that QTP waits for a Web page to load.
4) By increasing the default timeout settings for a test to instruct QTP to allow more time for objects to appear.
<<<<<< =================== >>>>>>
Q. 179: What is the purpose of creating Synchronization Points in QTP?
If we do not want QTP to perform a step or checkpoint until an object in our application achieves a certain status, we should insert a synchronization point to instruct QTP to pause the test until the object property achieves the value we specify or until a specified timeout is exceeded.
For example, suppose we record a test on a flight reservation application. We insert an order, and then we want to modify the order. When we click the Insert Order button, a progress bar is displayed and all other buttons are disabled until the progress bar reaches 100%. Once the progress bar reaches 100%, we record a click on the Update Order button.
<<<<<< =================== >>>>>>
Q. 180: What happens if we don't use Synchronization Point in QTP?
Without a synchronization point, QTP may try to click the Update Order button too soon during a test run - if the progress bar takes longer than the test’s object synchronization timeout, and the test will fail.
Q. 181: What is the purpose of Expert View in QTP?
In QTP, tests are composed of statements coded in the Microsoft VBScript programming language. The Expert View provides an alternative to the Keyword View for testers who are familiar with VBScript.
In the Expert View, we can view an action in VBScript. If we are familiar with VBScript, we can add and update statements and enhance our tests and function libraries with programming. This enables us to increase a test’s power and flexibility.
<<<<<< =================== >>>>>>
Q. 182: What is the main difference between Keyword View & The Expert View in QTP?
1) In the Keyword View, QTP displays information about each step and shows the object hierarchy in an icon-based table.
2) In the Expert View, QTP displays each step as a VBScript line or statement. In object-based steps, the VBScript statement defines the object hierarchy. In the Expert View, an object’s description is displayed in parentheses following the object type.
<<<<<< =================== >>>>>>
Q. 183: How can we insert a checkpoint or output value statement in Expert View Manually?
Because the statement displayed in the Expert View is a reference to the stored information, hence we cannot insert a checkpoint or output value statement in the Expert View manually and we cannot copy a Checkpoint or Output statement from the Expert View to another test.
<<<<<< =================== >>>>>>
Q. 184: What are the various ways of generating Statements in Expert View?
We can generate statements in the following ways:
1) We can use the Step Generator to add steps that use methods and functions.
2) We can manually insert VBScript statements that use methods to perform operations.
3) When we start to type a VBScript keyword in the Expert View or a function library, QTP automatically adds the relevant syntax or blocks to our script, if the Auto-expand VBScript syntax option is enabled.
<<<<<< =================== >>>>>>
Q. 185: What is IntelliSense in QTP?
IntelliSense is a statement completion feature of QTP which helps us in selecting the test object, method, property, or collection for our statement and to view the relevant syntax as we type in the Expert View or a function library.
<<<<<< =================== >>>>>>
Q. 186: What is the purpose of Auto-expand VBScript syntax option in QTP?
Auto-expand VBScript syntax is an option avaailable in QTP. When this option is enabled and we start to type a VBScript keyword in the Expert View or a function library, QTP automatically recognizes the first two characters of the keyword and adds the relevant VBScript syntax or blocks to the script. For example, if we enter the letters if and then enter a space at the beginning of a line, QTP automatically enters:
If Then
End If
The Auto-expand VBScript syntax option is enabled by default.
<<<<<< =================== >>>>>>
Q. 187: What is the purpose of bookmarks in our Test Actions?
We can use bookmarks to mark important sections in our action or function library so that we can navigate between the various parts more easily. In tests, bookmarks apply only within a specific action; they are not preserved when we navigate between actions and they are not saved with the test or function library.
<<<<<< =================== >>>>>>
Q. 188: What is the meaning of error message "Expected end of statement" while running a test?
When we receive an "Expected end of statement" error message while running a step in our test or function library, it may indicate that we need to add parentheses around the arguments of the step's method.
<<<<<< =================== >>>>>>
Q. 189: What are the types of Programmatic Descriptions?
1) Static Programmatic Description: Here we list the set of properties and values that describe the object directly in a VBScript statement. Using the Static type to enter programmatic descriptions directly into our statements may be easier for basic object description needs.
2) Dynamic Programmatic Description: Here we add a collection of properties and values to a Description object, and then enter the Description object name in the statement. In most cases, using the Dynamic type provides more power, efficiency, and flexibility.
<<<<<< =================== >>>>>>
Q. 190: How can we retrieve all objects located inside a Parent Object?
We use the ChildObjects method to retrieve all objects located inside a specified parent object, or only those child objects that fit a certain programmatic description.
To retrieve this subset of child objects, we first create a description object and add the set of properties and values that we want our child object collection to match using the Description object.
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.

0 comments:

Post a Comment