Wednesday 11 December 2013

QTP- Synchronization



Recording Modes in QTP
There are 3 ways of recording a qtp script-
1. Normal mode is the default mode of recording. It recognizes the objects regardless of their location or position in a window.
2. Analog mode records exact mouse movements and keyboard operations. The recorded steps in this mode are not editable. The script is recorded in the form of a track.
3. Low Level records all parent level objects as window test objects and all other as WinObject test objects. This recording mode is useful when objects are not recognized by recording in normal mode. This mode captures all the mouse clicks with respect to locations on the screen.


Synchronization In QTP:-
There are 3 ways of synchronization in qtp-
1. Using Wait() command in the script.
2. Setting default time for each qtp statement in File->setting->web->browser navigation time out.
3. Using WaitProperty() command, you can implement this property by clicking on object to be synchronized and then selecting “Insert->synchronization point” while recording the script.
Explanation: - wait() command will stop qtp from executing next statement for the time specified in the command. Navigation time out will wait for specified time limit if object does not appears in the application and waitproperty() will allow the next statement to execute only if the specified object appears or maximum time limit elapse.


Checkpoints in QTP
There are 9 types of checkpoints in qtp-
1. Standard Checkpoint compares the object values (attributes) captured during recording to the object values produced during a run session.
2. Image Checkpoint allows the users to check the properties of an image in the application. An image checkpoint can be created by inserting standard checkpoints. Implemented using standard check point option.
3. Bitmap Checkpoint we can check particular area of an image or web page as a bit map. Where as in image check point we cannot do it.
4. Table Checkpoint we can compare the content of a table recorded with the content of the table produced during the application execution. Table checkpoint can be implemented using standard checkpoints.
5. Accessibility Checkpoint recognizes area of a webpage that may not conform to the World Wide Web consortium (w3c). E.g. checks if an image include ALT properties, required by w3c web content accessibility guide line.
6. Text Checkpoint checks that a text is displayed in the appropriate place in an application or web page.
7. Page Checkpoint checks features of a web page such as load time; whether a page contains broken links, number of images e.t.c. Implemented using standard check point option
8. Database Checkpoints checks the values stored in a database.
9. XML Checkpoints can checks the content of an XML data files or documents that are part of a web application. XML check point option is supported for all add in environments.

Reusable Check points e.g. create a reusable bitmap check point to verify logo on all the pages of a website.
Steps to create a reusable checkpoint-
a) Record a checkpoint (only checkpoint statement) and open ->resources->object repository, in the OR window open File->Export and replace local objects, and save as .tsr file.
b) Record another script where you want to reuse this checkpoint, right click on action under resource from left pane of page and select ‘associate repository with the action’, browse the reusable repository created in first step. Now, existing checkpoint option will be enabled for your use in your Acton.
Note: To implement an existing checkpoint on an object the parent window of the object should be open (recording mode). (I am not sure about this please confirm)


QTP – Parameters and Variables
Input and output parameters can be stored and called using 4 ways as shown below-
1.Action Variables - Steps to store and retrieve values
a) Open a new test and add one more action, Insert->Call to New Action..
b) Open keyword view, right click on action1 and select “Properties window”.
c) Open parameter tab and add two input parameters a, b and one output parameter c , all variable of type Number. Click ‘Ok’ to save.
d) Open ‘Action1’ in expert view and paste the following statements –
a1= parameter("a")
a2= parameter("b")
parameter("c") = a1+a2

e) Open ‘Action2’ in expert view and paste the following statements and run ‘Action2’ only-
runaction "action1", oneiteration, 2,2,c
msgbox c

2.Data Table Parameters - allows us to create a data driven test that runs several times using the data values from the data table.
Steps-
a) Record a script e.g. login screen of flight reservation sample application.
b) Open ‘keyword view’ and click on ‘Value’ next to the ‘Agent Name field’.
c) Click on <#> symbol, select parameter radio button and click ‘Ok’ button.
d) Open ‘view->Data table’, data table will be displayed with a column having value entered during the script recoding.
e) Add values in table for parameterized and run the script. It will iterate the script with each of the value entered in the table.
3.Environment Variable Parameters- are of two types built in and user defined. Built in variables contain information about your system such as OS name, version, action name, result dir e.t.c.
E.g. this statement will display the OS name and result dir name
a= environment(“OS”) & environment(“ResultDir”)
msgbox (a)
User defined Variables are of two types Internal and External.
User defined Internal variables are defined with in a test and are accessible only to the test in which they are defined.
Steps-
a) Open File->settings->and click on “Environment” tab
b) Select “User defined” from “Variable Type” drop down.
c) Click on “+” and add a new variable with value e.g. variable c with value 10
We can access this variable anywhere in the script e.g.
msgbox(environment(“c”)) will display the value stored in internal variable. Also we can edit .xml file to add new variables and values.
User defined External variables are generated as .xml files and can be accessed in all the scripts using import option.
Steps-
a) Open File->settings->and click on “Environment” tab
b) Select “User defined” from “Variable Type” drop down.
c) Click on “+” and add a new variable with value e.g. variable c with value 10
d) Click on export button and save it.
e) Open a new test and go to File->settings->and click on “Environment” tab.
f) Check “Load variable and values from external file” check box and browse the file saved in step d.
We can access this variable anywhere in the script e.g.
msgbox(environment(“c”)) will display the value stored in external variable.
4.Random Number Parameter inserts any random number within the specified limit.
Steps-
a) Open a new test window in keyword view mode.
b) Right click on ‘Action1’ and select ‘Action properties’.
c) Enter an input parameter in action properties window of type Number and click ‘Ok’ e.g. variable name “a”
d) Now right click on ‘Action1’ from left pane and select ‘’Action call Properties’.
e) Click on ‘Parameter values ‘tab, click on ‘value’ next to the parameter.
f) A <#> symbol will appear, clicking on it will open value configuration option window.
g) Select ‘Parameter’ option button, open dropdown list box and select ‘Random Number’.
h) Define a range in the subsequent window and click ‘Ok’ to save it.
Note: - we can also use a table and environment variable.
msgbox(parameter("a")) run to view value assigned to the variable.



No comments:

Post a Comment