Practice and summary of QTP scene recovery

http://blog.csdn.net/jasonteststudy/article/details/39298689

 

The advantages of automated testing are that it is fast, reliable, repeatable, reusable, and fatigue-free. It is a liberation from heavy manual testing and is suitable for regression testing. Another feature of automation is that it is unattended. What the tester has to do is to see

  REPORT

  ER to determine whether the system has defects. Of course, ERROR will appear more or less in the process of script execution. Due to the unattended feature, the next script will not be able to run, which is why the POP function is used in the pop-up box in the automation script. The scene recovery provided by QTP can solve this problem. I will share my learning and practice process with you. If there is any inappropriate place, please correct me.

   Scene recovery can be regarded as an embedded mechanism, which is an installable and detachable component of the QTP script. The function of this component is to execute the specified command according to our instructions when there is a problem with the machine, record the crime scene, When the script finishes running, submit a report for us to analyze. Let's see how to make this part, I share a scene recovery of a screenshot of calling a function when an error occurs. The version I am using is QTP10.00

  1. Setting

  1. Create a new Recovery Scenario

  First we open the Resouces--Recovery Scenario Manager window.

  Click the New Scenario Recovery icon to start a new Recovery Scenario.

  2. Select the trigger method

  The scene recovery mechanism provides four types of trigger events, which are used to identify: pop-up dialog boxes, special property values ​​of objects, running errors, and application failures. I choose the Test  run error triggering method here.

  Error Select Any error so that any error can trigger a recovery scenario.

  3. Set the operation during recovery, here we choose to call the function.

  Click Next and select the edited function. My recovery operation function is as follows. The function of the function is to print the screenshot of the error page to REPORTER.

Function RecoveryFunction1(Object, Method, Arguments, retVal)
Dim datestamp,filename,ResPath
ResPath = Environment("ResultDir")
datestamp = Now()
filename = Environment("TestName")&"_"&datestamp&".png"
filename = Replace(filename,"/","")
filename = Replace(filename,":","")
filename = ResPath + "\" + ""&filename
Desktop.CaptureBitmap filename,True
Reporter.ReportEvent micFail,"场景恢复","报错截屏",filename
End Function

  Click Next to cancel the add another recovery operations option.

  4. Set the script to resume the operation at runtime, where the next Action or the next iteration in the component is processed.

  到这里,这个调用函数的场景恢复设置就基本完成了,下一步是给场景恢复取名并保存。

  可以选择将新建的场景恢复添加到当前的TEST或者将其视为默认设置。

  5、关联场景恢复文件

  在file>setting>recovery选项中,可以选择添加或者删除场景设置,就跟resources中国添加关联函数是一个道理。

  在test setting里可以看到我们新建的场景设置已经与当前TEST关联。

  二、运行

  批量运行脚本实验场景恢复的作用。

  在前面的脚本执行出错时不影响下一个脚本的执行,也即是场景恢复起到了作用,如果没有这个设置,我们批量运行脚本时就会中断在出错的位置,没有起到自动化应有的作用。我们来看一下运行的报告。

  SKIP ITERATION,我们设置的恢复操作,执行下一个迭代。

  这个是出错的截屏,这里我将密码设置错误触发了场景恢复。

  谢谢大家,有不正确的请指正。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326408981&siteId=291194637