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....
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.
1. You will have own driver script.
2. This will call each action one by one.
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.
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.
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.

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:-


Popular posts from this blog

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 EndFunction 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 Settings
Function ChangeIEZoom Dim intZoomLevel, objIE  intZoo…

QTP - Object Identification - Prerequesties

While starting a new project or proof of concept or after new QTP installation, we would face the issue in identifying objects as QTP built objects like WinList, WebEdit, etc.; instead everything will be identified as WinObject.

Here are some steps to ensure you did the environment setup RIGHT before start automating.
Did you enabled required Add-ins only while launchingDid you selected "Record >> Record and Run Settings" - This should be based on what type of application you are working with
Windows app - Windows >> Record and run test on any windows applications. Web app - Web >> Record and run test on any open browser.
Did you tried to launch UFT/QTP and then AUT.If its web, ensure browser zoom level set to 100%Try disabling the protected mode in IE for web.Launch UFT and AUT using RUN AS ADMINISTRATORAlso see the Object Identification Methods if you are interested.

Run JavaScript from QTP

Yeah, You can run your pure JavaScript from QTP using RunScript method. Lot of times, we are in need of firing events or simulating actions on web page which is not supported by QTP. At that time, you can use your direct DOM methods and directly execute your script on the web page from QTP like,
Dim MyPage, SearchBox Set MyPage = Browser("title:=Google").Page("title:=Google") Set SearchBox = MyPage.RunScript("document.getElementsByName('q')(0);") SearchBox.Value="testing"
'if objects available in frames, Set SearchBox = MyPage.RunScript("document.frames(4).document.getElementsByName('q')(0);")
Set objFrame = Browser("title:=Google").Page("title:=Google").Frame("title:=something")
objFrame.RunScript("document.getElementsByName('q')(0);") Also, you can execute by obtaining actual browser window object if you have IE app like, Dim IEApp Set IEApp = CreateObject("Internet…