I am using the "On Error Resume Next" option for error handling... below is the code.
Here I have three webedit statements available and down I am checking "If err.number <> 0".
My question once my first web edit statement returns error, the control should go to "If" condition and check.
Please suggest me how to proceed with that.
On error resume next
Browser(oBrowser).Page(oPage).WebEdit(EditBox,"Ind ex:=0").Set "123"
Browser(oBrowser).Page(oPage).WebEdit(EditBox,"Ind ex:=1").Set "Test"
Browser(oBrowser).Page(oPage).WebEdit(EditBox,"Ind ex:=2").Set "Sample"
If err.number <>0 Then
On Error Goto 0
There are lots of thread for on error Resume.. just search it in the forum.. for query Just change the Test Settings in Run tab , when error occurs 'Procedd to next step' instead of popup box..
Another option is to use Recovery Scenario with the condition embedded in a user-defined function...exlore the Recovery Scenario Wizard...u will get to know what I am talking about...
Thank You for answers.
But I have tried using the Test Settings -> Run -> changed the option from "Pop up message box" to "proceed to next step".
But if I have error in the first webedit line, still the control is going to second line....third line and then going to "IF" condition.
I don't want to use the Recovery Scenarios. Please suggest.
Well only way to do it would be below
Buy the NEW QTP Descriptive Programming Unplugged Book
** Download QTP Unplugged 2nd Edition eBook for FREE **
There seems to be no way to have a error handler active on all statements within QTP other than recovery scnearios.
Powerdebug would replace that, if you had seen the features it offers.
Else have a function call after each statement where you feel error may occur, but then the choice is yours to define at all places, extra overhead
-- Here to Learn and share ---
"On Error Resume Next" just let control flow continue.
You need to test If err.Number <> 0 right after the ponential error row, or put the test in each row to catch the error.
Create a generic input function where you pass the object and data.
InputData Browser(oBrowser).Page(oPage).WebEdit(EditBox,"Ind ex:=0"), "123"
InputData Browser(oBrowser).Page(oPage).WebEdit(EditBox,"Ind ex:=1"), "Test"
In the function, you can wrap entry for each object type with the appropriate .Exist or any other state checks along with error handling.
Sub InputData(obj, data)
select case on object type
If obj exists...
On error resume
If err.number <> 0