恢复场景或在函数本身中处理大部分场景
在执行过程中我可以预期的场景很少,我想了解处理此类运行时错误的最佳实践。
还有一个问题,是否值得在函数加载期间加载所有恢复场景,或者在函数本身中处理异常。
请建议最佳实践以及为什么您建议我们需要这样做。
There are few scenarios which i can expect during my execution, I would like to understand the best practices of handles such run time errors.
One more question, is it worth to load all the recovery scenarios during the load of the functions or handle the exception with in the functions itself.
Kindly suggest the best practices and why you suggest we need to go for that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于QTP中建立的命名,初学者经常混淆异常和GUI事件。
确实,弹出窗口并不是一个“例外”,即使它“崩溃”了脚本执行。
为了捕获失败的操作并从中恢复,我建议使用“On Error Resume Next...On Error GoTo 0”语句。
为了捕获可能发生也可能不发生的 GUI 事件,您可以使用 QTP 恢复场景,但是,正如 Tom E 提到的,每个激活的恢复处理程序都会使用额外的资源并影响 QTP 性能。
最好的方法是只使用您需要的那些,并保持其余的停用。
举几个例子。
1.捕获异常
这样,如果您有RegEx语法错误,执行将不会停止。
2.动态操作恢复处理程序
谢谢,
阿尔伯特·加里耶夫
http://automation-beyond.com/
Due to naming established in QTP, beginners often confuse exceptions and GUI events.
Truly, pop-up window is not an "exception" even if it "crashes" script execution.
For catching and recovery from failed operations, I recommend using "On Error Resume Next...On Error GoTo 0" statements.
For catching GUI events, that may or may not happen, you can use QTP Recovery Scenarios, BUT, as Tom E mentioned, each activated recovery handler uses extra resources and affects QTP performance.
Best way to use only those of them you would need, and keep the rest deactivated.
A few examples.
1.Catching exceptions
This way, if you have RegEx syntax errors, execution won't stop.
2.Dynamically operating Recovery handlers
Thank you,
Albert Gareev
http://automation-beyond.com/
根据我使用 QTP 的经验,最好直接在函数中处理已知的异常场景,并将异常处理机制留给未知或意外的异常。恢复场景会使用额外的计算机资源,并且可能会减慢测试速度,因此仅以有限的方式使用它们来捕获真正异常的场景。
In my experience with QTP, it's best to handle known exception scenarios directly in your functions, and leave the exception handling mechanism for unknown or unexpected exceptions. Recovery scenarios use additional machine resources and can slow down your tests, so only use them in a limited fashion for catching truly exceptional scenarios.