KR Testing Solutions

Quality is effected by your work process

Query Forum

How to capture tool tip in QTP? 

E.g.: On Amazon.com, when you bring the mouse over the ‘A9′ search image (on the top-left side of the page), it shows ‘A9 search’ as tool-tip. This can be captured using following code: strToolTip= Browser(“title:=Amazon.*”).Page(“title:=Amazon.*”).Image(“src:=.*a9search.*”).getROProperty(“alt”)
msgbox strToolTip

How to Maximising a Browser?

Sub MaxBrowser( ByRef Browser )
hwnd= Browser.GetROProperty(“hWnd”)
Window(“hWnd:=”&hwnd).Maximize
End Sub
Call MaxBrowser(Browser(“micClass:=Browser”))

How to extract column from webpage ?

Dim colA(),colB()
totalRows = Browser(“<yourBrowser>”).Page(“<yourPage>”).WebTable(“<yourtable>”).RowCount
ReDim colA(totalRows), colB(totalRows)
For x = 1 to totalRows
colA(x) = Browser(“<yourBrowser>”).Page(“<yourPage>”).WebTable(“<yourtable>”).GetCellData(x,<firstcolumn>)
colB(x) = Browser(“<yourBrowser>”).Page(“<yourPage>”).WebTable(“<yourtable>”).GetCellData(x,<secondcolumn>)
Next 

How to Capture Screen shot ?

Sub captureScreenShot ()
          strStoreSnapshotMode = Setting(“SnapshotReportMode”)
      Setting(“SnapshotReportMode”) = 0
          Browser(“name:=.*”).Page(“title:=.*”).Sync
      Setting(“SnapshotReportMode”) = strStoreSnapshotMode
End Sub

How to Call SQL stored procedure from QTP?

Function RunStoredProcedure(StoredProcedureName)
sDatabaseName=”ABC”
sUID=”xyz”
sPWD=”ABC_xyz”
‘ Create the database object
Set cm = CreateObject(“ADODB.Command”)

‘ Activate the connection.
cm.ActiveConnection = “DRIVER={Microsoft ODBC for Oracle}; ” &_
“SERVER=” & sDatabaseName & “;
User ID=” & sUID & “;Password=” & sPWD & ” ;”

‘ Set the command type to Stored Procedures
cm.CommandType = 4

‘ Stored Procedures
cm.CommandText = StoredProcedureName

‘ Define Parameters for the stored procedure
cm.Parameters.Refresh

‘ Pass input value. Assuming Stored Procedure requires 2 parameters
cm.Parameters(0).Value = “Kuldeep”
cm.Parameters(1).Value = “Kumar”

‘ Execute the stored procedure
cm.Execute()
Set cm = Nothing
End Function

How to write the test Result (Output) on Excel sheet?   

Dim objexcel
Set objexcel= CreateObject(“Excel.sheet”)
objexcel.Visible = True
objexcel.Workbooks.add
With Window(“Calculator”)
.WinButton(“5″).Click
.WinButton(“*”).Click
.WinButton(“3″).Click
.WinButton(“=”).Click
End With  
result= Window(“Calculator”).WinEdit(“Edit”).GetROProperty(“text”)
 
If result=15 Then
         objexcel.ActiveSheet.Cells(1,1).Value = “test is pass”
         Reporter.ReportEvent micPass,”Calculation”, result
Else
         objexcel.ActiveSheet.Cells(1,1).Value = “test is Fail”
         Reporter.ReportEvent micFail,”Calculation”, “Expected Result is 15” +”Acutal is “+result
End If

what is the use of function GetROProperty()? 

GetROProperty is used to retrieve properties listed in Object Spy.

Example: hWnd=Browser(“browser_name”).GetROProperty(“hwnd”)
Window(“hwnd:=” & hWnd).Minimize

For Queries/comments click here

