Pages

Custom Search

HP QTP Question Database: Q. 171 to 180

HP QTP Question Database: Q. 171 to 180

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.

No comments: