410 likes | 419 Views
Learn how to build an automation infrastructure and set up the framework for the Flight Reservation project. Gain knowledge on advanced coding techniques, testing methodologies, and script maintenance.
E N D
FR Project Building and Setting-up the Infrastructure Dani Vainstein and Monika Arora Gautam
Introduction • The FR project ( Flight Reservation ) is designated for all “First Step” users, who want to learn how to use QTP like in the “real” world of automation testing. • The FR step-by-step project will teach you: project design, use of advanced coding techniques, how to reduce script maintenance, use of modern testing methodologies, and much, much more. • The FR project will teach you how to build an automation infrastructure, define a framework for the requirements of the Application Under Test (AUT) . • You will learn about different types of testing including: Regression, Negative, and Sanity (or Smoke) tests. Dani Vainstein and Monika Arora Gautam
Subjects/Topics covered • The Object Oriented Programming (OOP) testing methodology. • Build the automation infrastructure. • Organizing QTP and test related artifacts a.k.a Project Folders • Define a Global Scripting.Dictionary object. • The Application Under Test (AUT). • QTP Options. • Record and Run Settings configuration. Dani Vainstein and Monika Arora Gautam
The OO Testing methodology • First rule : Separate Data from Coding. • Second rule : Separate User Interface (UI) from business logic. • Third rule : Business layer module never call another business layer module, as well as Graphical User Interface (Gui) module never calls another Gui module. Data Layer Test Layer Utils Layer Business Layer GUI Layer Dani Vainstein and Monika Arora Gautam
The Data Layer • The data layer are data source files, thus can be Excel files, xml files or a database. Data Layer Test Layer Utils Layer Business Layer GUI Layer Dani Vainstein and Monika Arora Gautam
The Utils Layer • These are common or specific function libraries associated with the scripts. Data Layer Test Layer Utils Layer Business Layer GUI Layer Dani Vainstein and Monika Arora Gautam
The GUI Layer • Every GUI “Module” handles one GUI screen • Every module handles all the available actions for the current module i.e. Get Data, Set Data, Check Data Data Layer Test Layer Utils Layer Business Layer GUI Layer Dani Vainstein and Monika Arora Gautam
G4 G1 G2 G5 G3 GUI layers schema Dani Vainstein and Monika Arora Gautam
Business Layer • The Business Layer supports a single business action. • The Business layer module can call 1 to nGUI modules. • The Business module acts like a controller for the GUI actions. • One Business module can never call another Business module. Data Layer Test Layer Utils Layer Business Layer GUI Layer Dani Vainstein and Monika Arora Gautam
B1 G1 G5 G4 G3 Business Layer illustration Dani Vainstein and Monika Arora Gautam
Test Layer • The Test Layer is the engine and a procedure to parse the parameters required for a single test, and call to the required Business Layer Module. • Every Module has a unique name, usually a process name i.e. AddNewCustomer. • The implementation of the test is the same, for all the tests, beside the call to the business action. Data Layer Test Layer Utils Layer Business Layer GUI Layer Dani Vainstein and Monika Arora Gautam
The Infrastructure – Project Folder • If you work in a company, you should build this infrastructure on a network drive /shared drive/version control, with a daily backup. • If You work with Quality-Center the infrastructure should be built within the Test Plan pane. Dani Vainstein and Monika Arora Gautam
Mapping a Network Drive for Automation • In the real world, we do have network drives. The best method I know, is to select a constant free drive i.e Q: and map the network drive to the physical location. • By doing this you’ll save large strings paths for example, if you have a network path as the follows:“//server/company/division/project/unit/product/qa/qtp/automation” , map Q: to the automation folder. • All the testers have to do the same. Now, your automation folder is in Q:\FR • Believe me, this process can save you a lot of headaches!!! Dani Vainstein and Monika Arora Gautam
Assumptions and Dependencies • We are assuming that you don’t have Quality-Center. • We are also assuming that you don’t have a “network” drive. So, always save your work. • A good project starts with a good plan. This step is skipped assuming that we already have a test plan. Dani Vainstein and Monika Arora Gautam
Automation FR LIB RA BL GL RS DOC DAT SETTING TESTS RES BATCH ENV Suggested Infrastructure • FR – Flight Reservation Project • LIB - Function Library Files • RA – Reusable Actions • BL – Business Layer • GL – GUI Layer • RS – Recovery Scenarios • DOC – Documents • DAT – Data Files ( xml, xsl ) • SETTING – QTP Settings files. • TEST – QTP Tests • RES – Results Folder • ENV – Environment files • BATCH – Batch files from Batch runner or Multi-Tester Manager Dani Vainstein and Monika Arora Gautam
About Reserved Objects • Reserved Objects are QTP COM objects, that extend the capabilities of QTP i.e Reporter, SystemUtil, Parameter, Environment, PathFinder, Description • VBScript objects are not “Reserved”, that’s why you don’t see the intellisense, and all methods and properties when you press the “.” • However, you can insert VBScript objects or any COM object to Reserved Objects. Dani Vainstein and Monika Arora Gautam
About Reserved Objects • Inserting objects to reserved category makes QTP to load those objects. • Don’t add unnecessary objects, you’ll pay with performance. • Don’t do it on ADODB; your database will remain always open. • In the next slide we will take the advantage of defining a new reserved object • read more about Reserved Objects here : http://www.advancedqtp.com/2007/06/reserved-objects Dani Vainstein and Monika Arora Gautam
GlobalDictionary Object • The OO Methodology needs a data source during run-time. • The solution is to define a Global Scripting.Dictionary Object for this purpose. • If you don’t know what is a Scripting.Dictionary object, please! read related documentation, we are going to use it a lot see link: Scripting QTP - Advanced VBScript • Another advanced option, is to use a disconnected record-set “ADOR.Recordset”; will not covered in this project. Dani Vainstein and Monika Arora Gautam
Define a Global Dictionary • Open the Registry editor ( type regedit in run command ) • Locate the Key : HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects. • Close QTP if it’s open. Dani Vainstein and Monika Arora Gautam
Define a Global Dictionary • Right Click on ReservedObjects and select from the popup menu New Key • In the newly created entry, type “GlobalDictionary” • Add new String value ProgID = Scripting.Dictionary • Right-click on ProgID Modify Scripting.Dictionary ( in value data ) • Add new String value UIName = GDictionary • Right-click on UIName Modify GDictionary ( in value data ) • Add a new DWORD value VisibleMode = 2 • Right-click on VisibleMode Modify 2 ( in value data ) Dani Vainstein and Monika Arora Gautam
Define a Global Dictionary • That is how your “ReservedObjects/GlobalDictionaryentry will look. Global Dictionary Reserved Objects Key Path Dani Vainstein and Monika Arora Gautam
QTP intellisence for Reserved Objects • Type GDictionary. In the Expert View, you’ll see the intellisence for the newly created Reserved Object. Always Restart QTP after modifying the Registry Dani Vainstein and Monika Arora Gautam
Shortcuts... • You can define a .reg file that automatically updates the registry, on any new machine, so you don't have to do it manually. Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\GlobalDictionary] "ProgID"="Scripting.Dictionary" "UIName"="GDictionary" "VisibleMode"=dword:00000002 Dani Vainstein and Monika Arora Gautam
Automation FR LIB RA BL GL RS DOC DAT SETTING TESTS RES BATCH ENV Reg Settings File. ReservedObjects.reg Dani Vainstein and Monika Arora Gautam
Recommended Global Objects GloalFso You can use a "Log" file during the run-session DeviceReplay Simulates mouse and keyboard actions. Including Drag n Drop Dani Vainstein and Monika Arora Gautam
Add-in Manager Select only ActiveX Dani Vainstein and Monika Arora Gautam
The AUT ( Application Under Test ) • Our AUT is the Flight Application Demo. • The AUT embeds some ActiveX objects. • When you first open QTP be sure that only ActiveX option is checked. • Always open QTP before the AUT when working with ActiveX, otherwise new ActiveX objects will identified as WinObjects. • Only One instance of AUT should be opened while recording. Dani Vainstein and Monika Arora Gautam
QTP Global Options • One of the most important options in QTP is to define the working path. • This will allow you to use relative paths when working with tests, resources, data and more. • If for some reason you want to move your project from C:\Automation\FR to D:\Automation\FR you just need to modify a single parameter, otherwise you’ll need to modify all tests, resources and associated repositories… you don’t want to do this, believe me. Dani Vainstein and Monika Arora Gautam
Define a Working Path in QTP. • Menu : Tools Options Folders Tab • Shortcut: Alt + T + O • Toolbar QTP Options Dani Vainstein and Monika Arora Gautam
Define the Root Project Folder Root Project Folder Dani Vainstein and Monika Arora Gautam
Recommended Options - Run Run Mode = Fast Allow other mercury… Save still image… For Errors and Warnings Dani Vainstein and Monika Arora Gautam
Recommended Options - General Display Add-in manager Uncheck Automatically generate “With” statements… Dani Vainstein and Monika Arora Gautam
Automation FR LIB RA BL GL RS DOC DAT SETTING TESTS RES BATCH ENV Saving Option Settings Options.vbs Dani Vainstein and Monika Arora Gautam
View Options - General • From Menu : Tools View Options Show line numbers Auto indent Tab spacing = 4 Dani Vainstein and Monika Arora Gautam
Courier New Size = 10 or 11 View Options – Font and Color • From Menu : Tools View Options Dani Vainstein and Monika Arora Gautam
Record and Run Settings • When you click “Record” QTP will record anything you’re doing, until you stop recording. • This can be very dangerous; QTP will add new objects to repository and new lines of code. • We can accidentally overload the repository with private objects ( My outlook e-mails ), and with objects we’ll never use. • Solution : Modify Record and Run Settings as explained in next slide. Dani Vainstein and Monika Arora Gautam
Record and Run Settings • Menu : Automation Record and Run Settings… Record and run only on Applications opened by QTP Applications specified below Dani Vainstein and Monika Arora Gautam
Record and Run Settings • Menu : Automation Record and Run Settings… Flight4A.exe Uncheck ”Launch Application” Include descendant processes Dani Vainstein and Monika Arora Gautam
Summary • The Infrastructure for the FR project is ready. • For any question, please refer to the FR Project Forum. Dani Vainstein and Monika Arora Gautam
Special Thanks To • Natwarlal Asawa from India, Hyderabad • Bharathi Babu from India, Pune • Dinkar Singh from India, Delhi • Ayyappa Koppolu from India, Pune • Paul Grossman from USA, Chicago • Sumit Singhal from India, Bangalore • Sanjeev Mathur from India, Noida • Manasa VN from India, Bangalore • Prakash Kumar from India, Pune • Suresh K from India, Bangalore • Richi Sharma from USA, New Jersey • Janardhan Kalvakuntla from USA, New England • Joydeep Das from India, Hyderabad Dani Vainstein and Monika Arora Gautam
Make sure to visit us for: Tutorials Articles Projects And much more @ www.AdvancedQTP.com 41 Dani Vainstein and Monika Arora Gautam