Micro Focus QTP (UFT) Forums
SCript?? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: SCript?? (/Thread-SCript--7203)



SCript?? - rawat.jagat9 - 02-14-2013

how to check the number of unread emails in gmail using qtp


SCript?? - Pavan keerthi - 02-14-2013

'You need to be logged into the Gmail account
Code:
Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Inbox.*").Click
Browser("title:=Gmail.*").Page("title:=Gmail.*").Sync

'To get the innertext of inbox link
inboxcount = Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Inbox.*").getroproperty("innertext")
If inboxcount = "Inbox" Then
Print "No Unread Emails."
ExitAction
Else
emailcount = replace(inboxcount, "Inbox","") 'replaces inbox with space
emailcount = Rtrim(ltrim(emailcount)) 'removes all the spaces
emailcount = replace(emailcount, "(","")
emailcount = replace(emailcount, ")","")
Print "You have "&emailcount& " unread emails in your inbox."
End If
plz run this Script


RE: SCript?? - newqtp - 02-15-2013

Code:
'Login to gmail Account
Browser("opentitle:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "username"
Browser("opentitle:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Passwd").Set "password"
Browser("opentitle:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Sign in").Click
Browser("opentitle:=Gmail.*").Page("title:=Inbox.*").Link("innertext:=Inbox.*").Click
Browser("title:=Gmail.*").Page("title:=Gmail.*").Sync

' Get unread emails count
sLink= Browser("opentitle:=Gmail.*").Page("title:=Inbox.*").Link("innertext:=Inbox.*").GetROProperty("innertext")
'msgbox sLink

If sLink = "Inbox" Then
     iEmails = 0
     Msgbox "Total Unread Email(s) " & iEmails & "  No New email"
     Exit Action
else
'Split unread emails count from Inbox(XX)
  iEmails = Split(sLink, " ")(1) 'have total number of  unread email count as (XX)
  iEmails = Replace(iEmails, "(", "") ' this statement have partial number as XX)
  iEmails = Replace(iEmails, ")", "") 'antoher replace ) to blank sapce statement as XX
  Msgbox "Total Unread Email(s) " & iEmails
End If



RE: SCript?? - Ram2009 - 02-16-2013

To add to the above script, I am able to login successfully to gmail. But when I tried to click on Inbox I am getting the error.

Browser("name:=Inbox.*", "hwnd:=854422").page("title:=Inbox.*","hwnd:=852998").Link("innertext:=Inbox.*").click

Error is seen as below:

Cannot find the "[ Link ]" object's parent "[ Browser ]" (class Browser). Verify that parent properties match an object currently displayed in your application.

I am using QTP 10 trail version, Windows 7 ultimate OS, IE 8
Plx let me know if you need any other info.