QTP Recovery Objects - Associated Methods

Recovery scenarios handling in QTP and the associated methods in the Automation testing.

Description

Enables you to control the recovery scenario mechanism programmatically during the run session. The recovery scenario mechanism enables you to instruct QuickTest to recover from unexpected events and errors that occur in your testing environment during a run session.

For more information on the recovery scenario mechanism, see the HP QuickTest Professional User Guide.

Associated Methods

  • Activate Method

  • GetScenarioName Method

  • GetScenarioPosition Method

  • GetScenarioStatus Method

  • SetScenarioStatus Method

Associated Properties

  • Count Property

  • Enabled Property
Activate 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.

Syntax

Recovery.Activate

Example

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

Recovery.Activate

Recovery.SetScenarioStatus 2, False

Recovery.Activate

Recovery = False

Recovery.Activate 

GetScenarioName  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.

Example

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  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

Example

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 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

Example

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 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).

Example

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

0 comments:

Post a Comment