Date post: | 04-Apr-2018 |
Category: |
Documents |
Upload: | krishna-keshav |
View: | 214 times |
Download: | 0 times |
of 25
7/29/2019 QTP-PPT-DAY1-CHAP5
1/25
Chapter 5
Synchronization
7/29/2019 QTP-PPT-DAY1-CHAP5
2/25
Objectives
After completing this chapter, you will beable to:
Define synchronization. Examine when and where synchronization
is most helpful.
Add a synchronization step for a specifiedobject.
7/29/2019 QTP-PPT-DAY1-CHAP5
3/25
QuickTest Professional Workflow
Prepare1
Create2
Verify & Enhance
3Integrate
4
Setup fortest automation Create basic test
Document manualtest steps
Check applications/environment stability
Check that data isvalid
Record useractions
Confirm successfulplayback
Use ObjectRepository
Enhance basic test
Add synchronization
Insert checkpoints
Data drive the test
Pass data
Build integratedtest sets
Integrate tests
Figure 5-1 Synchronization in the Workflow
So far we have created a basic test. We should enhance the test by addinga synchronization point.
7/29/2019 QTP-PPT-DAY1-CHAP5
4/25
What is Synchronization?
Figure 5-2 QuickTest Waits For Insert Done Visual Cue
7/29/2019 QTP-PPT-DAY1-CHAP5
5/25
What is Synchronization?
Synchronization is a step added to a test thatinstructs QuickTest to wait for the state of aproperty on a particular object to change beforeproceeding to the next step in the test.
Just like a manual tester will wait for a visual cueto know when the AUT has completed itsprocessing, we instruct QTP to wait for a cueprior to moving on to the next step in the test.
A synchronization point allows the test to pause
while an application process completes, beforemoving on to the next step.
7/29/2019 QTP-PPT-DAY1-CHAP5
6/25
Some Visual Cue Examples
A progress bar reaches 100% completion.
A status message appears.
A button becomes enabled.
A window opens and is ready for dataentry.
A pop-up message appears in response toan operation.
7/29/2019 QTP-PPT-DAY1-CHAP5
7/25
Examine the Application
Figure 5-3 Synchronize on the Progress Bar
7/29/2019 QTP-PPT-DAY1-CHAP5
8/25
Examine the Application
QTP has a global object synchronization timeout. Whena step attempts to interact with an object that is notavailable when the application is still processing, QTPwill wait for either the object to become available or forthe object synchronization timeout to occur.
If one process takes considerably longer than others, theglobal synchronization timeout may not be long enoughfor the process to complete. And in this case, the nextstep might fail. To give these longer processes enoughtime to complete, we add a synchronization point toextend the time QTP will wait before moving on to thenext step.
7/29/2019 QTP-PPT-DAY1-CHAP5
9/25
Wait times often occur before an objectbecomes available for the next step.
For example, in the Flights application, once theInsert Order button has been clicked, a progressbar must complete before the reservation OrderNo. will be displayed. The progress bar mayrequire additional time before the test can
proceed. If insufficient time is allocated for thesespecial circumstances, the test may fail.
Examine the Application
7/29/2019 QTP-PPT-DAY1-CHAP5
10/25
The error message, Object not enabledappears if QuickTest is running a testand proceeds to the next step before the
previous step has fully processed. QTP will wait only as long as it takes for
the process to complete, not necessarily
the full timeout.
Examine the Application
7/29/2019 QTP-PPT-DAY1-CHAP5
11/25
Setting General Standard CheckpointOptions
Checkpoint timeout. Specifies the time interval (in seconds) during which
Quick Test attempts to perform the checkpoint successfully. Quick Test
continues to perform the checkpoint until it passes or until the timeout
occurs. If the checkpoint does not pass before the timeout occurs, the
checkpoint fails. For example, suppose it takes some time for an object toachieve an expected state. Increasing the checkpoint timeout value in thiscase can help ensure that the object has sufficient time to achieve thatstate, enabling the checkpoint to pass (if the data matches) before themaximum timeout is reached.
If you specify a checkpoint timeout other than 0, and the checkpoint fails,the Test Results window displays information on the checkpoint timeout.
7/29/2019 QTP-PPT-DAY1-CHAP5
12/25
Add a Synchronization step whileRecording
Figure 5-4 Insert a Synchronization Point
7/29/2019 QTP-PPT-DAY1-CHAP5
13/25
Synchronization points instruct QuickTest topause until an object property achieves aspecified value.
The easiest way to add a synchronizationpoint is while recording. Always add the synchronization point
immediately after the step to be synchronized.
From the QTP menu bar, choose INSERTSTEPSYNCHRONIZATION POINT. Step timeout values add to the global values.
Add a Synchronization step whileRecording
7/29/2019 QTP-PPT-DAY1-CHAP5
14/25
Object Synchronization
GlobalTimeout
Figure 5-5 Object Synchronization Timeout
Sync StepTimeout
Maximum Total
Timeout
Script
Continues
Script
Continues
Global + Sync Step = Maximum TotalTimeout Timeout Timeout
Test
run 2
Test
run 1
OK
Error
7/29/2019 QTP-PPT-DAY1-CHAP5
15/25
Object Synchronization
When the synchronization timeout is setfor a step, this value is added to theglobal timeout value.
QTP has a default timeout between teststeps of 20000 milliseconds (20seconds).
May not wait for the full timeout to arrive.
7/29/2019 QTP-PPT-DAY1-CHAP5
16/25
Object Synchronization
For example: Lets say an object has a globaltimeout of 30 seconds and a synchronizedtimeout of 30 seconds. If the actual time it takesfor QTP to recognize the object is 40 seconds,
the test will move to the next step after 40seconds.
This feature applies to environments that do notsynchronize automatically.
Examples of auto-synchronizing environments:
- Web; SAP; TE
7/29/2019 QTP-PPT-DAY1-CHAP5
17/25
Understanding and Using RegularExpressions
Regular expressions enable Quick Test to identify objects and text stringswith varying values. You can use regular expressions when:
defining the property values of an object in dialog boxes or inprogrammatic descriptions
parameterizing a step creating checkpoints with varying values
For example, you can use a regular expression if you want to create a text
checkpoint on a date text string, but the displayed date changes according
to the current date. If you define the date as a regular expression, the
checkpoint checks that the captured text string matches the expected dateformat, rather than checking the exact date value.
A regular expression is a string that specifies a complex search phrase. By
using special characters, such as a period (.), asterisk (*), caret (^), and
brackets ([ ]), you can define the conditions of a search.
7/29/2019 QTP-PPT-DAY1-CHAP5
18/25
Using Regular Expressions for PropertyValues
If you expect the value of a property to change in a predictable way during
each run session, you can use regular expressions when defining or
parameterizing property values, for example, in the Object Repository
window, or in programmatic descriptions.
For example, your site may include a form in which the user inputs data and
clicks the Send button to submit the form. When a required field is not
completed, the form is displayed again for the user to complete. When
resubmitting the form, the user clicks the Resend button. You can definethe value of the buttons name property as a regular expression, so that
Quick Test ignores variations in the button name when clicking the button.
7/29/2019 QTP-PPT-DAY1-CHAP5
19/25
Using Regular Expressions inCheckpoints
When creating a standard checkpoint to verify the property values of an
object, you can set the expected value of an objects property as a regular
expression so that an object with a varying value can be verified.
For example, suppose you want to check that every window and dialog box
in your application contains the name of your application followed by a
hyphen (-) and a descriptive title. You can add a checkpoint to each dialog
box object in your test to check that the first part of the title contains the
name of your application followed by a hyphen.
When creating a text checkpoint to check that a varying text string is
displayed on your Web site or application, you can define the text string asa regular expression.
7/29/2019 QTP-PPT-DAY1-CHAP5
20/25
Using Regular Expressions inCheckpoints
For example, when booking a flight in the Mercury Tours sample Web site,
the total cost charged to a credit card number should not be less than $300.
You define the amount as a regular expression, so that Quick Test willignore variations in the text string as long as the value is not less than $300.
You can apply the same principles to any checkpoint type whose dialog box
contains a Configure Value area similar to that described in Configuring
Constant and Parameter Values.
For example, for table checkpoints you can set cell values as regular
expressions, and for XML checkpoints you can set attribute or elementvalues as regular expressions. For more information on specific checkpoint
types, see the relevant chapter for the checkpoint type.
7/29/2019 QTP-PPT-DAY1-CHAP5
21/25
Defining Regular ExpressionsYou can define a regular expression for a constant value, a Data Table
parameter value, an Environment parameter value, or a property value in aprogrammatic description.
You can define a regular expression by entering the regular expression
syntax for the string in the Value box in the Constant Value Options dialog
box or the Parameter Options dialog box. You instruct Quick Test to treatthe value as a regular expression by selecting the Regular Expressioncheck box.
By default, Quickest treats all characters in a regular expression literally,
except for the period (.), hyphen (-), asterisk (*), caret (^), brackets ([ ]),
parentheses (()), dollar sign ($), vertical line (|), plus sign (+), question mark(?), and backslash (\). When one of these special characters is preceded bya backslash (\), Quick Test treats it as a literal character.
7/29/2019 QTP-PPT-DAY1-CHAP5
22/25
Review Questions
1. What is the function of a synchronizationpoint?
a) To update test data
b) To give more time for an object to processbefore moving onto the nest step
c) To set an environment variable for an object
7/29/2019 QTP-PPT-DAY1-CHAP5
23/25
2. What is the default time QuickTest waits
for a step to process?a) 2 minutes
b) 20 seconds
c) 2 milliseconds
7/29/2019 QTP-PPT-DAY1-CHAP5
24/25
3. What operation in the Flight AUT might
require synchronization?a) Entering the passenger name
b) Deleting an order
c) Inserting an orderd) Selecting the business class
7/29/2019 QTP-PPT-DAY1-CHAP5
25/25
4. How long will QTP wait if:
- synchronization timeout is set to 10seconds and the global timeout is set to40 seconds, but the actual time for theobject to be recognized is 25 seconds:
a) 10
b) 40
c) 50
d) None of the above