HP QTP Question Bank: Q. 161 to 170
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 valuesFor 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.
Continue to Next Part : Q 171 to 180
An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.