400 likes | 419 Views
This guide covers building the GUI login module, creation of reusable actions, object repository setup, smart identification, modifying test settings, and more. Learn step-by-step with useful tips and best practices.
E N D
Login Module Building the Login GUI Layer Module
Topics covered • Create a new test, and classify it as a reusable action under GUI Layer. • Adding Object to Local Object Repository. • Mapping Dialogs/ Objects. • Smart Identification. • Modify and save Test Settings. Dani Vainstein & Monika Arora Gautam 2
Before you start… Before starting the presentation, read about the following topics in QTP help. Reusable-Actions Smart identification. Action Parameters. Object Spy. Test Object Properties. Run-time Object Properties. Object Repository. Dani Vainstein & Monika Arora Gautam 3
Things to Remember… • The Application Under Test (AUT) uses embedded ActiveX objects, so when you first time open QTP, make sure to check ActiveX option from Add-in manager. • When QTP is launched, be sure only the ActiveX option is checked in the add-in manager. Dani Vainstein & Monika Arora Gautam 4
Automation FR LIB RA BL GL RS DOC DAT SETTING TESTS RES BATCH ENV guiLogin Module • Save the current test under name = “guiLogin” in folder FR\RA\GL guiLogin Dani Vainstein & Monika Arora Gautam 5
guiLogin - Introduction • We are going to create a new Test and reusable action. • The Test name would be guiLogin, because it handles the “Login” dialog. • The main action will also called guiLogin. It will be a reusable action, for further tests. • The guiLogin will receive an input parameter of string type. Dani Vainstein & Monika Arora Gautam
Modifying the Test Settings - Properties Tab Description : The guiLogin Module Stores all the actions required for the login process Remark : associated add-ins : ActiveX only Dani Vainstein & Monika Arora Gautam 7
Run Tab Run one iteration only Save The Test Pop up Message box Disable Smart Identification During the run session Dani Vainstein & Monika Arora Gautam 8
Reusable action • We will create Reusable Action named guiLogin and set the Action properties. • The guiLogin module ( reusable action ) implements all the available actions on the Dialog login screen. • The Parameter StepName will be used as an instruction to the reusable action i.e. “SetData”, “CheckLogo” etc. Dani Vainstein & Monika Arora Gautam 9
guiLogin Reusable-Action • From Menu Edit Action Action Properties Dani Vainstein & Monika Arora Gautam 10
guiLogin - General Tab Change Action Name Add Description Mark Reusable Dani Vainstein & Monika Arora Gautam 11
Parameters Tab – Add StepName Add a new Input Parameter ( Click on + ) Add StepName Input Parameter Add Description Type String Default Leave Empty Dani Vainstein & Monika Arora Gautam 12
Mapping The Dialog Login • The guiLogin will hold a local repository. • The advantage of the OOT (Object Oriented Testing ) methodology, I think ( and others may disagree with me ) is that by having a reusable action per-screen, you don’t have to maintain a shared object repository. • Especially when you work within a team, it helps sparing the locks on the shared working files. • Mapping the application objects – is very important, you should map your application before you start to “script” Dani Vainstein & Monika Arora Gautam 13
Adding Objects to Local Repository • Open the Flight Application from Start All Programs QuickTest Professional Sample Applications Flight. • Do not login, just leave the window open. Dani Vainstein & Monika Arora Gautam 14
Adding Objects to Local Repository • Open the local object repository from menu Resources Object Repository. • Or just type Ctrl+R in QTP application. • QTP will show an hand icon. Click Add objects in toolbar Or Object Add objects To Local… Dani Vainstein & Monika Arora Gautam 15
Mapping objects Point the title-bar of dialog Click OK All Objects types Click OK Dani Vainstein & Monika Arora Gautam 16
Naming conventions • All the objects will be added to the local repository. • Remove spaces and non-alphanumeric characters from Object Names. • Change “Agent Name:” to “AgentName”. • Change “Static” to “Logo”. • Remove all names with : (colon ) at the end of the name. Dani Vainstein & Monika Arora Gautam 17
Why Renaming? • Sometimes there are two blanks instead of one; between two words. According to my experience, nobody will make a new version for such a mistake. Their answer ( R&D ) would be “We will fix it later”. • For QTP this is critical, as it will not identify two spaces instead of one. • The name “Static” says nothing to you and/or your colleagues, but with “logo” you have no doubt. • QTP sometimes gives insignificant names to objects i.e. “button_1” or “button_2”. • It is better to change these, to more descriptive names. • Changing logical names does not effect the QTP object recognition mechanism. Dani Vainstein & Monika Arora Gautam
Naming conventions See the logical names Convention changes Dani Vainstein & Monika Arora Gautam 19
CheckDialog Reusable Action • We will learn how to check different dialog messages that share same dialog title “Flight Reservation”. • We will create a new reusable action inside the guiLogin module, and we will call it “CheckDialog”. • I will explain later, the considerations of this decision. Dani Vainstein & Monika Arora Gautam 20
Creating a new reusable action • From Menu : Insert Call to New Action • Type : Hold the ALT key, and type ( I + N ) • From toolbar as shown below: Call to New Action Dani Vainstein & Monika Arora Gautam 21
Adding a new reusable action Name : CheckDialog Description : Manage all dialog checkpoints under guiLogin Reusable Action Location : At the end of the test Dani Vainstein & Monika Arora Gautam 22
CheckDialog Created • Now you should have two reusable actions. • Notice the actions listbox ( left ) and the keyword view ( right ). Dani Vainstein & Monika Arora Gautam 23
Object Repository Mapping Dialogs • Move to Expert View Action CheckDialogs. • Open the local repository : Resources Object Repository • Or Type CTRL+R • Or from toolbar as shown below: Dani Vainstein & Monika Arora Gautam 24
Mapping Dialogs • Open the Flight Reservation application if is not opened, and click OK. • CAUTION : always be aware, specially when adding objects, that you have only one instance of the AUT open. • What would happen? These child objects would be added under a new “Dialog_2” parent object and would not be recognized during playback. Dani Vainstein & Monika Arora Gautam 25
Map Flight Reservations dialogs • Click OK to get Flight Reservations dialog. Dani Vainstein & Monika Arora Gautam 26
Naming Conventions • Remove space between “Flight Reservation” and change it to “FlightReservation". • Change the “static” to “Icon”. • Change “Please enter agent name” to “Msg”. Dani Vainstein & Monika Arora Gautam 27
Mapping other dialogs? • Return to the same process and add all the objects/ dialog w.r.t. Logging in to Flight Application. • Try to map the following dialogs : • Why these are not added to the repository? Dani Vainstein & Monika Arora Gautam 28
Mapping dialogs • That’s because all the messages has the same title “Flight Reservations”. • For QTP all these dialogs are same. • Is it good? Of course! Otherwise you will have to map every single message in your AUT. • But, what about the message displayed in the dialog? The text is not the same. • This you will learn through the Object Identification feature and the Object Spy in next upcoming slides. Dani Vainstein & Monika Arora Gautam 29
Object Spy Understanding object identification • Select the object Spy. From menu : Tools Object Spy • Or from toolbar as shown below. Dani Vainstein & Monika Arora Gautam 30
Object Spy • Click on the finger point and select the message in the dialog. • Save a screenshot of the spy in “My Pictures” and do same for this dialog and compare properties for both the messages. Dani Vainstein & Monika Arora Gautam 31
Object Spy - Msg Dani Vainstein & Monika Arora Gautam 32
Comparing • The properties are quite different. The key of the mystery is the property window id, they are the same = 65535. Dani Vainstein & Monika Arora Gautam 33
Understanding The Object Identification • Another look to the repository will show us that the object is identified by QTP using the native class and window id, those properties have the same values • You will see further, why, this is a very big advantage. Dani Vainstein & Monika Arora Gautam 34
Highlight the Dialogs Messages in the Application • Select the Msg object in the repository and Click the “highlight in application” button while one of the pop-ups is displayed, see what happens. • One by one do the same for other pop-ups, and see what happens. Highlight in application Dani Vainstein & Monika Arora Gautam 35
Conclusion • Logically, QTP identifies all the messages inside the same dialog as the only one message. • Imagine you have to map all the different messages for same instance of dialog in your AUT. It’s lot of job. • However QTP takes care of it by its Object Identification and Spy feature. Dani Vainstein & Monika Arora Gautam 36
Saving the Test • Save The Test. • Every Time you see * near the test name, it means that the test is not saved. Always remember to save your work. Not Saved Dani Vainstein & Monika Arora Gautam 37
Summary • We have created a new reusable action guiLogin/guiLogin module • We a created a second new reusable action guiLogin/CheckDialog • In this session we’ve learned how to map the Login window and messages dialogs. Dani Vainstein & Monika Arora Gautam 38
Special Thanks To • Bharathi Babu, India, Pune. • Ayyappa Koppolu, India, Pune. • Paul Grossman, USA, Chicago. • Sumit Singhal, India, Bangalore. • Sanjeev Mathur, India, Noida. • Manasa VN, India, Bangalore. • Prakash Kumar, India, Pune. • Richi Sharma, USA, New Jersey. • Janardhan Kalvakuntla, USA, New England. • Indlamudi Rajesh, India, Mumbai. • Joydeep Das, India, Hyderabad. Dani Vainstein & Monika Arora Gautam
Make sure to visit us for: Tutorials Articles Projects And much more @ www.AdvancedQTP.com Dani Vainstein & Monika Arora Gautam 40 40