SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jun 2004
    Location
    colorado springs
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Quit Test on Runtime Error, how to?

    I tried searching for this topic and could not really find what I am looking for. So, please point me to the correct topics if this has been brought before.

    What I want is to have the test stop and exit for any error that QTP detects (object not found, ect). We will have several scripts that will run at night. So, I want to be able to stop/exit a test if any error occurs, report whatever happened, and the go on to the next test script.

    My question is, how should I go about creating something that will stop/exit the test on any error? I thought, that I may put at the beginning of my script some IF or WHILE statemant that keeps the test running until it encounters an error. I tried looking at recovery scenarios, but not sure if that is going to accomplish what I want.

    I am fairly new to VBS, so any code examples you can provide would be helpful.

    Thanks!

  2. #2
    Member
    Join Date
    Jun 2004
    Location
    colorado springs
    Posts
    80
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Quit Test on Runtime Error, how to?

    Sorry, I meant to maybe try a DO WHILE/UNTIL statement instead of the WHILE listed above.

  3. #3
    Advanced Member
    Join Date
    Mar 2007
    Location
    Salt Lake City, UT, USA
    Posts
    606
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Quit Test on Runtime Error, how to?

    The problem with a loop like you suggest is that it will only be checked once, at the start or end of your script. If an error occurs in the middle, your loop won't know about it until the end of the loop, or the next iteration (depending on how you set up the loop).

    You're right about recovery scenarios. Those typically just click a button, or close the application entirely, or reboot your machine. It's hard to make a recovery scenario close the current test iteration or script but continue with the next iteration or script.

    One way to handle this that does exactly what you want takes a lot of coding, but works perfectly.

    Nest each operation inside an nested if..then structure:

    If window exists then
    _If object exists then
    _use that object
    __If next object exists then
    __do some stuff
    ___If next object exists then
    ____etc.
    ___Else
    ____Report the failure
    ____Exit Iteration
    ___End If
    __Else
    ___Report the failure
    ___Exit Iteration
    __End If
    _Else
    __Report the failure
    __Exit Iteration
    _End If
    Else
    _Report the failure
    _Exit Iteration
    End If

    It's long, and it's a lot of coding those if..then..else statemetns, but in the end, if anything goes wrong, it gets reported to the log and the iteration ends without going through a bunch more steps that all fail anyway.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

  4. #4
    Junior Member
    Join Date
    Jan 2007
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Quit Test on Runtime Error, how to?

    Glenn_martin,

    Instead of that you can have On Error Resume Next and handle that by using descriptive programming as u like

    Another option is use recovery manager and close popup and execute a Vbs file to write to log and do wat ever u want to do.

  5. #5
    Senior Member
    Join Date
    Feb 2003
    Posts
    533
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Quit Test on Runtime Error, how to?

    This is what I am also trying to figure. In my case if object is not found the script simply exits and do not loop to next test case in the spreadsheet. I have even set test setting as on error go to next iteration. In global sheet I have filled few rows with some random numbers. even then the script exits when object is not found. I want to run the script to run thru the sheet that has listed test cases.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:39 PM.

Copyright BetaSoft Inc.