Forum Discussion

chinmaya_chiras's avatar
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")



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")



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 ?

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 2 rankChampion Level 2
    Hi Chinmaya,



    > [...] learning QTP 10.0 [...] Why code 2 is failing ?



    a) This is TestComplete by SmartBear (www.smartbear.com) but not QTP forum. Both tools, basically, do the same, but in different ways, so you might or might not get a reply; and

    b) It would help (on the QTP forum as well) if you let people know what does 'passed' and 'failed' mean. Does QTP crash? Does the tested application crash? Any error is posted to the log? What the error text says? What code line errors out? Etc. As a general rule: the more information about your problem you provide people with, the more chances that someone will reply you with the possible solution.