Sunday, May 22, 2011

QTP 10 Menu Item Missing

Try the below steps, You will get your menu item's back.


Step1: Launch QTP.
Step2: Right click on the top of toolbar
Step3: Select Customize ---> Select Toolsbar Tab ---> Click on Restore All

Monday, May 16, 2011

How to use key strokes in QTP?


'Problem: Sometimes it happened that QTP is not recognizing the objects. Can i use keyboard strokes to click any of the link and Navigate the different parts of open application.

'Solution: 
'Use of KeyStroke on Active Browser/Window
Set Obj=CreateObject("WScript.Shell")
wait 2
Obj.Run "http://www.google.com"
wait 2
     Obj.SendKeys "{Enter}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
     Obj.SendKeys "{Enter}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Tab}"
  wait 2
  Obj.SendKeys "{Enter}"
         
'The above code will
1.  Launch "Google.com"
2.  Click on link "Advanced Search"
3.  Click on link "Google Instant" within Advanced Search Page

How to Close Multiple Browser? QTP

Problem: I have 10 open Browsers, How can i close them 1 by 1.

Solution:

'Close All the Open Browser
While Browser("title:=.*","index:=0").Exist
Browser("title:=.*","index:=0").close
Wend

Friday, February 25, 2011

Perform search in Excel file

'Excel1 : D:\temp.xls            Sheet1 with two columns "Mobile" &"result"
'Excel2 : D:\temp1.xls           Sheet1 with column "Mobile"
'Search "Mobile #" present in Excel1 into Excel2
'if information is available in Excel 2 , Put the text "P" in result column of Excel1
'if information is not available in Excel 2 , Put the text "NP" in result column of Excel1
'Save temp.xls as temp2.xls
---------------------------------------------------------------------------------------

DataTable.Import "D:\temp.xls"
globalrow=DataTable.GetRowCount

Set obj=Createobject("Excel.Application")
Set objwb=obj.WorkBooks.Open("D:\temp1.xls")
Set objsheet=objwb.Sheets("Sheet1")
obj.visible="True"
flag=0

For i=1 to globalrow
   Datatable.SetCurrentRow(i)
   dev=int(DataTable("East",global))
   set foundrow=objsheet.Cells.Find(dev)
   On Error resume next
   flag=foundrow.Row

   If flag<>0Then
    DataTable.Value("result",global)="P"
    else
    DataTable.Value("result",global)="NP"
  End If
flag=0
Next

DataTable.Export "c:\temp2.xls"


Revert me back in case of query @ http://twitter.com/jaijeetpandey

Friday, December 24, 2010

MouseOver, Font, Color, Size, Background color,Change in Link color

Get the colour of the link after moving the mouse over the link on webpage

msgbox Browser("").Page("").Link("").Object.currentstyle.color    'Before moving the mouse over the link
Setting.WebPackage("ReplayType") = 2
Browser("").Page("").Link("").FireEvent "onmouseover"
msgbox Browser("").Page("").Link("").Object.currentstyle.color       'After moving the mouse over the link


The same way you can find the Font Size, Font Name  etc.

Browser("").Page("").Link("").Object.currentstyle.color
Browser("").Page("").Link("").Object.currentstyle.fontSize
Browser("").Page("").Link("").Object.currentstyle.fontFamily
Browser("").Page("").Link("").Object.currentstyle.backgroundColor

Tuesday, November 30, 2010

How to Calculate Transaction Time for a functional transaction with the help of QTP?

Using MercuryTimers you can find out the transaction time.



Systemutil.run "http://www.google.com"
For i=0 to 3
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q","micclass:=WebEdit").Set DataTable("search_term",global)

MercuryTimers("Search").Start 
Browser("title:=Google").Page("title:=Google").WebButton("name:=Google Search","micclass:=WebButton").Click
Browser("title:=.*Google Search").Page("title:=.*Google Search").Sync
Reporter.ReportEvent micDone,"Search Time for Iteration "&i+1,""& MercuryTimers.Timer("Search").ElapsedTime/1000
MercuryTimers("Search").Stop

DataTable.SetNextRow
Browser("title:=.*Google Search").Back
MercuryTimers.Timer("Search").Reset
Next

Note:
'Create a Column "search_term"  in DataTable ( Global Sheet)
'Enter 4 different search Terms




Mercury Timer   Transaction Time   End to End Testing