Qtp 简明教程

QTP - Recovery Scenarios

Recovery Scenarios

在执行 QTP 脚本时,我们可能会遇到一些意外错误。为了恢复测试并继续执行其余脚本,我们可使用以下意外错误进行恢复方案。可以通过导航到“资源”→恢复方案管理器进行访问恢复方案管理器,如下所示 −

While executing the QTP scripts, we might get some unexpected errors. In order to recover the tests and continue executing the rest of the script from these unexpected errors, Recovery Scenarios are used. The Recovery Scenario Manager can be accessed by Navigating to "Resources" → Recovery Scenario Manager as shown below −

qtp recovery scenario 1

Steps to Create Recovery Scenario

Step 1 − 单击“新建”恢复方案按钮;恢复方案向导将按如下所示打开 −

Step 1 − Click "New" Recovery Scenario button; the Recovery Scenario Wizard opens as shown below −

qtp recovery scenario 2

Step 2 − 选择触发器事件。它对应于可能在以下四种事件中发生的事件 −

Step 2 − Choose the Trigger Event. It corresponds to event, which can arise in any of the following four events −

  1. Pop-Up Window

  2. Object State

  3. Test Run Error

  4. Application Crash

Step 3 − 恢复操作窗口打开。恢复操作可以执行以下任何操作,如下面的屏幕截图所示 −

Step 3 − The Recovery Operations Window opens. Recovery Operation can perform any of the following Operation as shown in the screenshot below −

qtp recovery scenario 4

Step 4 − 指定适当的恢复操作后,我们还需要指定后恢复操作,如下所示 −

Step 4 − After specifying the appropriate Recovery Operation, we need to specify the Post Recovery Operation as well, as shown below −

qtp recovery scenario 5

Step 5 − 指定后恢复操作后,应命名恢复方案并将其添加到测试中,以便激活它。

Step 5 − After specifying the Post Recovery Operation, the recovery scenario should be named and added to the Test so that it can be activated.

qtp recovery scenario 6

Step 6 − 恢复方案的创建已完成,需要通过选中“将方案添加到当前测试”选项并单击“完成”将其映射到当前测试。

Step 6 − The Recovery Scenario creation is complete and needs to be mapped to the current Test by checking the option "Add Scenario to the current Test" and click "Finish".

qtp recovery scenario 7

Step 7 − 添加的恢复方案将如下所示,单击“关闭”按钮以继续。

Step 7 − The Added Recovery Scenario will be as shown below and click the "Close" Button to continue.

qtp recovery scenario 8

Step 8 − 单击关闭按钮后,QTP 会提示用户保存创建的恢复方案。它将使用扩展名 .qrs 保存,向导将关闭。

Step 8 − After clicking the Close button, QTP would prompt the user to save the created Recovery scenario. It will be saved with the extension .qrs and the wizard would close.

qtp recovery scenario 9

Verification

创建的恢复方案现在应当成为测试的一部分,可以通过导航到“文件”→“设置”→“恢复”选项卡来验证此方案。

The Created Recovery Scenario should be a part of the test now and can be verified by navigating to "File" → "Settings" → "Recovery" Tab.

qtp recovery scenario 9