Tuesday, 14 July 2015

FUNCTIONS & METHODS IN QTP


                                                            VB. SCRIPT
Q. Variable creates in 3 types of keywords?

  Dimension: which can hold any value?
  Private: a variable will be to the block hold; apart from that block can’t be used.
  Public: it can use anywhere.
  Variables: it is a name given to a memory location, which can hold a value and that can be   changed any no.of times in future if required.
 Declaration variables: in VB script one can declared a variable using the following key words.
i.                    Public ii. Private iii. Dimensional
   Naming convention of a variable:
                   I.            Variable name should be meaningful
                II.            It should not 256 characters
             III.            It should start with alphabets
             IV.            It should not include any periods (.)
                V.            It should not same as keywords (or) reserved words
    Option explicit: this statement restricts the usage of new variable in a program without  
       declaration.
      Advantage: i. the variable is reusable / reusability
                               ii. Easy to update the values
 Procedures: it is a set of reusable expenses to perform a specific task; procedure can be called      any no.of times in the same text / multiple texts.
           There are 2 types of text procedures
i. function procedure
ii. sub procedure
Function procedure & sub procedure can accept the values but function procedure only can return a   value.
Ø  Sub procedure will execute more faster than function procedure
Ø  So whenever the procedure no need to return any value then it is better to use sub procedure gather then sub procedure.
                                                                                                         METHODS
 Q. Methods with real time scenario?
1.Capture Bit map: It is used for capturing a snapshot of an object during the execution &stores it in the desired location.                                                                                                                                    Syn: window(“flight reservation”).captured bitmap “path of the location with a file name”            .bmp extension”
2. Exist Method: It is used for checking the objects is existing or not. If at all the object is existing then it will return true and allows the QTP for further execution. If at all the object is not existing then it will wait till the object exist, soon after the object exist then it will return true and allows the QTP for further execution. If at all the object does not exist even after the maximum time is specified than finally it will return falls and allows the QTP for further execution.                                                                                   Syn: var= window(‘flight reservation”).exist (12) msg box var
3. Wait property: it is used for making the tool to wait based on the object properties value are up to the maximum time.                                                                                                                                              Syn: Object hierarchy.Wait property(“property name”)., property value, extra time in              milli seconds.
4. Wait: wait statement is used for making the tool time is wait till the specify time is elapsed.
5. Click: click method is used for clicking on a specified method.
 0 is left, 1 is right, 2 is middle      
      Syn: object hierarchy.click[ (x,y)],button]
6. Double click: it is used for double clicking on an object
Syn: object hierarchy DBL[ (x,y)],button]
7. Set: it is used for performing the operation mainly following objects
Ø  Edit box: it is used for setting any value into the object box
Ø  Check box: set method is used for selecting and de selecting the checkbox
Ø  Radio Button: set method is used for selecting a radio button in a group
8. Activate method: it is used for activating a dialog or a window
Ø    Close Box: this method used for closing a window or a browser
Ø    Type: it is used for making the QTP perform some keyboard related operation
Ø    Set secure: it is used for setting the encrypted data into an edit box.
9. Set secure: it is used for setting the encrypted data into an edit box.
    Syn: O.H.Set Secure “encrypted String”
 10. to generate the encrypted string QTP has Provide a special tool by name password encoder:
    Navigation:  start  à programs  à QTP à Tools à Password encoder
11. Get RO Property: Runtime Object used for getting the runtime object properties value during the execution.
12. Get TO property: Text Object used for getting the TO property value during the execution.
13. Set Text object: it is used for setting the text object property value temporally during the                                           execution
Simple VB Script functions used for comparison and calculations:
   C int: it is used for converting any value into integer value
   C str: it is used for converting any value into String value
   C dbl: it is used for converting any value into decimal value
   C Bool: it is used for converting any value into Boolean value.
   L Trim: it is used for trimming the left side phase
   R Trim: it is used for trimming the right side phase
   Middle Trim: it is used for trimming the both side phase
   LEFT: it is used for getting the left side sub string
   RIGHT: it is used for getting the right side sub string
   Middle: it is used for getting the middle sub string
   Length: it is used for getting the length sub string
   Upper case: it is used for converting any String into Upper case
   Lower case: it is used for converting any String into Lower case
   Round: it is used for rounding a decimal value to nearest integer.
  Data table method: data table methods are used for performing the operation on the runtime
            data table during the execution.
  Add sheet: it is used for an extra sheet to the runtime data table
                 Syn: data table.add sheet “sheet name”
   Delete sheet: it is used for a specified sheet from the runtime data
            Syn: data table.delete sheet “sheet name”
   Import: it is used for importing the data present in the excel file to the runtime data table
            Syn: data table.import “ path of the excel file”
Import sheet: it is used for importing a specific sheet of data from the excel file to a specify        
 sheet  of Data in the runtime data type.
            Syn: data table.import sheet “ path of the excel file”
Export: it is used for exporting the completing data present in runtime data table to an excel  file
            Syn: data table.export “path of the excel file”
   Export sheet: it is used for exporting a specify sheet of data file to an excel file
            Syn: data table.export sheet “path of the excel file”
   Set current row: it is used for making the QTP focus on a specified row
            Syn: data table.Set current row
   Set next row: it is used for making the QTP focus on the next row of the currently focusable
            Syn: data table.next row
Set previous row: it is used for making the QTP focus on the previous row of the currently    focus row                      
            Syn: data table.Set previous row
   Get sheet: this method is used for making the QTP focus on a specified sheet
            Syn: data table.Get sheet
 Get row count: It is used for getting the row count of a specified sheet. By default it will get the    row-   count    of global sheet. If required we need to first focus the required sheet and than get  the row count.
            Syn: data table.get  rowcount
Value: it is used for getting a value from a specified sheet, specified column and current focused     
  Row.
            Syn: data table.value

 Input – Output parameters: it is a concept provided by QTP used for passing the values into the action and returning the values from the action. 
Depending upon the no.of values to be passed into the action that many no.of input parameter need to be declared, depending upon the no.of values need to be return from the action that many no.of  output values need to declare.                                                                                                                  
Navigation for declaring Input and Output parameter:
Ø  Activate the menu edit
Ø  Go to action
Ø  Select the option action properties
Ø  Select the parameter tab declare the desire no.of I/p O/p parameters
Ø  Click on ok

No comments:

Post a Comment