Skip to main content

What is Framework?

Today, I am going to discuss about framework due to request of my friend Anand.


Lot of QTP guys know the information on How to Create Test, How to identify Complex objects, How to generate results and etc. But still somebody have doubts like
What is Framework?
Why we need Framework?
What's the purpose of it?
How to design framework?
Is that required lot of coding knowledge?, etc.


Let's consider a case. We have 100 test scenarios to automate. Each test scenario have around 100 test cases. Here you will do the following....
Design:
1. Create Test Scripts for each case by creating separate actions.
2. Each test case script i.e. each action will have associated resources. - Object Repository, Function Library and Recovery Scenario files.
Execution:
1. You will have own driver script.
2. This will call each action one by one.
Maintenance:
1. If any UI changes happened, you need to find the particular OR file to update the same.
2. You need to maintain lot of OR files which is a tough task.
3. If any new resource joined in Team, its tough task to give KT and to get on track.


So, you have lot of drawbacks in your script generation, execution and mainly on Maintenance phase. This will not give estimated ROI for clients. So,
1. How to reduce these complexities?
2. How to make our task easy?


Here we go...
Framework - Framing our work. How we are framing our automation work i.e. Script Design, execution and maintenance of our automation project which will yield good results on below points.
1. Easy script generation.
2. Maximum Re-Usability.
3. Low maintenance cost.
4. Easier execution of scripts for every new builds based on our decisions.
5. Ability to design test scripts using Non-Technical testers, Business Analysts, etc.


Let's design a sample framework for QTP for the same case we talked above.
Framework Design:
1. Let's create some folder structure which will help us to keep our files in respective folder. This will help a lot while our project grows.
2. Create a folder "MyApp-Automation" - Under this folder,
       Create a folder "Function Library" - Under this, maintain all our function libraries like .vbs, .qfl    and .txt files.
       Create a folder "Object Repository" - Under this, maintain OR files. Create a Shared OR for different modules or Create a Shared OR for each application.
       Create a folder "Data Files" - Under this, maintain all test data excel files, Scenario files, Test Cases files, etc.
       Create a folder "Config Files" - Under this, maintain all configuration files whether in .ini or .xls format. Maintain all the data required globally for execution of any test in these files so that we can read and set these values as Environment Parameters to access through out our execution scope.
       Create a folder "Results" - Under this, export our results after execution by creating a subfolder with name as "MyTest_CurrentDate_Time".
Test Design:
1. First identify the available functionalities, test cases and flow of business. Based on your analysis, design some re-usable functions like Login, CreateTxn, DeleteTxn, Logout, etc.
2. Then go and create Test Case Script. Here just you can use all your re-usable functions already written. No need to write again and again code for same functionality. This will reduce your script design time as well as maintenance time.
Execution:
1. Add a field "Execute?" in your TestScenarios file and mark as "Yes/No" based on your execution requirement.
2. The same way, add this field for TestCases sheet and mark as Yes/No.
3. Now design your DriverScript like,
   a) Read the Test Scenarios file.
   b) Check Execute field. If Yes, goto TestCases file for this TestScenario.
   c) Read TestCases. If Yes, execute this case. i.e. Call the function for this case like "Call TS1_Case_001". Here Case_001 is the function for your TestCase TS1_Case_001.
   d) The same way, it will loop for all cases under the Test Scenario and then will pickup and loop for all Test Scenarios.
4. So, the only initial point is your Driver Script after setting up your requirement for execution and test data.
Maintenance:
1. Here you have minimum number of OR files based on application or modules. So if any UI changes happened in application, its easy to find and update values.
2. Also, if any functionality is changed in your application, just go and modify in your re-usable function. That's enough, it will affect all the cases as the re-usable function only called inside all the cases. No need to open each case and modify.
3. Even manual testers or business analysts can design test script because we have ready made functions for all functionality. Only thing they should know, purpose and use of each re-usable function which we can deliver by creating a documentation.


Types:-
For the types of frameworks, you will find lot of resources in web. Just Google it. Just providing the main types available.
1. Keyword-Driven
Our designed re-usable functions are Keywords.
2. Data-Driven
Your test data is driving your test. i.e. Your single test will run multiple times with different data each time.
3. Hybrid
Any combinations for more than one kind of framework.


So, I hope now you might have some idea about framework and you might be in the position to answer all the questions I have listed on top.
Why are waiting? Start creating your framework now !!!


Here are some links:-
http://www.youtube.com/watch?v=XGr5HC8VrAI
http://www.youtube.com/watch?v=rB3r7Dp_jyM

Comments

Popular posts from this blog

Some good Resources / Blogs / Sites for Selenium Users

Here I have listed out some good blogs and sites by extensive selenium automation users. Hope these will help you a lot. http://automationtricks.blogspot.com  - by NirajKumar http://www.theautomatedtester.co.uk/ http://testerinyou.blogspot.com   - by Naga/Mathu http://seleniumready.blogspot.com  - by Farheen Khan http://seleniumdeal.blogspot.com/  - Amit Vibhuti http://seleniumexamples.com/blog Sauce Labs and BrowserMob are companies doing cloud and extensive selenium automation services, products, etc http://saucelabs.com/blog http://blog.browsermob.com http://testingbot.com/ Cedric Beust -  creator of the TestNG Java testing framework. http://beust.com/weblog/ http://blog.reallysimplethoughts.com/  - by Samit Badle, Created many Selenium IDE Plug-Ins Available Colud Testing: 1. SauceLabs 2. Soasta 3. BrowserMob 4. CloudTesting.com  etc. Selenium Testing Products: 1. Twist by ThoughtWorks 2.  TestMaker by  PushToTest 3. Element34 company providi

UFT - Take full page screenshot by scrolling the page

'######################################################################################## 'This is navigate through the full page and taking individual screenshot of visible area '######################################################################################## Function TakeScreenshot Dim intScrolls, intScroll, strScrollPos Set pgApp = Browser ( " " ) .Page ( " " ) intScrolls = Round ( pgApp . RunScript ( " document.documentElement.scrollHeight / (screen.height) " ) , 2 ) If intScrolls < 1 Then intScrolls = - 1 pgApp . RunScript " window.scrollTo(0, 0); " Wait 1 Browser ( " " ) .CaptureBitmap " C:\screenshot0.png " , True For intScroll = 0 To intScrolls If Environment . Value ( " Browser " ) = " CHROME " Then strScrollPos = " scrollY " Else strScrollPos = " document.documentElement.scrollTop " End If If p

Change IE Browser ZOOM settings

Lot of UI automation testers could have faced this problem as we could change the zoom settings while operating manually for our convenience and forgot to reset to 100%. But our QTP and some other related tools would operate the browser perfectly if browser zoom is 100%. So wee need to change the zoom before start to run the scripts. Its better to have a code snippet in our framework to change this zoom setting right? Here we go... 1. We can simply change the Registry values before Invoking IE Function  ChangeRegistry   Dim  objShell   Set  objShell =  CreateObject ( "WScript.Shell" )  objShell.RegWrite  "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor" ,  "100000" ,  "REG_DWORD"   Set  objShell =  Nothing End   Function This option is very useful. But in real time, lot of customers could have restricted write access to windows registry. So we can try other options. 2. Use IE COM object and Change