• Like
Qtp day 5
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Qtp day 5

  • 630 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
630
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
29
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. QTP
  • 2. Day5: Advanced QTPRecovery scenarioOptional stepsFramework ApproachWorking with Dynamic Objects
  • 3. Recovery scenarioWhen executing scripts we may getsome Unexpected errors.To recoverthe test and continue running scriptfrom these unexpected errors we useRecovery Scenarios
  • 4. Recovery scenarioWhat happens in  Recovery Scenarios?Trigger EventRecovery OperationsPost-Recovery Test Run Option
  • 5. Recovery scenarioTrigger Event:The event that interrupts your runsession. For example a window that maypop up on screen.
  • 6. Recovery scenarioRecovery Operations:The operations to perform to enable QTPto continue running the test after thetrigger event interrupts the run session.For example, clicking an OK button in apop-up window.
  • 7. Recovery scenarioPost-Recovery Test Run Option:The instructions on how QTP should proceedafter the recovery operations have beenperformed, and from which point in the test QTPshould continue. For example, you may want torestart a test from the beginning, or skip a stepentirely and continue with the next step in thetest. Recovery scenarios are saved in recoveryscenario files having the extension .qrs. Arecovery scenario file is a logical collection ofrecovery scenarios, grouped according to ourspecific requirements.
  • 8. Recovery scenarioRecovery scenario manger canhandle following four events: 1. Pop-up window: To handle unwantedpop ups.2. Object state: To handle object relatederrors at runtime.3. Test run error: To handle vb scriptstatement errors at runtime.4. Application crash: To handle crashedapplications at runtime.
  • 9. Recovery scenario1.Recovery Scenario for PopupWindow:Steps to follow to handle unwanted popups:Trigger Event Steps:Resources Menu -->Recovery ScenarioManager -->New -->Next -->Select “PopupWindow” as Trigger event -->Next -->Clickon Hand Icon -->Show unwanted windowwith Hand icon -->Next -->Next-->(Continue below mentioned steps)
  • 10. Recovery scenarioRecovery Operations steps:Select function call as Recovery Operation-->Next {Open Notepad -->Save empty filewith .vbs extension} -->Browse the .vbs fiepath -->Next -->Uncheck Add anotherRecovery Operation -->Next -->(Continuebelow mentioned steps)
  • 11. Recovery scenarioPost-Recovery Test Run Option Steps:Select Post-Recovery Test Run Option{Repeat current step and continue, Proceedto Next step, Proceed to Next Action,Proceed to next test iteration, Restartcurrent test run, Stop the Test Run} -->Next-->Enter Scenario Name -->Next -->SelectOption --> Finish -->Save the scenario with“.qrs” -->Record required RecoveryOperation {Click ok, Click Cancel} take thescript into function -->Save the library file-->Click Run
  • 12. Recovery scenario2.Recovery Scenario for ObjectState:Steps to follow to check Property valuesof an object in the application matchspecified values. User can specifyproperty values for each object in thehierarchy.
  • 13. Recovery scenarioTrigger Event steps:Resources Menu --> Recovery ScenarioManager --> New --> Next --> Select“Object state Window” as Trigger event -->Next --> Click on Hand Icon --> Showobject with and icon --> Next --> Next-->select object property with value (enabled,false)-->click next --> (Continue belowmentioned steps)
  • 14. Recovery scenarioRecovery Operations steps:Select function call as Recovery Operation--> Next {Open Notepad --> Save emptyfile with .vbs extension} --> Browse the.vbs fie path --> Next --> Uncheck Addanother Recovery Operation --> Next-->(Continue below mentioned steps)
  • 15. Recovery scenarioPost-Recovery Test Run Option Steps:Select Post-Recovery Test Run Option{Repeat current step and continue, Proceedto Next step, Proceed to Next Action,Proceed to next test iteration, Restartcurrent test run, Stop the Test Run} -->Next--> Enter Scenario Name --> Next -->Select Option -->Finish --> Save thescenario with “.qrs” --> Record requiredRecovery Operation {Click ok, Click Cancel}take the script into function --> Save thelibrary file --> Click Run
  • 16. Recovery scenario3.Recovery Scenario for Test RunError:Steps to follow to check if test does not runsuccessfully then Test Run Error can beraised.Trigger Event steps:Resources Menu -->Recovery ScenarioManager -->New -->Next -->Select“Testrunerror Window” as Trigger event-->Next -->select any error o -->Next -->Next-->(Continue below mentioned steps)
  • 17. Recovery scenarioRecovery Operations steps:Select function call as RecoveryOperation -->Next {Open Notepad-->Save empty file with .vbs extension}-->Browse the .vbs fie path -->Next-->Uncheck Add another RecoveryOperation -->Next -->(Continue belowmentioned steps)
  • 18. Recovery scenarioPost-Recovery Test Run Option Steps:Select Post-Recovery Test Run Option{Repeat current step and continue, Proceedto Next step, Proceed to Next Action,Proceed to next test iteration, Restartcurrent test run, Stop the Test Run} -->Next>Enter Scenario Name >Next -->SelectOption --> Finish >Save the scenario with“.qrs” -->Record required RecoveryOperation {Click ok, Click Cancel} take thescript into function -->Save the library file-->Click Run
  • 19. Recovery scenario4.Recovery Scenario for ApplicationCrash:Steps to follow to check application failureduring Test Run.Trigger Event steps:Resources Menu --> Recovery ScenarioManager--> Click New--> Click Next-->Select Application Crash as Triggerevent-->Next -->Select selected executableapplication-->Next --> (Continue belowmentioned steps)
  • 20. Recovery scenarioRecovery Operations and Post-RecoveryTest Run Option Steps:Select Recovery Operation {Keyboard,Mouse Operation,Close ApplicationProcess, function Call, Restart, MicrosoftWindows} -->Next -->If you want to checkAdd another operation else uncheck-->Next-->Next -->Enter Scenario Name -->Next-->Select Option -->Finish -->Close -->Savethe scenario with “.qrs”
  • 21. Recovery scenarioA recovery scenario can handle onthese situations.On error StatementsFollowing are error statements :1. On Error Resume Next2. On Error Go to 03. err.number4. err.description
  • 22. Recovery scenarioOn Error Resume Next:On Error Resume Next statementenables the Error handling in thecode.If there is error in the code "Onerror Resume Next" ignores it andcontinue with next line of code.
  • 23. Recovery scenarioOn Error Go to 0:On error got to 0 statement disableserror handling we have previiouslyenabled it by using On Error resumeNext.err.number and err.description:Provides the error number and thedescription of the error
  • 24. Recovery scenarioAdvance QTP Script to attach and enablerecovery scenario manager file to qtp testduring runtime :Dim qtAppSet qtApp = CreateObject("QuickTest.Application")qtApp.Test.Settings.Recovery.Enabled = TrueqtApp.Test.Settings.Recovery.SetActivationMode"OnError"qtApp.Test.Settings.Recovery.Add"C:qtprecovery.qrs", "Recovery", 1qtApp.Test.Settings.Recovery.Item(1).Enabled = True‘Above statement will enable recovery file for specifictest.
  • 25. Recovery scenarioSo using above advance qtp scriptwe can attach and enable existingrecovery scenario manager file to qtptest during runtime.
  • 26. Recovery scenarioUsing Recovery Scenarios you caninstruct QTP to recover fromunexpected events  and errors thatoccur in your testing environment during arun session.Recovery scenario become crucial forlarge tests, which rununattended  and are paused untilrecovery operation, is performedincreasing the test execution time.
  • 27. Recovery scenarioThere are 6 steps  involved in creating arecovery scenario1) In QTP , Select Resources > RecoveryScenario Manager .Create new Scenario2) Specify the Trigger Event.  A TriggerEvent is an event that interrupts your runsession3) Specify the  Recovery Operation whichis the corrective action you take whentrigger happens
  • 28. Recovery scenario4) Specify Post-recovery test run optionswhich specify how to continue the runsession after Quick Test  Professional hasidentified the event and performed all ofthe specified recovery operations.5)  Check and verify Summary  of thescenario you created.6) Add Recovery Scenario to your testusing  File > Settings > Recovery.
  • 29. Optional stepsAn optional step  is a step that is notnecessarily required tosuccessfully complete a runsession.During a run session, if  the object ofan optional step does not exist  in theapplication QTP  bypasses this stepand continues to run the test.
  • 30. Optional stepsTo set a step as optional in keywordview right click on the step and selectOptional StepAlternatively, you can directly write thekeyword "OptionalStep" preceding astatement to make it optional.
  • 31. Framework ApproachWhat is Test Automation Framework?Suppose you are given a task whereyou have to automate some test casesfor an application. When you arefinished automating the application,what would be your expectations fromthe scripts you have created?
  • 32. Framework ApproachThe scripts should run as intendedwithout any issues.The code and the flows should be easyto understand.The scripts should be easy to maintainin case of any changes.All the above points can be achieved byusing a proper Automation Framework.
  • 33. Framework ApproachAn Automation Framework is a set ofguidelines that you can follow during testcase scripting to achieve the abovementioned results.It may be related with these aspects.Specifying the folder structure that willbe used for storing test cases, functionlibraries, object repositories and datasheets.
  • 34. Framework ApproachDeciding the format of the data sheetsi.e., how the data sheets would begrouped and how the scripts will accessthese data sheets.Following proper coding standards andusing comments so that the code canbe understood easily by anyone.Using reusable functions whereverpossible so that lesser amount ofrework is needed in case of anychanges.
  • 35. Framework ApproachModular Framework in QTP.Modular Framework is the approachwhere all the test cases are firstanalyzed to find out the reusable flows.Then while scripting, all these reusableflows are created as functions andstored in external files and called in thetest scripts wherever required.
  • 36. Framework ApproachAdvantages of Modular Framework .Test Scripts can be created in relativelyless time as the reusable functions needto be created only once.Effort required to create test cases isalso lesser due to code reuse.If there are any changes in the reusablefunctions, the changes need to be donein only a single place. Hence scriptmaintenance is easier.
  • 37. Framework ApproachDisadvantages of Modular Framework.Since data is still hardcoded in the script,the same test case cannot be run formultiple data values without changingdata after each run.Additional time is spent in analyzing thetest cases to identify with reusable flows.Good programming knowledge isrequired to create and maintain functionlibraries.
  • 38. Framework ApproachData Driven Framework in QTP.In Data Driven Framework, the data is NOThard-coded in the test scripts. Instead, it isstored in some external files. The test scriptfirst connects to the external data sourceand then extracts the data from that source.Most of the times, excel sheets are used tostore the data. Other external data sourcesthat are frequently used are – Text files,XML files, Databases, Combination of morethan one external file.
  • 39. Framework ApproachAdvantages of Data Driven Framework .Since the data is kept separate from thetest script, the same script can be runmultiple times for different sets of data(which can be kept in multiple rows inthe data sheet).Changes made in the test data don’taffect the test scripts in any way andvice versa.
  • 40. Framework ApproachDisadvantages of Data DrivenFramework.Additional effort and good technicalexpertise is required to create functionsthat connect to the external datasources to retrieve the data.Additional amount of time is required inidentifying which external data source touse and deciding how the data shouldbe stored or grouped in that externaldata source.
  • 41. Framework ApproachKeyword Driven Framework in QTP.In Keyword Driven framework, you cancreate various keywords and associatea different action or function with eachof these keywords. Then you create aFunction Library that contains the logicto read the keywords and call theassociated action.
  • 42. Framework ApproachAdvantages of Keyword DrivenFramework.The keyword and function libraries arecompletely generic and thus can bereused easily for different applications.All the complexity is added in thefunction libraries. Once the libraries areready, it becomes very easy to writethe actual test script steps in excelsheets.
  • 43. Framework ApproachDisadvantages of Keyword DrivenFramework.Lot of time and effort needs to be spentinitially to create the function libraries. Thebenefits of the keyword driven frameworkare realized only after it has been used forlonger periods of time.Very high programming skills are neededto create the complex keyword libraryfunctions.It’s not easy for new people to understandthe framework quickly.
  • 44. Framework ApproachBusiness Process Testing (BPT)Framework in QTP.Business Process Testing (BPT)Framework is the framework where youcan divide the test cases into multipleflows and each of these flows is scriptedby using a Business Process Component.When all the components for a particulartest case are ready, you can link thecomponents one after the other as per thetest case flow and execute the BPT testcase from QC.
  • 45. Framework ApproachAdvantages of BPT Framework.BPT Framework allows non-technicalsubject matter experts to quickly createtest cases using the business processcomponents.A lot of features such as componentlinking & data parameterization come builtin with the BPT Framework. Because ofthis you do not need to spend extra effortto write code for these functionalities.
  • 46. Framework ApproachDisadvantages of BPT Framework.BPT Framework can be used only if youhave QC access.You would need to purchase additionallicense for BPT Framework if you want touse this for your test scripts.
  • 47. Framework ApproachHybrid Framework in QTP.Hybrid Framework is a framework thatis created by combining differentfeatures of any of the frameworksmentioned above. Based upon yourrequirements, you can combine thefeatures of any of the above frameworksto come up with your own version ofHybrid Framework.There are many different ways to createa Hybrid Framework.
  • 48. Framework ApproachAdvantages of Hybrid Framework.The main advantage of this approachis that you can use the best featuresfrom all the types of frameworks tocreate your own.
  • 49. Framework ApproachDisadvantages of Hybrid Framework .The framework is highly complex andneeds very good programmingexpertise and experience to build aHybrid Framework from scratch.
  • 50. Working with Dynamic ObjectsEvery now and then an object we areworking with is changing during test run, orits properties are set dynamically atruntime by input parameters. The outcomeof such an object is the inability of addingthis object to the Object Repository.The solution is dynamic objects, i.e.objects which are defined during run time.
  • 51. Working with Dynamic ObjectsThere are several ways to work with dynamically generated object:Using Regular Expression.Using alternative object property to uniquely identify the dynamic object.Descriptive programming.
  • 52. Working with Dynamic ObjectsUse regular expressions  for the dynamic property.Open the Object Repository, and find the object from the left side of the Object repository window.From the list of the properties, select the dynamic property.Click the edit icon, which is next to the Constant edit field.Check the ‘Regular expression’ checkbox.Replace the dynamic portion of the string with wild cards (*) and Click “OK”.
  • 53. Working with Dynamic ObjectsModify the Object Repository  for the dynamic object to use different property to uniquely identify the object:Open Object repository, and select the dynamic object.Click on the Add/Remove Button.Choose a different property to identify the object uniquely.
  • 54. Working with Dynamic ObjectsMultiple usages of a Dynamic Object: Set newObject = Description.Create newObject(“micclass”).Value = “WebElement” newObject(“html tag”).Value = “SPAN” newObject(“class”).Value = “radio-classic- ITEM-OFF” newObject(“text”).Value = Parameter(“Text”)
  • 55. Steps before starting Automation Frame Work1. Give environment variable path (which ismandatory)2. In the SystemMy Computer Right Click PropertiesAdvanced Environment Variable Qpath:3. In QTP ToolFile Settings Resources [+] AddPath(GenUtils.txt & LibraryUtils.txt) Apply Ok
  • 56. THANK YOUFor further information Contact: prashanthbs@in.com