Your SlideShare is downloading. ×
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Qtp day 3
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Qtp day 3

1,024

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,024
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
52
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. Day3: Advanced FeaturesParameterizationStep GeneratorAdding conditional statementsCustom checkPoints
  • 3. ParameterizationTypes of parameterization:We can parameterize tests in several ways in QTP.1. Through Loop Statements2. Dynamic Test Data Submission3. Through Data Table4. Fetching Test Data directly from External files(Flat files & Spreadsheets)5. Fetching Test Data directly from Databases(MSAcess, Oracle etc).6. Getting Test Data from front end objects.
  • 4. Parameterization1. Through Loop Statements: We can use loop statementsfor passing sequential numbers & Logical Numbers.Note: We can’t generate Strings.For orderno=1 to 10 step 1 for one increment stepkeyword is not mandatoryWindow("Flight Reservation").ActivateWindow("Flight Reservation").WinButton("Button").ClickWindow("Flight Reservation").Dialog("OpenOrder").WinCheckBox("Order No.").Set "ON"Window("Flight Reservation").Dialog("OpenOrder").WinEdit("Edit").Set ordernoWindow("Flight Reservation").Dialog("OpenOrder").WinButton("OK").ClickNext
  • 5. Parameterization2.Dynamic Test Data Submission: Through Loop Statements we cangive strings also but every time user has to enter data.For x=1 to 3Agent =inputbox("enter an Agent Name")Password=inputbox("enter a password")invokeapplication "C:Program FilesMercury InteractiveQuickTestProfessionalsamplesflightappflight4a.exe"Dialog("Login").ActivateDialog("Login").WinEdit("Agent Name:").Set AgentDialog("Login").WinEdit("Agent Name:").Type micTabDialog("Login").WinEdit("Password:").SetSecure passwordDialog("Login").WinButton("OK").ClickWindow("Flight Reservation").CloseNext
  • 6. Parameterization3. Through Data Table: QTP adds one data table(Spreadsheet) for every test, we can use DataTable for Data Driven Testing.It has 3 types of usage .a. Entering test data directly into data table and useb. Importing test data from external Flat filesc. Importing test data from external Spread sheetsd. Importing test data from Data bases.
  • 7. Parameterizationa. Entering test data directly into data table and use.Steps:i) Generate the basic test>open data table(View>Data Table)ii) Click on column header>enter the name of thefield (like this we can create number ofcolumns) > Enter Data>connect the data to test(variable=datatable(“column name”, Sheet id)Example: agent=datatable(“agent”,1)Pass parameters.)iii) Run the test.
  • 8. ParameterizationExample:Agent = Datatable("Agent",1)pwd=Datatable ("Password",1)Invokeapplication "C:Program FilesMercuryInteractiveQuickTestProfessionalsamplesflightappflight4a.exe"Dialog("Login").ActivateDialog("Login").WinEdit("Agent Name:").Set AgentDialog("Login").WinEdit("Agent Name:").Type micTabDialog("Login").WinEdit("Password:").SetSecure pwdDialog("Login").WinButton("OK").ClickWindow("Flight Reservation").Close
  • 9. Parameterizationb. Importing test data from external files:Open Data Table (view>Data table)>placemouse pointer on data table and rightclick>file>import from file>Click ok>Browswpath of the file (it imports data from the flat file)Connecting Test Data to QTP Test as aboveand run the test.
  • 10. Parameterizationc. Importing test data from external Spreadsheets:Open Data Table (view>Data table)>place mousepointer on data table and rightclick>file>import from file>Click ok>Browse path ofthe excel sheet (it imports data from the excelsheet)Connecting Test Data to QTP Test as above andrun the test.
  • 11. Parameterizationd. Importing test data from Data bases:Through Data table we can import Test Data from Databases, but first we have to create /get the DSN(Datasource Name)& we have to use SQL Commands.i) Creating a Test Database: open MS Access (or we canuse any other database).ii) Start programs>MS Office>MS Access>file>new>Select blank Database>enter name of thedatabase>Save with mdb extension.iii) Creating Tables: Select Create table in designview>Enter field name(Agent)and Select data type(text)Like this we can create number of fields>save&entertable name.iv) Entering Data into Tables: Select table>enter thedata.v) Creating DSN & importing data
  • 12. ParameterizationNavigation:view>data table>Place mouse pointer on Datatable>sheet>import>fromdatabase(Database query wizard opens)>choose ‘specifySQL statements manually>clicknext >click create>click new>select driver type>click next>browse path to store> enterDSN Name>Click Save>click next>clickfinish>select>browse the database& select>clickok>click ok>select DSN>click ok>enter SQL statement(select *from login)>click finish.Note: DSN Creation is one time activity, by using the DSNwe can get data for number oftests.
  • 13. Parameterization4. Fetching Test Data directly from Flat filesDim fso, myfileSet fso=createobject("scripting.filesystemobject")Set myfile=fso.opentextfile("d:trigun.txt",1)myfile.skiplineWhile myfile.atendofline <> truex=myfile.readlineS=split(x,"@")
  • 14. ParameterizationSystemUtil.Run "C:Program FilesMercuryInteractiveQuickTestProfessionalsamplesflightappflight4a.exe","","C:ProgramFilesMercuryInteractiveQuickTestProfessionalsamplesflightapp","open"Dialog("Login").ActivateDialog("Login").WinEdit("Agent Name:").Set s(0)Dialog("Login").WinEdit("Agent Name:").Type micTabDialog("Login").WinEdit("Password:").SetSecure S(1)Dialog("Login").WinEdit("Password:").Type micReturnWindow("Flight Reservation").CloseWend
  • 15. ParameterizationFetching Test Data directly from DatabasesOption explicitDim con,rsSet con=createobject("adodb.connection")Set rs=createobject("adodb.recordset")con.provider=("microsoft.jet.oledb.4.0")con.open "C:Documents and SettingspoojaMyDocumentstrigun.mdb"rs.open "select * from login",condo until rs.eof=true
  • 16. ParameterizationSystemUtil.Run "C:Program FilesMercuryInteractiveQuickTestProfessionalsamplesflightappflight4a.exe","","C:ProgramFilesMercuryInteractiveQuickTestProfessionalsamplesflightapp","open"Dialog("Login").ActivateDialog("Login").WinEdit("Agent Name:").Set rs.fields("agent")Dialog("Login").WinEdit("Agent Name:").Type micTabDialog("Login").WinEdit("Password:").SetSecurers.fields("password")Dialog("Login").WinEdit("Password:").Type micReturnWindow("Flight Reservation").Closers.movenextloop
  • 17. ParameterizationUsing Dictionary Object for ParameterizationSet inputdata=CreateObject("Scripting.Dictionary")inputdata.Add "Agent","gcreddy"inputdata.Add "Password","mercury"SystemUtil.Run "C:Program FilesHPQuickTestProfessionalsamplesflightappflight4a.exe"Dialog("Login").ActivateDialog("Login").WinEdit("Agent Name:").Setinputdata("Agent")Dialog("Login").WinEdit("Password:").Setinputdata("Password")Dialog("Login").WinButton("OK").Click
  • 18. Step GeneratorThe Step Generator enables to add stepseasily, by selecting from a range of context-sensitive options and entering the requiredvalues.User familiar with VBScript, can add andupdate statements and enhance the tests withprogramming.After the test or an Action is recorded, itspower and flexibility can be increased byadding recordable and non- recordableVBScript statements as required for tasks likeCheckpoints, Datatables etc.
  • 19. Step GeneratorThese additional steps can be added eithermanually or using Insert>Step >StepGenerator.In the Step Generator dialog box steps can bedefined that use:-Test object methods and properties.-Utility object methods and properties.-Calls to library functions, VBScript functions,and internal script functions.
  • 20. Step Generator
  • 21. Adding conditional statementsConditional statements enable you to control the flow ofyour Test or component. You use the IF … THEN andELSE statement to incorporate decision-making in yourtests. The IF … THEN statement evaluates whether acondition is true. If the condition is true, the statementsfollowing IF … THEN are executed. If condition is not true,the statementsfollowing the ELSE are executed.If [condition] Then[statement]Else[else statement]End If
  • 22. Adding conditional statementsif...then...elseif statementif fee="Cash" thenmsgbox "pay cash!"elseif fee="Visa" thenmsgbox "pay with visa."elseif fee="American Express" thenmsgbox "pay with American Express."elsemsgbox "Unknown method of Payment."end If
  • 23. Custom checkPointsQTP checkpoints are very limiting when itcomes to maintenance and transport ofthe same across scripts. It is always bestto avoid QTP checkpoints wheneverpossible and create your own checkpoint.For doing the custom check points, weuse Reporter.ReportEvent method
  • 24. Custom checkPointsSyntax is: Reporter.ReportEvent EventStatus, ReportStepName, DetailsThere are 5 EventStatus.micPass – used to display passed events.micFail – used to display Failed events.micDone – No event statusmicWarning – used to display Warning events.micInfo – used to display any information events.
  • 25. Custom checkPointsReportStepName – Name/Text of node to be shown in the test results tree viewDetails – Text to be shown in the detail column of the report
  • 26. Custom checkPointsCustom CheckPoints and the Exist MethodThis is an extremely important concept, and it should serve as the base to all CheckPoints. It checks whether an object exists on the page or not, and before we can start verifying an object’s properties, it’s important that we check if it is even available to us to perform our verifications. Also, if the object is found in the applicantion, the Exist method returns true, else, it returns false.Syntax:Object.Exist(Timeout)
  • 27. Custom checkPointsIn this syntax, Timeout is the amount of time you would like QTP to wait for the object before it returns a boolean output.Case where an object is found.To check if the Text box exists, we can formulate the following code that will wait for a max of 5 seconds before the WebEdit appears on the page:MsgBox Browser("title:=.*Relevant Codes.*").Page("micclass:=Page").WebEdit("name:=txtExistTest").Exist(5)
  • 28. Custom checkPointsCase where an object is not found.MsgBox Browser("title:=.*Relevant Codes.*").Page("micclass:=Page").WebEdit("name:=txtNotFound").Exist(5) False
  • 29. Custom checkPointsCustom CheckPoints and the GetROProperty Method.GetROProperty is short for Get- Runtime-Object-Property. In other words, this method can be used to retrieve the value that the object has, at present.Note that, in some dynamic applications, runtime object properties can change on various factors.
  • 30. Custom checkPointsAlso, with Descriptive Programming (DP), regardless of what property you retrieve, it will always be a runtime property.IfBrowser("title:=.*Relevant.*").WebEdit("name:=t xtMaxLen").GetROProperty("max length")=10 ThenReporter.ReportEvent micPass, "WebEdit MaxLength Text", "Test Passed."ElseReporter.ReportEvent micFail, "WebEdit MaxLength Text", "Test Failed."End If
  • 31. Custom checkPointsWhen you open your Test Results after the abovestatement executes, you will notice that, the test failed.It will always fail because the maxLength for ourWebEdit is not 10, but 9. When you you use Object spyto retrieve the max length property,you will notice thatit is indeed not 10, but its 9. However, in the real-world,we may not always know the properties these objectswill have at runtime, and most of the times you willcome to find of errors after your regression suitescomplete their execution.
  • 32. Custom checkPointsLet’s create another CheckPoint, and verify if the Link has the correct color:With Browser("title:=.*Relevant Codes.*").Link("text:=Relevant Codes: Test Color")If .Exist(5) ThenIf .GetROProperty("color") = "#0000ff" ThenReporter.ReportEvent micPass, "RelevantCodes Link", "Correct color."ElseReporter.ReportEvent micFail, "RelevantCodes Link", "Incorrect color."End IfElseReporter.ReportEvent micFail, "RelevantCodes Link", "Link was not found."End IfEnd With
  • 33. QTP Continued Day4:Report and CommentSplitting ActionVirtual object
  • 34. QTP Continued Day5:Recovery scenarioOptional stepsFramework ApproachWorking with Dynamic Objects

×