A part of a task is called as an Action. They are mainly used to divide a long test into multiple small logical units to increase the re-usability of tests by reducing the duplication of script. The complexity of script can also be reduced when they are divided into small logical units.
There are three different types of actions:
a. Reusable action is the one which can be reused any number of times by any test
b. Non reusable action is the one which can be used by only the test that the action is stored with and also this can be used only once.
c. External Action: If a reusable action is called from a different test using Call to existing method, then the action gets displayed in a read-only mode in the called-test and this read-only action is called as External Action.
Assume that you need to create three different tests for an email application such as composing a mail, checking inbox mails and verifying sent items. Analyze the three scenarios. The things you need to do are:
Composing an Email:
Login
Compose email
Logout
Compose email
Logout
Checking in box:
Login
Verification of inbox
Logout
Verifying Sent items:
Login
Verifying sent items
Logout
In all the three scenarios you are logging into application and then logging out from the application. Instead of creating each scenario in a single test, if you divide first test into three separate actions (Login, Compose mail, Logout), then Login and logout actions can be used in other tests and this will reduce the duplication of code.
What are the different ways of calling actions? Explain their differences.
There are two methods in calling actions:
1. Call to existing action
2. Call to copy of action
Call to Existing action:
This method just calls the original action. A read-only view of the original action can be seen in the calling action. Any changes made to the original action will be reflected here as well. For calling any action using this method, it has to be made sure that the original action is reusable action. If an object repository is associated with the original action, then the object repository can also be seen in read-only mode in Object repository window.
Call to copy of action:
This method creates a copy of original action. Once the copy is created, it is independent of original action. Whatever changes made to the original action will not be reflected here. For calling any action using this method, it is not necessary that the called action should be reusable. Object repository will also be copied if original action has any.
What are the difference between Actions and Functions?
- Actions are specific to QTP where as Functions can be used by any programming language.
- Actions are associated with object repository where as function will not have any object repository.
- Functions can be called from actions where as actions can’t be called from functions.
- Function can return only one where as Action can return multiple values.
- File extension for Functions is .vbs where as for actions it is .mts
- Syntax for calling a function is – Call Function(Function Name) where as for Action RunAction “Action Name”, alliterations
No comments:
Post a Comment