12 years ago
Behavior of Reporter.reportevent
Hi all,
I am a student learning QTP 10.0. I executed the following two codes with the aim to verify the user name display in a web page. But though the two codes appear to me correct with the use of reporter.reportevent, they are throwing different results. Below are the two codes and their results.
Code 1:
Dim username
username=inputbox("enter the username")
systemutil.Run "http://127.0.0.1/login.do"
with Browser("title:=acti.*").page("title:=acti.*")
.webedit("name:=username").set "admin"
.webedit("name:=pwd").set "manager"
.webbutton("name:=Login now").click
end with
s=browser("title:=acti.*").page("title:=acti.*").webelement("innertext:=User.*","html tag:=SPAN").GetROProperty("innertext")
arr=split(s)
For i=0 to ubound(arr)
If arr(i)="("&username&")" Then
desc=1
Exit for
else
desc=desc
End If
Next
If desc=1 Then
reporter.ReportEvent micPass, "un verify", "proper username is displayed"
else
reporter.ReportEvent micFail, "un verify", "improper username is displayed"
End If
browser("title:=acti.*").Close
Result : Passed
Code 2 :
Dim username
username=inputbox("enter the username")
systemutil.Run "http://127.0.0.1/login.do"
with Browser("title:=acti.*").page("title:=acti.*")
.webedit("name:=username").set "admin"
.webedit("name:=pwd").set "manager"
.webbutton("name:=Login now").click
end with
s=browser("title:=acti.*").page("title:=acti.*").webelement("innertext:=User.*","html tag:=SPAN").GetROProperty("innertext")
arr=split(s)
For i=0 to ubound(arr)
If arr(i)="("&username&")" Then
reporter.ReportEvent micPass, "un verify", "proper username is displayed"
Exit for
else
reporter.ReportEvent micFail, "un verify", "improper username is displayed"
End If
Next
browser("title:=acti.*").Close
Result : Failed
In both the codes I have used "admin" as value for the variable "username" and variable "S" will hold "User: Administrator System (admin) ".
Why code 2 is failing ? Can you guys please help me out ?
I am a student learning QTP 10.0. I executed the following two codes with the aim to verify the user name display in a web page. But though the two codes appear to me correct with the use of reporter.reportevent, they are throwing different results. Below are the two codes and their results.
Code 1:
Dim username
username=inputbox("enter the username")
systemutil.Run "http://127.0.0.1/login.do"
with Browser("title:=acti.*").page("title:=acti.*")
.webedit("name:=username").set "admin"
.webedit("name:=pwd").set "manager"
.webbutton("name:=Login now").click
end with
s=browser("title:=acti.*").page("title:=acti.*").webelement("innertext:=User.*","html tag:=SPAN").GetROProperty("innertext")
arr=split(s)
For i=0 to ubound(arr)
If arr(i)="("&username&")" Then
desc=1
Exit for
else
desc=desc
End If
Next
If desc=1 Then
reporter.ReportEvent micPass, "un verify", "proper username is displayed"
else
reporter.ReportEvent micFail, "un verify", "improper username is displayed"
End If
browser("title:=acti.*").Close
Result : Passed
Code 2 :
Dim username
username=inputbox("enter the username")
systemutil.Run "http://127.0.0.1/login.do"
with Browser("title:=acti.*").page("title:=acti.*")
.webedit("name:=username").set "admin"
.webedit("name:=pwd").set "manager"
.webbutton("name:=Login now").click
end with
s=browser("title:=acti.*").page("title:=acti.*").webelement("innertext:=User.*","html tag:=SPAN").GetROProperty("innertext")
arr=split(s)
For i=0 to ubound(arr)
If arr(i)="("&username&")" Then
reporter.ReportEvent micPass, "un verify", "proper username is displayed"
Exit for
else
reporter.ReportEvent micFail, "un verify", "improper username is displayed"
End If
Next
browser("title:=acti.*").Close
Result : Failed
In both the codes I have used "admin" as value for the variable "username" and variable "S" will hold "User: Administrator System (admin) ".
Why code 2 is failing ? Can you guys please help me out ?