Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected Behavior of Reporter.Reportevent
#1
Solved: 10 Years, 3 Months, 3 Weeks ago
Hi all, I am new to this forum. I executed the following two codes in QTP 10.0. The objective of both the codes are same, and that is to verify the username displayed in acti-time application. Both the codes are syntactically correct and without any run time error. But I am getting different statuses on result screen after executing the codes. Here are the two codes

Code 1 :

Code:
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:

Code:
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 variable "username" and variable "s" will hold the value "User: Administrator System (admin) ". I was expecting code 2 to display passed in result screen as when "s" is splitted, all the elements in the string will be stored in the array "arr". Now while comparing each element of the array "arr" with the value of variable "username", the element arr(3) will match with the value of the variable "username" and the reporter.reportevent statement for micpass should be executed and in result screen the status would have been "Passed". But it is not happening in code 2 and the statement for micfail in the else part is executing. But Code 1 is performing well as per my expectation.

Why my code 2 is failing ? Can someone please help me out ?
Reply
#2
Solved: 10 Years, 3 Months, 3 Weeks ago
In 2nd method when for loop is Executed, Each time it will check Username. So when Username is not matches, immediately Else condition will be executed. So we should use only 1st code only.
Reply
#3
Solved: 10 Years, 3 Months, 3 Weeks ago
But Sir,
At one point, it will match with the username and then reporter.reportevent for micpass will be executed and then Exit for will be executed. And this will throw the execution out of the for loop and as reporter.reportevent for micpass is executed, the result status would have been Passed. Am I right ??
Reply
#4
Solved: 10 Years, 3 Months, 3 Weeks ago
What you said is correct. But can you please look into the both codes, how you are splitting. Try to debug by using F11, Then you come to know what was the wrong
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Drag and Drop Annoying QTP Behavior ShaneP 1 4,508 08-21-2015, 07:25 PM
Last Post: Nj_Acc
Question Is Reporter ignoring the status of steps? dlaureano 3 3,399 06-05-2014, 01:38 PM
Last Post: Jay
  QTP Automation: How to retrieve Reporter.Reportevent Message scsenthil 1 5,250 11-14-2013, 07:51 PM
Last Post: spannerj
  QTP vbscript ArrayList strange behavior frankhovin 2 2,827 11-11-2013, 07:12 PM
Last Post: Parke
  error reporter carr2805 0 1,715 07-15-2010, 03:54 AM
Last Post: carr2805

Forum Jump:


Users browsing this thread: 1 Guest(s)