Useful Automation framework
Test Model for this project is basically divided into 4 components:
1. Test Data: Project use excel sheet as database for test data. In test data we store different environment parameters like user details, URL etc (so that we can update them without opening scripts), test data for different iterations of testing and external parameters to verify results. Example from excel sheet:
URL = URL Link
User = Kansara
2. Scripts: Test script which contains entire flow & logic of testing.
3. Reports: Collection of different results for different execution.
4. Support Scripts/Functions: Supports scripts & functions which help in maintaining scripts & flow process like managing reports, similar functions etc.
Scripting structure
Scripting structure is simple & straightforward. Certain rules are followed while scripting which are following:
Scripting structure is simple & straightforward. Certain rules are followed while scripting which are following:
1. Nomenclature of scripts: All local variables should be start with “v_” & their names should be self explanatory e.g. v_date is used for storing date.
2. Comments: Write one test condition in single block of comments & provide script & test logic clearly in comments. Example:
'---- Checkpoints to verify login page ----
Browser("Applied Research International").Page("Applied Research International_6").Check
CheckPoint("Password")
Browser("Applied Research International").Page("Applied Research International_4").Image("changeuser_btn").Click
2. Comments: Write one test condition in single block of comments & provide script & test logic clearly in comments. Example:
'---- Checkpoints to verify login page ----
Browser("Applied Research International").Page("Applied Research International_6").Check
CheckPoint("Password")
Browser("Applied Research International").Page("Applied Research International_4").Image("changeuser_btn").Click
3. Global Variables: Used environment dependent variable like wait time, username etc. as global variables. Stored global variables mostly in database rather than in environment variables for easy usage & maintenance. Example:
Browser("Applied Research International").Page("Applied Research International_2").WebEdit("LogonDialog:txtUserName").Set datatable.Value("User")
Browser("Applied Research International").Page("Applied Research International_2").Image("LogonDialog:btnSubmit").Click 55,17
Browser("Applied Research International").Page("Applied Research International_3").WebEdit("LogonDialog:txtPassword")
.SetSecure datatable.Value("Password")
4. Maintaining base state: Always maintained base state after each execution so that each run can start from same place. Example: Logoff & close the browser when test complete.
'-------- Logoff-----
'-------- Logoff-----
Browser("Applied Research International").Page("Structured Credit Online_2").Link("Log-off").Click
Browser("Structured Credit Online").Dialog("Security Warning").WinButton("Yes").Click
Browser("Applied Research International").Page("The Applied Research International").WebButton("Yes").Click
Browser("Applied Research International").Page("Applied Research International_5").Sync
Browser("Applied Research International").Close
5. Execution of test without launching QTP: This was a requirement for this project so that development people can run certain test for smoke testing. A script is prepared so that without launching QTP we can run certain tests. Example:
Dim qtpApp
Dim qtpTest
'Run test
qtpApp.Open Testpath, True
Set qtpTest = qtpApp.Test
qtpTest.Run
While qtpTest.IsRunning
'Wait For Test To Finish
Wend
Exception Handling
On error goto Errorhandler
Errorhandler:
'-------- Logoff-------
Browser("Applied Research International").Page("Structured Credit Online_2").Link("Log-off").Click
Browser("Structured Credit Online").Dialog("Security Warning").WinButton("Yes").Click
Browser("Applied Research International").Page("The Applied Research International").WebButton("Yes").Click
Browser("Applied Research International").Page("Applied Research International_5").Sync
Browser("Applied Research International").Close
Post a Comment