40 Comments »

  1. how to store .gui files and dat files in quality center

    Comment by DUrga | December 17, 2007 | Reply

  2. what is the script for connecting to ORCAL through QUICK TEST PROFESSIONAL PLZ REPLAY TO MY MAIL
    AND YOUR WORK IS NICE FOR ALL TESTING PERSONS

    Comment by nagesh | December 19, 2007 | Reply

  3. Dim objOutlookMsg
    Set objOutlook = CreateObject(”Outlook.Application”)
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    objOutlookMsg.To = “anamika.sharma@telus.com”
    objOutlookMsg.Subject = “test”
    objOutlookMsg.Body = “Hello Anamika, from QTP”
    objOutlookMsg.Attachments.Add “C:\Documents and Settings\Desktop\anurag.xls”
    objOutlookMsg.Send

    This code is not working when i paste this into expert view in QTP. Please send me more guidance.

    Comment by Anamika | February 1, 2008 | Reply

  4. [...] Query Forum [...]

    Pingback by QTP Scripts examples « KR Testing Solutions | February 5, 2008 | Reply

  5. hi sir,
    thanks for u r material.please send me quality centre study material.

    Comment by T.L.K.Govinda Chary | February 29, 2008 | Reply

  6. I have 4 different values and i need to identify a row in an excel using QTP.

    i.e Suppose a = ab, b = v4.3, c= WT and d = kl

    now these values are present in an excel sheet.
    i want the row in which these value are residing.
    All the 4 values will be residing in a single row.

    Please suggest.

    Comment by Ronny | February 29, 2008 | Reply

  7. Hi ,

    Iam working in testing and I have learned QTP and practicing the scripts now .I want to know the script for the Data driver testing for flight application in windows.

    Could you please provide me the script for this …..

    Thanks
    Krishna

    Comment by krishna | March 1, 2008 | Reply

  8. Hey Guys,
    You are doing a great job. Please put some more sample script so that new people who are not so familiar with the scripting can learn how to write script. You can write scripts on any scanario and put it on this blog. Thanks for quick response. Are you guys from Delhi?

    Comment by Pari | March 4, 2008 | Reply

  9. Nice Kuldeep. Its a very healthy feeling to see the awsome contribution you have done to the industry with me as the 1st one on the list.

    Comment by Abhinav Vaid | March 6, 2008 | Reply

  10. Thanq Kuldeep u people are doing a great job

    Comment by Subramanyam | March 12, 2008 | Reply

  11. How to verify fontsize using winrunner.

    Comment by Ravisekar.J | March 25, 2008 | Reply

  12. How to verify fontsize using winrunner.
    Pls Reply To jack.sekar@gmail.com

    Thanks in Advance.
    Ravi.J

    Comment by Ravisekar.J | March 25, 2008 | Reply

  13. Hi guys plz let me know any site from where i can download sample applications and practice. As i’m new to Automation by working on a sample application i think i can learn more.

    Comment by Sheshadri | March 25, 2008 | Reply

  14. I am planning to perform a Load testing for one of the application. Could you please share with me the load testing plan/ template.

    Thanks
    Sudheer
    91 9941332907

    Comment by Sudheer | March 27, 2008 | Reply

  15. hi,
    thank you for the answer posted for me .. it was gr8 and use ful.
    one more samll query here whts the reguler expression to find an value “in between”, i know how to use stars with ends with but i could not find an reguler expression to find the value whic is inbetween a word EG: if i type “ple” it should show all the values which has ale in it {sample,ample}, so how do we do this.?

    Regards
    Masha

    Comment by Masha | April 15, 2008 | Reply

  16. need to know how to use silk test tool for automation. I would appreciate if you could also give me some sample test cases for HL7 used for drug Prescription and Pharmacy claims
    Thanks

    Marina

    Comment by Marina | May 18, 2008 | Reply

  17. I am running query using QTP which retrives around 70 to 80 rows from database.This is taking around 3 minutes.But if i run the same query using editors such as Aqua Data Studio it is taking just 40 seconds.

    Please any one can tell me ahy it is taking long time to run in QTP as compared to editor.

    Is there any solution where i can reduce the query running time in QTP.

    Comment by Venu Shinde | May 27, 2008 | Reply

  18. Hi,

    How to verify the navigation which changes dynamically.
    e.g.

    Now with 50 Recoreds –Page 1
    later with 150 records — page 1 2 3

    How to put conditions for available page links at a instant

    Comment by Rahul_Test77 | May 28, 2008 | Reply

  19. hi,

    The microsoft query button in the data driver wizard is disabled when i am using winrunner. Could u please tell me the reason how to rectify that.

    thanks
    v

    Comment by v | June 4, 2008 | Reply

  20. hi,i want to do HP-QTP 9.2 certification.Plz specify how I can get material for preperation.

    Comment by Aruna | June 19, 2008 | Reply

  21. Is it possible to get QTP result in Excel sheet and in the form of Graph i.e Pie or bar Graph if so pls send script to the above mail id

    Comment by Vijayashree | June 19, 2008 | Reply

  22. hi,i completed my B.sc(computer science)in 2004.now i want to learn testing&i want to do job.pls tell me where can i start.

    Comment by radhika | June 20, 2008 | Reply

  23. hello sir..

    the amazing knowledge shared by you. its awesome and will definately help begginers like me. I hope I’ll definaltey get some help from you on my way to learning QTP descriptive .

    Comment by any | June 28, 2008 | Reply

  24. Hi,

    How to validate or fetch the Data From PDF ? please help me with the same.

    Regards
    Mahendra

    Comment by Mahendra | July 10, 2008 | Reply

  25. sir
    thanks for providing notes on qtp using vb script . hope it benifit many like me.

    Comment by surya prakash | July 27, 2008 | Reply

  26. Hello KR Team,

    First of all, Many thanks for you support and effort.

    How can i unzip files using VBscript in QTP?
    Please help.

    Regards

    Comment by GVMS | August 13, 2008 | Reply

  27. Hi,
    I am getting an error while exporting 3XL sheets to the same work book where the data will be written in a loop. From the first loop it writes one row in all the 3Xl sheet, by the end of 4th loop the data sheet is ready to export, but i get “General Run Error” after the first sheet is exported. Please do let me know if there is a way out for the same.

    Thanks
    Mahendra

    Comment by Mahendra | September 5, 2008 | Reply

  28. Hi ,

    how to get the count of number of nodes in a Tree View through VBscript . ie. i want the number of total Parent nodes and child nodes for each nodes and their values for example id Tree View is Register editor i.e when we go to regedit , wee find Left Tree View the their values in that case how can i get the no of parent and Child nodes and also their values

    Comment by anji | September 10, 2008 | Reply

  29. I am using data sheet in excel format and my script opens this excel and fetches values to each and every test case, now i am integrating QC with QTP. Can you please let me know how to open the same data sheet from QC? or else do i need to attach this data sheet to main folder of this feature so that all test cases can access the data sheet?

    Plz suggest..

    Comment by anfal | September 16, 2008 | Reply

  30. Hi,

    This is regarding changing a value in JavaList object that already has some value. Note:This object allows to both select from the lsit or enter a new value.

    JavaList(“Quantity (mm):”) already has 100 as its value.

    When the following statement runs,the new value from datatable is appending to the old value.Ex:The JavaList(“Quantity (mm):”) already has 100 and im selecting 200 from datatable the result is 100200.Is there a way to to delete the existing value 100.

    JavaWindow(“CompanyName – QA.*”).JavaDialog(“Change Order”).JavaList(“Quantity (mm):”).Select DataTable(“NewQuantity”, dtLocalSheet)

    Thanks
    Sunil

    Comment by Sunil | October 31, 2008 | Reply

  31. Hello..u hav done a great job by posting so much informations..AL de wishes 4 ur KR testing Solutions..

    Comment by Soumya Sreekanth | November 24, 2008 | Reply

  32. excellent material

    Comment by Butchi Reddy | December 30, 2008 | Reply

  33. What is automation testing

    Comment by Test | January 30, 2009 | Reply

    • Software Test Automation is the process of automating the steps of manual test cases using an automation tool Or utility to shorten the testing life cycle with respect to time…
      When application undergoes regression, some of the steps might be missed out or skipped which can be avoided in Automation…
      Automation helps to avoid human errors and also expedite the testing process…
      To implement the Test Automation detailed planning and effort is required

      Comment by kuldeep kumar | February 9, 2009 | Reply

  34. Hi Kuldeep/Rakesh,

    You are really doing nice work.I have one query On QTP testing in Oracle Application.

    I am trying to do some setups,using QTP and for that purpose,I need to parameterize checkbox.Can you please explain,how I can achive it.

    Thanks,

    K.Manish.

    Comment by K.manish | March 17, 2009 | Reply

  35. how to call a url from QTP by scripts?

    my scranrio is

    Registe a customer in portal

    1 After entering the customer code in the portal
    2 Will receive a mail with passcode
    3 Then entering the passcode in portal to continue further

    Comment by mahesh | March 19, 2009 | Reply

  36. How to kill the process in the task manager by using vbscrip.

    Comment by Chaitanya | June 17, 2009 | Reply

    • Try this:

      strComputer = “.”
      Set objWMIService = GetObject(“winmgmts:” _
      & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2″)
      Set colProcessList = objWMIService.ExecQuery _
      (“SELECT * FROM Win32_Process WHERE Name = ””)
      For Each objProcess in colProcessList
      objProcess.Terminate()
      Next

      Comment by kuldeep kumar | June 25, 2009 | Reply

      • Hello kuldeep,

        Thanks a lot for your response. But i am unable to execute to it.

        Regards,
        Chaitanya.

        Comment by Chaitanya | July 22, 2009

  37. hallo,

    ich habe versehentlich einige wichtige bilder von meinem MP3 Player gelöscht. Leider sind die Dateien nicht mehr im meinem Papierkorb.
    Die Files waren sehr wichtig für mich! Ich würde die gerne wiederherstellen.
    Im Internet fand ich dazu die Seite http://www.datenrettung-info.com, die eigentlich schon ganz gut die Möglichkeiten der Wiederherstellung von Daten beschreibt. Dort sind die verschiedenen Wege für unterschiedliche Medien ganz gut beschrieben.
    Hat wer noch einen Tipp für mich, wo ich noch weitere Infos finden kann?

    danke

    Comment by CleawayCrek | July 12, 2009 | Reply


Leave a comment