Tuesday 20 March 2012

Working With Multiple Browsers in QTP

We are aware of that multiple instances of QTP can't be running on a single machine. But by using QTP we can work with multiple instances of the Application Under Test. For example, QTP can handle multiple browsers or multiple applications at a time.


We can work with 2 applications at a time even without stopping the recording. We should make sure that we configured both Record and Run on any opened applications(Both Windows and Web) under Automation>Record And Run Settings> Select the radio button "Record and Run on any application for both Windows and Web".


We have to keep it in our mind that we can't run multiple instances of QTP on a single machine.But we can handle multiple browsers or applications by using single QTP instance.

Step Generator In QTP

Step Generator is a feature and Library of functions which is used for generating the Recordable or Non-Recordable steps.


We can launch the step generator by anyone of the following methods.

Method#01:
By navigating to Insert Menu > Step Generator.
Method#02:
By pressing F7 short cut key.


The Step Generator enables us to add steps by selecting a wide range context sensitive options and to enter the required values.We can define the steps than can use:
  • Test object operations(Tests only)
  • Utility Object operations
  • Calls to Library functions
  • Calls to VBScript functions
  • Calls to Internal functions
For example, we can create a step to check whether a particular object exists as well as returned value of a function as output value or as part of the conditional statement.


We can parameterize any of the values in out step.Also, we can use the Step Generator to insert steps in function libraries. However we can't use the Step Generator to access the objects names or collections or the list of libraries.


We need to know that where the step needs to be inserted in out script before adding the step.Once the Step Generator is opened we need to select the category for step operation(Test/Utility object, Function) and the required object or the function library. Then we can select the appropriate operation(method, property or function), define arguments and return values.We can parameterizing required by the functions.


The Step Generator is used to insert the correct steps at our test. We can also insert another steps without closing the Step Generator.We can use the Step Generator in Keyword/Expert View or from Active Screen.

Measuring Transaction Time In QTP

In some situations we may need to track the time taken for the script execution or need to track the time taken for a functionality to completed. For example, we can take a Networking application. Assume that we are running the discovery service to identify the list of devices available on the selected network. Here we need to measure the time taken to discover all the devices.

QTP provides a Utility object called "Services" which is used to measure the transaction time. Assume that we are going to track the Discovery service of a networking application.

'* Starting transaction Time
Services.StartTransaction "DiscoveryService"
'* Logic for Discovery Service goes here
'* Tracking End time
Services.EndTransaction "DiscoveryService" 

We can find StartTransaction and EndTransaction under Insert menu. We can also have n-number of transaction points in the same script. But we need to make sure that the tracking is happening properly,

We can also measure the time by using Timer function.Timer is VBScript in built function. We can take the same discovery service for example.

'* Starting transaction Time 
starttime= Timer '* It returns the time elapsed since 12 A.M mid night in seconds
'* Logic for Discovery Service goes here 
'* End transaction Time 
endtime = Timer
'* Calculating final time
finalfime = endtime- startrime

Here starttime,endtime,endtime are variables. We can use any variable based on the wish.

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | JCPenney Coupons