参考来源:http://www.qtpschool.com/2012/03/recovery-scenarios-in-qtp.html
Recovery Scenarios in QTP
-
What is Recovery Scenario?
Recovery Scenarios are used to recover the test from unexpected errors and continue with execution.
[pope译]
Recovery Scenario 是什么?
Recovery Scenario 被用来从异常错误中恢复测试 ,并执行。
What is unexpected errors?
Unexpected error or exception is a unpredictable/unexpected error which occurs suddenly during execution of the script. These kind of errors makes your script fail/stop/paused.
[pope译]
异常错误是什么?
异常错误是 在执行脚本时,不可预测的/意外的 情况突然发生。这种类型的错误导致脚本fail/stop/paused。
[?] 在脚本执行时stop与paused的区别不知会是什么?
Atonomy of Recovery Scenarios?
A recovery scenario consists of the following three patrs:
1. Trigger Event
2. Recovery Operations
3. Post-Recovery Test Run Option
[pope译]
自动的Recovery Scenarios?
Recovery Scenarios 包含如下三个部分:
1.触发事件(Trigger Event)
2.恢复操作(Recovery Operations)
3.恢复测试后运行的选项(Post-Recovery Test Run Option)
-
Trigger Event:
The event that interrupts your run session. For example a window that may pop up on screen.
[pope译]
触发事件:
此事件打断你运行的session。例如window的 弹出窗
Recovery Operations:
The operations to perform to enable QTP to continue running the test after the trigger event interrupts the run session. For example, clicking an OK button in a pop-up window.
[pope译]
恢复操作:
此操作在触发事件终止运行session后执行,能够使QTP继续运行此测试的操作。例如:在弹出window框中点击ok按钮。
Post-Recovery Test Run Option:
The instructions on how QTP should proceed after the recovery operations have been performed, and from which point in the test QTP should continue. For example, you may want to restart a test from the beginning, or skip a step entirely and continue with the next step in the test. Recovery scenarios are saved in recovery scenario files having the extension .qrs. A recovery scenario file is a logical collection of recovery scenarios, grouped according to our specific requirements.
[pope译]
恢复运行后的选项:
此指令定义 在恢复操作之后如何运行QTP,从testQTP脚本的什么位置开始继续。例如:你打算从开始位置重新运行,或者在测试中忽略此步骤并继续下一步。恢复操作 保存恢复场景的文件在 extension.qrs中。一个恢复场景文件按照我们具体设定的要求,收集恢复场景上的内容。
Recovery scenario manger can handle following four events:
1. Pop-up window: To handle unwanted pop ups.
2. Object state: To handle object related errors at runtime.
3. Test run error: To handle vb script statement errors at runtime.
4. Application crash: To handle crashed applications at runtime.
[pope译]
恢复场景需要处理以下四点:
1.window弹出框:处理不需要的弹出框
2.对象状态:处理对象中,因此而相关联的错误
3.测试运行错误:处理vb script 脚本在运行时的错误
4.应用程序崩溃:处理应用程序的崩溃情况
-
1. Recovery Scenario for Pop-up Window:
Steps to follow to handle unwanted pop-ups:
Trigger Event Steps:
Resources Menu -->Recovery Scenario Manager -->New -->Next -->Select “Popup Window” as Trigger event -->Next -->Click on Hand Icon -->Show unwanted window with Hand icon -->Next -->Next -->(Continue below mentioned steps)
Recovery Operations steps:
Select function call as Recovery Operation --> Next {Open Notepad --> Save empty file with .vbs extension} --> Browse the .vbs fie path --> Next --> Uncheck Add another Recovery Operation --> Next -->(Continue below mentioned steps)
Post-Recovery Test Run Option Steps:
Select Post-Recovery Test Run Option {Repeat current step and continue, Proceed to Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run, Stop the Test Run} -->Next -->Enter Scenario Name -->Next -->Select Option --> Finish -->Save the scenario with “.qrs” -->Record required Recovery Operation {Click ok, Click Cancel} take the script into function -->Save the library file -->Click Run
[pope译]
1.Window弹出框的恢复场景:
如下步骤允许不需要的弹出框:
触发事件的步骤:
Resources Menu -->Recovery Scenario Manager -->New -->Next -->Select “Popup Window” as Trigger event -->Next -->Click on Hand Icon -->Show unwanted window with Hand icon -->Next -->Next -->(继续下面提到的步骤)
恢复操作的步骤:
选择function 调用作为Recovery Operation --> Next {Open Notepad --> Save empty file with .vbs extension} --> Browse the .vbs fie path --> Next --> Uncheck Add another Recovery Operation --> Next -->(继续下面提到的步骤)
恢复测试后的运行参数步骤:
选择Post-Recovery Test Run参数{Repeat current step and continue, Proceed to Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run, Stop the Test Run} -->Next -->Enter Scenario Name -->Next -->Select Option --> Finish -->Save the scenario with “.qrs” -->Record required Recovery Operation {Click ok, Click Cancel} take the script into function -->Save the library file -->Click Run
2. Recovery Scenario for Object State:
Steps to follow to check Property values of an object in the application match specified values. User can specify property values for each object in the hierarchy.
Trigger Event steps:
Resources Menu --> Recovery Scenario Manager --> New --> Next --> Select “Object state Window” as Trigger event --> Next --> Click on Hand Icon --> Show object with and icon --> Next --> Next-->select object property with value (enabled ,false)-->click next --> (Continue below mentioned steps)
Recovery Operations steps:
Select function call as Recovery Operation --> Next {Open Notepad --> Save empty file with .vbs extension} --> Browse the .vbs fie path --> Next --> Uncheck Add another Recovery Operation --> Next -->(Continue below mentioned steps)
Post-Recovery Test Run Option Steps:
Select Post-Recovery Test Run Option {Repeat current step and continue, Proceed to Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run, Stop the Test Run} --> Next--> Enter Scenario Name --> Next --> Select Option -->Finish --> Save the scenario with “.qrs” --> Record required Recovery Operation {Click ok, Click Cancel} take the script into function --> Save the library file --> Click Run
[pope译]
2.对象状态的场景恢复
步骤要求选择 应用中匹配的特殊的属性值。用户可以对不同级别的每个对象具体设置特殊的值。
触发事件的步骤:
Resources Menu --> Recovery Scenario Manager --> New --> Next --> Select “Object state Window” as Trigger event --> Next --> Click on Hand Icon --> Show object with and icon --> Next --> Next-->select object property with value (enabled ,false)-->click next --> (继续下面的步骤)
场景恢复步骤:
选择function 作为Recovery Operation --> Next {Open Notepad --> Save empty file with .vbs extension} --> Browse the .vbs fie path --> Next --> Uncheck Add another Recovery Operation --> Next -->(继续下面的步骤)
恢复测试运行后的参数的步骤:
选择Post-Recovery Test Run参数{Repeat current step and continue, Proceed to Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run, Stop the Test Run} --> Next--> Enter Scenario Name --> Next --> Select Option -->Finish --> Save the scenario with “.qrs” --> Record required Recovery Operation {Click ok, Click Cancel} take the script into function --> Save the library file --> Click Run
3. Recovery Scenario for Test Run Error:
Steps to follow to check if test does not run successfully then Test Run Error can be raised.
Trigger Event steps:
Resources Menu -->Recovery Scenario Manager -->New -->Next -->Select “Testrunerror Window” as Trigger event -->Next -->select any error o -->Next -->Next -->(Continue below mentioned steps)
Recovery Operations steps:
Select function call as Recovery Operation -->Next {Open Notepad -->Save empty file with .vbs extension} -->Browse the .vbs fie path -->Next -->Uncheck Add another Recovery Operation -->Next -->(Continue below mentioned steps)
Post-Recovery Test Run Option Steps:
Select Post-Recovery Test Run Option {Repeat current step and continue, Proceed to Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run, Stop the Test Run} -->Next >Enter Scenario Name >Next -->Select Option --> Finish >Save the scenario with “.qrs” -->Record required Recovery Operation {Click ok, Click Cancel} take the script into function -->Save the library file -->Click Run
[pope译]
3.测试运行错误时的场景恢复:
步骤运行如下操作:如果不能成功运行测试,Error可以被增加运行。
触发事件的步骤:
Resources Menu -->Recovery Scenario Manager -->New -->Next -->Select “Testrunerror Window” as Trigger event -->Next -->select any error o -->Next -->Next -->(继续下面步骤)
恢复场景步骤:
选择function作为Recovery Operation -->Next {Open Notepad -->Save empty file with .vbs extension} -->Browse the .vbs fie path -->Next -->Uncheck Add another Recovery Operation -->Next -->(继续下面步骤)
恢复测试运行后的参数步骤:
选择Post-Recovery Test Run 参数{Repeat current step and continue, Proceed to Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run, Stop the Test Run} -->Next >Enter Scenario Name >Next -->Select Option --> Finish >Save the scenario with “.qrs” -->Record required Recovery Operation {Click ok, Click Cancel} take the script into function -->Save the library file -->Click Run
4. Recovery Scenario for Application Crash:
Steps to follow to check application failure during Test Run.
Trigger Event steps:
Resources Menu --> Recovery Scenario Manager--> Click New--> Click Next -->Select Application Crash as Trigger event-->Next -->Select selected executable application-->Next --> (Continue below mentioned steps)
Recovery Operations and Post-Recovery Test Run Option Steps:
Select Recovery Operation {Keyboard, Mouse Operation,Close Application Process, function Call, Restart, Microsoft Windows} -->Next -->If you want to check Add another operation else uncheck-->Next -->Next -->Enter Scenario Name -->Next-->Select Option -->Finish -->Close -->Save the scenario with “.qrs”
[pope译]
4.应用程序崩溃的场景恢复:
此步骤允许应用程序测试运行失败。
触发事件步骤:
Resources Menu --> Recovery Scenario Manager--> Click New--> Click Next -->Select Application Crash as Trigger event-->Next -->Select selected executable application-->Next --> (继续下面的步骤)
恢复场景和恢复运行时的参数步骤:
选择Recovery Operation {Keyboard, Mouse Operation,Close Application Process, function Call, Restart, Microsoft Windows} -->Next -->If you want to check Add another operation else uncheck-->Next -->Next -->Enter Scenario Name -->Next-->Select Option -->Finish -->Close -->Save the scenario with “.qrs”
-
If you can predict that a certain event may happen at a specific point in your test or component, it is recommended to handle that event directly within your test or component by adding steps such as If statements or optional steps or "on error resume next", rather than depending on a recovery scenario. Using Recovery Scenarios may result in unusually slow performance of your tests.They are designed to handle a more generic set of unpredictable events which CANNOT be handled pragmatically.
[pope译]
错误处理(在error时继续下一步) 还是 场景恢复?
如果你可以预测{predict}特定的事件在你的测试过程或某个组成部分的特殊点可能发生,推荐直接增加步骤,来控制你的测试过程或组成部分中出现的事件,例如声明或者选择步骤 或者 “错误时继续下一步”,而不是依赖场景恢复。使用场景恢复在你测试中,可能结果导致非常慢的性能问题。他们设计用来控制更多的一般性不可预见的事件中使用。
Example:
On error Statements
Following are error statements :
1. On Error Resume Next
2. On Error Go to 0
3. err.number
4. err.description
On Error Resume Next:
On Error Resume Next statement enables the Error handling in the code.If there is error in the code "On error Resume Next" ignores it and continue with next line of code.
On Error Go to 0:
On error got to 0 statement disables error handling we have previously enabled it by using On Error resume Next.
err.number and err.description:
Provides the error number and the description of the error
[pope译]
例如:
在error声明中,做如下error 声明:
1.错误时继续下一句
2.错误时转到0
3.err号
4.err描述
错误时继续下一步:
错误时继续下一步声明 能够在代码中使用错误控制。如果有一个错误处理代码是“错误时继续下一步”, 那么就是忽略它并继续下一行代码。
错误时转到0:
错误时转到0声明 ,失去了对错误的控制 我们之前使用“错误时继续下一步”继续使用它。
err号和err描述
提供错误号和错误描述信息
-
1. Recovery Scenario for Pop-up Window:
-
Trigger Event:
没有评论:
发表评论