Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pause script with code
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
when you create a recovery scenario, one of the things it lets you define is the "Post-Recovery Test Run Options". The instructions on this page say, "select the test run operation you want to perform when the recovery operation is complete".

The choices are:
1) Repeat current step and continue
2) Proceed to next step
3) proceed to next action or component iteration
4) proceed to next test iteration
5) restart current test
6) stop the test run

I'm thinking you could select option #1 here - repeat the current test step.

In your recovery function, just before exiting the function, you could do this (this is taken from the QTP help on "Recovery Object", "Define a recovery Scenario" and modified a little bit):


'************************************************************************************************************************
'Description:
'
'This example uses the Recovery collection to specify a set of
'recovery scenarios to associate with a new test.
'
'Assumptions:
'There is no unsaved test currently open in QuickTest.
'For more information, see the example for the Test.SaveAs method.
'************************************************************************************************************************

Code:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTestRecovery 'As QuickTest.Recovery ' Declare a Recovery object variable
Dim intIndex ' Declare an index variable

' Open QuickTest and prepare objects variables
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

Set qtTestRecovery = qtApp.Test.Settings.Recovery ' Return the Recovery object for the current test

' Disable all scenarios
For intIndex = 1 To qtTestRecovery.Count ' Iterate the scenarios
    qtTestRecovery.Item(intIndex).Disabled = True ' Disable each Recovery Scenario (Note: the 'Item' property is default and can be omitted)
Next

' Enable the recovery mechanism (with default, on errors, setting)
qtTestRecovery.Enabled = True

'Ensure that the recovery mechanism is set to be activated only after errors
qtTestRecovery.SetActivationMode "OnError"
'OnError is the default, the other option is "OnEveryStep".

Set qtApp = Nothing ' Release the Application object
Set qtTestRecovery = Nothing ' Release the Recovery


How this would work: you've defined your recovery scenario for the test already. Modify your existing recovery scenario definition and set "Post-Recovery Test Run Options" to "Repeat current step and continue". In the Run Settings for your test (from QTP select File->Settings and select "Run" from the "Test Settings" window. In the run Properties window, set "When error occurs during run session" to "pop up message box".

When the error occurs in your test, it calls your recovery function. The recover function does whatever you told it to do (sends an email, I guess), then (in this example) disables all recovery scenarios for this test only. When the recover function exits, it does the post-recover test run options and re-runs the step that failed. Your recovery function is disabled now, so when the QTP re-runs the current step it will throw an error but not call the recovery function. This error will cause it to display the usual error pop-up message box that lets you stop, retry, debug, or continue.

I haven't actually tried all this, but it seems like this should/might work. Let me know how it goes.
Reply


Messages In This Thread
Pause script with code - by JRDew - 03-04-2011, 12:27 AM
RE: Pause script with code - by oleg8888 - 03-04-2011, 04:06 AM
RE: Pause script with code - by JRDew - 03-04-2011, 06:20 PM
RE: Pause script with code - by tdevick - 03-07-2011, 10:16 PM
RE: Pause script with code - by JRDew - 03-08-2011, 02:03 AM
RE: Pause script with code - by tdevick - 03-08-2011, 09:46 PM
RE: Pause script with code - by aardvax - 03-08-2011, 07:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VB script Code. Tejas Tikhe 2 3,651 06-19-2012, 10:54 AM
Last Post: Tejas Tikhe
Rolleyes How to pause QTP script using DotNet Factory nistalaramesh 3 5,169 06-23-2011, 02:59 PM
Last Post: Saket
  Pause from QTP. logeshkumarvb 2 4,423 01-11-2011, 07:20 PM
Last Post: UFTEnthusiast
  need script to pause the test kumsweta 1 3,432 12-02-2008, 09:26 PM
Last Post: roxer

Forum Jump:


Users browsing this thread: 3 Guest(s)