Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic error handling
#1
Solved: 10 Years, 4 Months ago
Yeah, I'm a noob...but I have no one else to help me...

What is the elegant/accepted way to do error checking in QTP VB Script? I want the test to not stop on an application error, but rather mark the test as Failed and hopefully give me a clue what the error was.

Seems simple, but I can't think of a good way to do it.
For example, if I do this:

1: On error resume next
2: Dialog("somewindow").Select "something"
2: Dialog("something").WinEdit("afield").Set "hi"
3: Dialog("something").WinEdit("afield2").Set "hi"
...
100: Dialog("something").WinEdit("afield100").Set "howdy"
101: if err.number<>0 then Reporter.ReportEvent micFail, "Entering data in big window", ("Error # " & CStr(Err.Number) & " " & Err.Description)


The problem is the error might be, "could not set value of afield100" when the real error was that we couldn't open the window in Line 2.

Because there is no, "On error Goto line/tag" in QTP VBScript I have no way of knowing what line the error happened on....do I?
I don't want to know the LAST err.number we got, I want to know the FIRST err.number we got.

You don't want to do, "If err.number<>0..." after every single line do you?

About the best I can think of is something like:

1: On error resume next
2: step =1
3: Dialog("somewindow").Select "next window"
4: step =2
5: Dialog("something").WinEdit("afield").Set "hi"
...
99: step = 100
100: Dialog("something").WinEdit("afield100").Set "howdy"
101: if err.number<>0 then Reporter.ReportEvent micFail, "Entering data in big window", "error after Step " & step & err.description

But that is pretty clunky....there must be a better way.
I just want to know what line caused the first error-or just what the first error was- but doing error checking after every line would be ridiculous.

Ideas?

Thanks,
Mark
Reply


Messages In This Thread
Basic error handling - by RandomGrin - 10-10-2013, 11:16 PM
RE: Basic error handling - by basanth27 - 10-11-2013, 10:11 AM
RE: Basic error handling - by RandomGrin - 10-11-2013, 07:52 PM
RE: Basic error handling - by basanth27 - 10-12-2013, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Estimate for preparing a basic test script QTPBeginner48 4 2,792 02-25-2014, 03:45 PM
Last Post: guin.anirban
  Flight reservation basic parameterization not working on qtp 11.5 srs246 0 3,569 01-08-2013, 10:14 AM
Last Post: srs246
  3 basic questions..please help Blizna 5 4,758 07-09-2010, 12:21 PM
Last Post: sasmitakumari
  Visual Basic Application Recording dlopes 2 2,365 07-09-2010, 10:21 AM
Last Post: Saket
  What is the errors handling ? keni 1 2,367 10-26-2009, 09:47 AM
Last Post: Saket

Forum Jump:


Users browsing this thread: 1 Guest(s)