Sunday, 21 September 2014

QTP - Linear Framework

As discussed this approach involves simply writing the code as we record and keep going.

For example, if the operation that you have to verify is the creation of a new account in gmail the following will be the steps:
a) Open gmail.com
b) Click on ‘Create Account’
c) Enter the details
d) Verify the details
e) Create the account
'Open GMail
SystemUtil.Run "iexplore.exe", "http://www.gmail.com"
'Page Sync
Browser("Gmail").Page("Gmail").Sync
‘Click on create account
Browser("Gmail").Page("Gmail").WebLink(“Create Account”).Click
‘Enter the details
Browser("Gmail").Page("Google Accounts").WebEdit(“First Name”).Set “Swati”
Browser("Gmail").Page("Google Accounts").WebEdit(“Last Name”).Set “test”
‘Fill in several other details
‘Submit
Browser("Gmail").Page("Google Accounts").WebButton(“Next Step”).click

The above is an example of how a program that uses the linear method looks like. It is obvious at this point what the advantages and disadvantages of this method are.
Advantages:
  1. Simplicity. For beginner programmer this method is apt
  2. Time – It does not take a lot of time to create the test
  3. Very little planning is required
Disadvantages:
  1. No reusability at all
  2. If there is another script that verifies a certain aspect of the ‘Google Accounts’ Page then you will have to rewrite the code to launch gmail.com page too. So lots of repetition.
  3. All the data is directly embedded into code. The hard coding does not let the code be used for any other set of data.
  4. Error prone and maintenance is difficult
While the cons outweigh the pros, this method can be used when your aim is strictly to accomplish a task without validations.
The components or test assets in this kind of frameworks are:
  1. Test script
  2. Object repository (This can be avoided by using descriptive programming if needed)

No comments:

Post a Comment