Recovery Object
Description
Enables you to control the recovery scenario mechanism programmatically during the run session. The recovery scenario mechanism enables you to instruct UFT One to recover from unexpected events and errors that occur in your testing environment during a run session.
For more details on the recovery scenario mechanism, see the Micro Focus UFT One User Guide.
Methods and Properties
Activate | Explicitly activates the recovery scenario mechanism at a specific point in the run. |
Count | Returns the number of recovery scenarios associated with the current test. |
Enabled | Retrieves or sets the status of the recovery scenario mechanism for the current test. |
GetScenarioName | Retrieves the name and source file of a recovery scenario, according to the specified position in the list of recovery scenarios associated with the test. |
GetScenarioPosition | Returns the index position of a recovery scenario in the list of recovery scenarios associated with the test, according to the specified name and source file. |
GetScenarioStatus | Returns the status of a recovery scenario (True = enabled or False = disabled), according to the specified index position in the list of recovery scenarios associated with the test. |
SetScenarioStatus | Enables or disables the specified recovery scenario, according to its index position in the list of recovery scenarios associated with the test. |
Activate Method
Description
Explicitly activates the recovery scenario mechanism at a specific point in the run.
Note:
The Activate method only works if the recovery mechanism is enabled, and only activates those recovery scenarios that are currently enabled.
If the recovery mechanism is currently disabled, the Activate method does not activate any recovery scenarios. You can use the Recovery object's Enabled property to change the status of the recovery mechanism.
The Activate method works only when the scenario's trigger event is Application Crash and the Recovery Operation is either Keyboard or Mouse operation or Close application process.
Syntax
Recovery.Activate
The following example uses the Activate method to explicitly activate recovery scenarios three times—the first time it explicitly activates the three scenarios associated with the current test; the second time it activates only the first and third scenario, since the second scenario is disabled; the third time it does not activate any scenarios, since the entire recovery mechanism is disabled.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery,, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition(ScenarioFile, ScenarioName)
msgbox Recovery.GetScenarioStatus(Position),, "Is scenario " & ScenarioName & " from " & ScenarioFile & " enabled ?"
ScenarioFile = Empty
ScenarioName = Empty
Next
'An application crash should be present
Recovery.Activate
Recovery.SetScenarioStatus 2, False
Recovery.Activate
Recovery = False
Recovery.Activate
Count Property
Description
Returns the number of recovery scenarios associated with the current test.
Syntax
Recovery.Count
Return Value
Number
The following example uses the Count property to return the number of recovery scenarios associated with the current test and then uses this information to perform various operations on the scenarios.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery,, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition( ScenarioFile, ScenarioName )
msgbox Recovery.GetScenarioStatus( Position ),, "Is scenario " & ScenarioName & " from " & ScenarioFile & " enabled ?"
ScenarioFile = Empty
ScenarioName = Empty
Next
Enabled Property
Description
Recovery default property. Retrieves or sets the status of the recovery scenario mechanism for the current test.
Syntax
To retrieve the recovery scenario mechanism status:
Recovery.Enabled
or
Recovery
To set the recovery scenario mechanism status:
Recovery.Enabled=Status
or
Recovery=Status
Argument | Type | Description |
---|---|---|
Status | Boolean | The status of the specified scenario (True = enabled or False = disabled). |
The following example uses the Enabled property to check the status of the recovery mechanism, and enables it if it is disabled. It then activates any recovery scenarios associated with the test, and then returns the recovery mechanism to its former status.
MyCurrentStatus=Recovery.Enabled
If Not( MyCurrentStatus ) Then
Recovery.Enabled=True
End If
Recovery.Activate
Recovery = MyCurrentStatus
Note: You could omit the word Enabled
in the statement above, because Enabled is the default property for the Recovery object.
GetScenarioName Method
Description
Retrieves the name and source file of a recovery scenario, according to the specified position in the list of recovery scenarios associated with the test.
Syntax
Recovery.GetScenarioName Position, out_ScenarioFile, out_ScenarioName
Argument | Type | Description |
---|---|---|
Position | Number | The index position of the recovery scenario in the list. Index position values begin with 1. |
out_ScenarioFile | String | Variable that stores the retrieved name of the recovery scenario. |
out_ScenarioName | String | Variable that stores the retrieved source file path of the recovery scenario. |
The following example uses the GetScenarioName method to retrieve the name of each of the recovery scenarios associated with the current test, and then displays the name in a message box.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery,, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition(ScenarioFile, ScenarioName)
msgbox Recovery.GetScenarioStatus(Position),, "Is scenario " & ScenarioName & " from " & ScenarioFile & " enabled ?"
Next
GetScenarioPosition Method
Description
Returns the index position of a recovery scenario in the list of recovery scenarios associated with the test, according to the specified name and source file.
Syntax
Recovery.GetScenarioPosition (ScenarioFile, ScenarioName)
Argument | Type | Description |
---|---|---|
ScenarioFile | String | The source file path of the recovery scenario. |
ScenarioName | String | The name of the recovery scenario. |
Return Value
Number
The following example uses the GetScenarioPosition method to retrieve the index position of each of the recovery scenarios associated with the current test, and then displays the index position in a message box.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery,, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition( ScenarioFile, ScenarioName )
msgbox Recovery.GetScenarioStatus( Position ),, "Is scenario " & ScenarioName & " from " & ScenarioFile & " enabled ?"
Next
GetScenarioStatus Method
Description
Returns the status of a recovery scenario (True = enabled or False = disabled), according to the specified index position in the list of recovery scenarios associated with the test.
Syntax
Recovery.GetScenarioStatus Position
Argument | Type | Description |
---|---|---|
Position | Number | The index position of the recovery scenario in the list. Index position values begin with 1. |
Return Value
Boolean
The following example uses the GetScenarioStatus method to retrieve the status (True = enabled or False = disabled) of each of the recovery scenarios associated with the current test, and then displays the status in a message box.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery,, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition( ScenarioFile, ScenarioName )
msgbox Recovery.GetScenarioStatus( Position ),, "Is scenario " & ScenarioName & " from " & ScenarioFile & " enabled ?"
ScenarioFile = Empty
ScenarioName = Empty
Next
SetScenarioStatus Method
Description
Enables or disables the specified recovery scenario, according to its index position in the list of recovery scenarios associated with the test.
Syntax
Recovery.SetScenarioStatus Position, Status
Argument | Type | Description |
---|---|---|
Position | Number | The index position of the recovery scenario in the list. Index position values begin with 1. |
Status | Boolean | The status to set for the specified scenario (True = enabled or False = disabled). |
The following example uses the SetScenarioStatus method to disable the status of the second scenario associated with the test.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery,, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition( ScenarioFile, ScenarioName )
msgbox Recovery.GetScenarioStatus( Position ),, "Is scenario " & ScenarioName & " from " & ScenarioFile & " enabled ?"
ScenarioFile = Empty
ScenarioName = Empty
Next
Recovery.Activate
Recovery.SetScenarioStatus 2, False
Recovery.Activate
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object