Friday, April 12, 2013

Splitting Action

We can split an action that is stored with your test into two sibling actions or into parent-child nested actions. When you slit an action, the second action starts with the step that is selected when you perform the split action operation.

When do you split an action in your test that uses a local object repository?

1)    Quick Test makes a copy of the local object repository.
2)    The two actions have identical local object repositories containing all of the objects that were in the original local object repository.
3)    If we add objects to one of the split actions, the new objects are added only to the corresponding local object repository.

Navigation to Split an Action
    Select the step before which you want the new action to begin -> Choose Edit -> Actions -> Split Action -> Choose required options (Independent of each other or Nested) -> modify the name -> Click OK

When Splitting Action is not possible?


Split of action is not possible in following scenarios:
 

1.    An External Action is selected
2.    The first step of an action is selected
3.    while recording test
4.    while running test
5.    Working with read only test.

Script: Write a script to retrieve all Action names
    Set aomObj=CreateObject(“QuickTest.Application”)
    Set aomObjList=aomObj.Test.Actions
    Msgbox aomObjList.Count
    For val=1 to aomObjList.Count
        Msgbox aomObjList(val).Name
    Next


Script: Write a Script to add shared object repository for Action1 during runtime

    Set objAom=CreateObject("QuickTest.Application")
Set objRep=objAom.Test.Actions("Action2").ObjectRepositories
ObjRep.Add "D:\Vamsi\Automation\QTP training\loginflight.tsr"


Script: Write a script to retrieve count all associated shared repository in all actions in a test.
   
    Set aomObj=CreateObject("QuickTest.Application")
cnt1=0
Set aomObjList=aomObj.Test.Actions
msgbox aomObjList.Count
For val=1 to aomObjList.Count
        Set cnt=aomObj.Test.Actions(aomObjList(val).Name).ObjectRepositories
        cnt1=cint1+cnt.Count
Next
msgbox cnt1


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

Changing Action properties




In corresponding action right click -> Actions -> Select Action properties

                                                OR

Keyword view -> right click on required Actions -> Select Action properties.


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com



Inserting Calls to Actions

There are three types of actions calls that can be inserted

1.    An “Insert Call to New…” will create a new action in the current test.
2.    An “Insert Call to Copy…” inserts a copy of the specified action into the current test. If the copied action uses checkpoints and OR objects, these are also copied.
3.    An “Insert Call to Existing…” allows insertion of a call ot a reusable action present in the current test or in another test.

Navigation for Insert Call to Copy action:
Insert menu -> Call to Copyof Action… -> Browse the test from which the action to be called -> Select the action -> Select the location -> click OK
                        OR
Place the curser where do u want to call ->right click on test pane -> Action -> select Call to Copyof Action… -> Browse the test from which the action to be called -> Select the action -> Select the location -> click OK

Navigation for Insert Call to Existing action:
Insert menu -> Call to Existing Action… -> Browse the test from which the action to be called -> Select the action -> Select the location -> click OK
                        OR
Place the curser where do u want to call ->right click on test pane -> Action -> select Call to Existing Action… -> Browse the test from which the action to be called -> Select the action -> Select the locaiton -> click OK

Note: When using call to existing action, the action that we want to call to be declared as a reusable action.


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

Types of Actions

There are three types of actions:

1.     Normal/Non-reusable action : An action that can be called only in the test in which is resides and can be called only once 

2.     Reusable action: An action that can be called multiple times by the test in which it resides and can also be called by other tests. 

3.     External reusable action : A reusable action stored in another test. External actions are read-only in the calling test, but we can choose to use a local, editable copy of the Data Table information for the external action.


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com 

Actions

Actions are used to divide scripts into logically related groups of QTP statements. They are similar to VB Script functions
QTP Scripts are maintained with scenario and each module of the script is called as action.
Every Script will have one default action is Action1
A script can have max 255 actions.
Every action of the script will have a sheet in the data table and the sheet name will be same as that of action.
Every action can access the data from its own action sheet of global sheet.
Actions are used for easy implementation of script re-usability.
Actions maintains scripts and repositories also

Creating a new Action:

    Insert menu → Call to New Action → ( Insert Call to New Action window opens ) , Enter Action name → Select required location ( At end of the test, After the current step ) → Click OK button.
                        Or
    Right click on script editor → Select Actions → Insert Call to New → ( Insert Call to New Action window opens ) , Enter Action name → Select required location ( At end of the test, After the current step ) → Click OK button.


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

Environment variables

How is an environment variable defined at run time?


           Environment(“Test Name”)=val

                 Note : The act of assigning a value to a non-existent environment variable causes QTP to implicitly create and initialize the variable.



How external variables laoded from an external XML file during run time?

          Environment.LoadFromFile “path”

How is an environment variable cleared or destroyed?

          Environment(“Test Name”)=”test”
          Environment(“Test Name”)=Nothing
 
Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com 

Environment Variables

QTP Environment variables are variables which we can share information across actions, recovery scenarios and libraries.

These environment variables are different from Windows environment variables.

Windows environment variable are available to all the programs running on the machine while QTP environment variables are only available to a test script running at run-time.

Types of Environment variables:

There are three types of Environment variables in QTP:

1.       Built-in :  QTP provides a variety of environment variables that define information such as the currently executing test’s name, the test’s path, the operating system type and its verision and the local host name.

To Check Built-in environment variables:

File -> Settings -> Environment tab -> From Variable type drop down select ‘BuiltIn’

Ex: msgbox environment(“OS”)

     Msgbox environment(“Prod Dir”)

2.       User defined Internal :  These variables are defined in a test and saved with the test. These variables can be modified during run-time.

Accessing User defined internal variables:

File -> Settings -> Environment tab -> From Variable type drop down select ‘User defined’ -> Click on ‘+’ button and enter environment variable name and value -> click on OK button.

3.       User Defined External : 
These variables are defined in an external environment files. These variables are read-only and cannot be modified at run-time. The external file can be associated with the test.

Accessing User defined external variables:

File -> Settings -> Environment tab -> From Variable type drop down select ‘User defined’ -> Click on ‘+’ button and enter environment variable name and value -> Click on Export button and save the corresponding file. -> Open a new test -> File -> Settings -> Environment tab -> From Variable type drop down select ‘User defined’ -> Check the Load variables and values from external files check box -> browse the corresponding environment file. -> Click Apply -> Click OK
Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com

AI in Software Testing: How Artificial Intelligence Is Transforming QA

For years, software testing has lived under pressure: more features, faster releases, fewer bugs, smaller teams. Traditional QA has done her...