Quality Testing

Quality is delighting customers

gmail QTP script for showing toal no of read and unread mail in aur account and print all read and unread mail one by one

SystemUtil.Run "IEXPLORE.exe","www.gmail.com","open"
'for browser existence
If browser("title:=Gmail: Email from Google .*").Exist Then
    reporter.ReportEvent micPass, "step-1 launched","correct browser was launched"
    else
        reporter.ReportEvent micFail, "step-1 launced", "browser was not found"
        
End If

Set myp = Browser("title:=.*").page("title:=.*")
If myp.webedit("name:=Email").exist Then
 myp.webedit("name:=Email").Set "mailid"
 
   reporter.ReportEvent micPass, "username", "exist"
 If  myp.webedit("name:=Passwd").exist Then
     myp.webedit("name:=Passwd").Setsecure "password"
     If  myp.webbutton("name:=Sign in").exist Then
         myp.webbutton("name:=Sign in").Click
         else
            reporter.ReportEvent micFail,"Sign button","button was not found"
             End If
        else
           reporter.ReportEvent micFail, "Password feild", "Edit feild was not found"
            End If
    else
        reporter.ReportEvent micFail, "username", "feild was not found"
    
 End If
Browser("title:=.*").Sync
'If browser("title:=.*").page("title:=Gmail-Inbox.*").Exist Then
'    reporter.ReportEvent micPass,"Test Pass","Login Successfully"
'    print ("Login successfully")
    set myinbox= browser("title:=.*").page("title:=Gmail - Inbox")
    'msgbox"For fetching total mails i used x,y cordinates as object and their property, so at different systemit may be not work so plz set x,y property value"
Tot=myinbox.webelement("outerhtml:=<B>.*</B>","html tag:=B","index:=0","x:=1242","y:=143").GetROProperty("innertext")
msgbox Tot

'row=myinbox.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").RowCount
'print "Total rows are exist on one page"&row

j=0

'For i=j to row+j
'    Dim t
'    t=myinbox.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").GetCellData(i,2)
'    't(i,3)=myinbox.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").GetCellData(i,3)
'print "mail from-->" &t
'j=i
'Next

loops(0)
counter=true
while(counter)
msgbox"t"&t
If t=Tot Then
    msgbox"All mails are listed"
    counter=false
    else
    myinbox.link("html tag:=A","text:=Older ›","index:=0").click
    
loops()
counter=true
End If

Wend



a=myinbox.link("text:=Inbox .*","html tag:=A","Index:=0").getroproperty("innertext")
b=len(a)


If b=5 Then
    msgbox"there are no unread msg"
    else
    c=mid(a,8,len(a)-2)
    
    d=left(c,len(c)-1)
    print"Unread msgs are" &d
End If

m=Tot-d
print"Read msg are..."&m

'    else
'      reporter.ReportEvent micFail,"test fail","Login failed"
'      print("login failed")
'end if

'--------------------Function definition---------------------------

Function loops(j)
   set myp=browser("title:=.*").page("title:=Gmail - Inbox")
   row=myp.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").RowCount
print "Total rows are"&row
    For i=j to row+j
        Dim t,m

        t=myp.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").GetCellData(i,2)
        't(i,3)=myinbox.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").GetCellData(i,3)
    print "mail from-->" &t
' m=myp.webtable("name:=Compose Mail","html tag:=TABLE","Index:=0").webtable("name:=t","html tag:=TABLE").getcelldata(i,2)
msgbox m

' print "unread mail--->" &m
    j=i
    
    Next
return j


End Function

Views: 535

Tags: Gmail, Inbox, QTP, and, fimding, for, in, mail, read, script, More…unread

Comment

You need to be a member of Quality Testing to add comments!

Join Quality Testing

Comment by Pradeep Sagar on August 13, 2012 at 9:32pm

Thank you sir

i need it a lot

thank you very much

TTWT Magazine

Welcome to Quality Testing!

Keith Klain

 Director - Head of Global Test Center at Barclays

Advertisement

Submit A Job

Submit A Tool

Advertisement

Videos

  • Add Videos
  • View All

Badge

Loading…

© 2013   Created by Quality Testing.

Badges  |  Report an Issue  |  Terms of Service