10-10-2013, 11:16 PM
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
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