Friday, May 9, 2014

QTP code to Delete mails recieved in present month

Option explicit
Dim u, p, i, nomp, x, k

'associate functions file
Executefile("F:\QTP\gml.vbs")

'launching site
launch

'log in site
u="EMAIL ID"
p="EMAIL ID"
login u,p

'click inbox
inbx
Do
'count no of rows
With browser("title:=.*")
With .page("title:=.*")
nomp=.webtable("name:=t").getroproperty("rows")
End With
End With
'get date of recieving mail
For i=1 to nomp step 1
With browser("title:=.*")
With .page("title:=.*")
x=.webtable("name:=t").GetCellData(i,4)
End With
End With
'check weather todays mail or not and delete
If instr(x, "am") or instr(x,"pm") Then
With browser("title:=.*")
With .page("title:=.*")
.webcheckbox("name:=t","index:="&i-1).set "on"
.webbutton("name:=Delete","index:=0").Click
i=i-1
End with
End with
'check weather may months or not and delete
elseif instr(x, "May") Then
With browser("title:=.*")
With .page("title:=.*")
.webcheckbox("name:=t","index:="&i-1).set "on"
.webbutton("name:=Delete","index:=0").Click
i=i-1
End with
End with
End If
Next
'check any older mails exist or not
With browser("title:=.*")
With .page("title:=.*")
k=.webelement("html tag:=B","index:="&p).getroproperty ("innertext")
End With
End With
'click older mails icon after deleting present page mails
If k="Older ›" Then
With browser("title:=.*")
With .page("title:=.*")
k=.webelement("html tag:=B","index:="&p).click
End With
End With
'increase oldermails icon upto 11 step by step
If p<>11 Then
p=p+1
End If
Else
Exit do
End If
Loop while 2>1
print("test passed")
sgnf

1 comment:

  1. Beautiful :) nice to see on blog what i have learnt really or practically :) :)

    ReplyDelete