tags:

views:

174

answers:

2

Hi All,

I am Anil. Can you please clarify the folowing query? I am not sure if the way I am trying to code is correct. Kindly advise me if I am moving in the right/wrong direction.

I am trying to develop an automation framework using QuickTest Professional, a testing tool.

  • There is an Excel sheet from which the data is being taken for execution based on the ID's stored in an array from another Excel sheet (The same ID is available in both Excel sheets).
  • I'm trying to handle the exeptional cases through a function call. This function will capture the screenshot of the page error occured and then exit the entire loop.
  • I need a scenario where execution continues for the next ID stored in the array, and this needs to be handled from the function call.

Thank you,

Warm regards Anil

+1  A: 

Well, it sounds like you already have the answer.. You just need to handle the expection that occurs when reading in the data within the main loop and make it stop there..

Now, I have not done VBScript for a LONG time so, to pseudo it:

While Not EndOfExcelSheet
    ReadDataFromExcel();
    If errOccurred Then TakeScreenPrint();
    'NOTE: We have caught the error and requested the screen print
    'is taken, but we have NOT bubbled the exception up!
End While
Rob Cooper
Thank you Rob. I am just trying to incorporate both the suggestions.
No problem, if you get stuck/confused then please edit/update your question and drop me a comment and I will see if I can help :)
Rob Cooper
A: 

It's hard to answer your question based on what you wrote, but the first thing that comes to my mind is to add a boolean parameter to your exception-handling function (let's call it ExceptionHandler). Say, if the parameter (let's call it ExitLoop) is true, you wll exit from the "entire loop", otherwise, continue. Now, it might be too tedius to change that for old calls to the function (calls without the new parameter) -- I'm not sure if VB supports function overloading. If this is the case, you can rename your ExceptionHandler to ExceptionHandler2, add the new parameter (ExitLoop) and logic to it and create a (now new) function ExceptionHandler that calls ExceptionHandler2 with its parameters plus true for ExitLoop.

Hope it helps.

Attila
Hi Attila:Thank you. I have two loops with variables say (i and j), now I am at i=5 and j=16, an error occured. The function I have will take the screen shot and proceed to the next step or exit the loop, I am trying to get an option which exit the loop for j alone and continues with i=6.