Forum Discussion

googleid_118035's avatar
googleid_118035
Contributor
13 years ago

How to capture an error by VB scripts when dropdown item not found

Hi All,



I want to capture and error do some task for test scenario.



Following is the sample code which I used and written in VB scipts.

It always return no errors exsist, even dropdown doesn't contain "Testedvalue".

-----------

Sub Test()

Err.Clear

On Error Resume Next



Sys.Browser("iexplore").Page("http://test")...ClickItem("Testedvalue")



If Err.Number <> 0 Then

Call Log.Message("Errors exsist" , "")

Else

Call Log.Message("No Errors exsist" , "")

End If



End Sub
  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 3 rankChampion Level 3
    Hi,



    Non-zero value of Err.Number indicates VBScript runtime error. Since there is no VBScript engine runtime error, this is the reason of why Err.Number equals zero all the time.

    Instead, there is a test logical error when some requested item is not found. To handle this situation you can use the OnLogError event handler (see the relevant TestComplete help topic for more details).

    Also, you can check if the needed item exists before trying to click it. Exact way of how to check item's existance depends on what type of combo-box the test works with.
  • Jeniferanto's avatar
    Jeniferanto
    Occasional Contributor
    Hi  Alexei Karas [TeamAQA,



     Can you please provide more details. I am looking fo rthis long time in teh help topic too.

    I am  not able to capture the err.description and err.number/ But I am seeing the error in logs.



    Thanks

    Jenifer.


  • Hi Jenifer,


     


    As Alexei said,  Err.Number and Err.Description indicate VBScript run-time errors. Are you sure that errors you see in the test log are generated by the VBScript engine? What is the error text?