Friday 2 August 2013

Automating Desktop application (G-talk chat) Using QTP!!

Prerequisites
1)Need to download G-talk chat application on your system and its shouldn't minimize  chat application cause some times  QTP may not identify 


'print window("text:=Google Talk").exist
Set gcon=description.Create
gcon("micclass").value="window"
gcon("text").value="Google Talk"
set gtalk=desktop.ChildObjects(gcon)
msgbox gtalk.count
'Enter username and password
Set desc_edit=description.Create
desc_edit("micclass").value="winedit"
Set input=gtalk(0).childobjects(desc_edit)
msgbox input.count
input(0).set "*****"
input(1).set "*****"
'button
desc_edit("micclass").value="winbutton"
Set button=gtalk(0).childobjects(desc_edit)
button(0).click
wait(10)
'winobject ,contactlist
desc_edit("micclass").value="winobject"
desc_edit("text").value="Contact List"
Set contactlist=gtalk(0).childobjects(desc_edit)
msgbox contactlist.count
'msgbox contactlist(0).getvisibletext()  'it gives complete contact list in ur gtalk
msgbox contactlist(0).getvisibletext(3,180,250,220) 'left,top,right,bottom coordinates
contactlist(0).click 10,(180+220)/2
wait(10)
Set desc_chat=description.Create
desc_chat("micclass").value="window"
desc_chat("regexpwndclass").value="Chat View"

Set chat_win=desktop.ChildObjects(desc_chat)
msgbox chat_win.count

desc_chat("micclass").value="winobject"
desc_chat("regexpwndclass").value ="RichEdit20W"
Set msgB=chat_win(0).childobjects(desc_chat)
msgbox msgB.count
msgB(0).type "Hello"

'Press Enter key

Set ws=createobject("wscript.shell")
ws.SendKeys "{Enter}"





No comments:

Post a Comment