Friday, 31 January 2014

Yahoo Mail Test Automation



Testing to find out Number of Unread Mails, Number of Mails Replied, Number of Mails with Attachments, and Number of Mails Forwarded :-)  Try It Yourself

Note:  Please ensure you check the values of properties correctly as they will change according to the yahoo mail versions that you are using

Option explicit
Dim ieo, nomp, noum, nofm, norm, noma, i, x, y, z

'launch yahoo mail websiteSet ieo=createobject("internetexplorer.application")
ieo.visible=true
ieo.navigate"http://www.mail.yahoo.com"

'login to yahoo mail
With browser("title:=.*")
        With .page("title:=.*")
            .webedit("name:=login").set "Enter a mail ID"
            .webedit("name:=passwd").setsecure "52eb84c9b61269a00a33b5b390e3f67da3ecc4f15"
            .webbutton("name:=Sign In").click
        End With
End With

'Find number of unread mails, number of mails with attachments, number of forwarded mails, and number of replied mails from the mail box
Noum=0
Norm=0
Nofm=0
Noma=0
Do
With browser("title:=.*")
          With .page("title:=.*")
          Nomp=.webtable("name:=toggleAll").rowcount
For i = 2 to Nomp step 1
    x=.webtable("name:=toggleAll").getcelldata(i,1)
    y=.webtable("name:=toggleAll").getcelldata(i,3)
    z=.webtable("name:=toggleAll").getcelldata(i,7)
    if x= "Unread" then
             noum=noum+1
    end if
    if y= " You replied to this message" then
             norm=norm+1
    end if
    if y= " You forwarded this message" then
             nofm=nofm+1
    end if
    if z= " Attachments" then
             noma=noma+1
    end if
Next

'Go to next page
If .link("name:= >", "index:=0").exist then
    .link("name:= >", "index:=0").click
    wait (3)
Else
Exit do 'statement to terminate infinite loopEnd if
End with
End with
Loop while 2>1

'Do logout With browser("title:=.*")
          With .page("title:=.*")
                    .link("name:=sign out").click
           End with
End with
set ieo=nothing

'Display output
Reporter.reportevent micdone, "Mailbox Testing",  "Get"&noum&"mails"
Reporter.reportevent micdone, "Mailbox Testing",  "Get"&norm&"mails"
Reporter.reportevent micdone, "Mailbox Testing",  "Get"&nofm&"mails"
Reporter.reportevent micdone, "Mailbox Testing",  "Get"&noma&"mails"

No comments:

Post a Comment