Friday, May 9, 2014

QTP code to count inbox mails

Option explicit
Dim u,p,m,em,k,x,sm
'associate functions file
Executefile("F:\QTP\gml.vbs")
'launching site
launch
'log in site
u="MAIL ID"
p="ENCRYPTED PASSWORD"
login u,p
'click inxox
inbx
em=0
k=9
Do
'counting no of mails in first page and clicking next page
With browser("title:=.*")
With .page("title:=.*")
m=.webtable("name:=t").getroproperty("rows")
em=em+m
x=.webelement("html tag:=B","index:="&k).getroproperty("innertext")
If x="Older ›"  Then
.webelement("html tag:=B","index:="&k).click
'increase k value until k becomes 11 since index is varying as newer and newest is adding for the next time
if  k<>11then
k=k+1
                                End If
else
exit do
End If
End With
End With
Loop while 2>1
'taking data of total mails showing
With browser("title:=.*")
With .page("title:=.*")
sm=.webelement("html tag:=B","index:=10").GetROProperty ("innertext")
sm=cint(sm)
If em=sm Then
print("test passed")
else
print("test failed")
End If
End With
End With
sgnf

No comments:

Post a Comment