Class QCImageErrorCapture
Sub Class_Terminate()
'Check if the current test has failed. If failed then only capture screenshot
If Reporter.RunStatus = micFail Then
CaptureAndAttachDesktop
End If
End Sub
 
Private Sub CaptureAndAttachDesktop()
'QC is not connected
If QCUtil.IsConnected = False then Exit Sub
 
'The test is not running from Test Lab
If QcUtil.CurrentRun is Nothing Then Exit Sub
 
On error resume next
'Hide QTP to make sure we don't get QTP in snapshot
Set qtpApp = CreateObject("QuickTest.Application")
 
qtpApp.visible = False
'GIve time for QTP to get hidden
Wait 2
 
'Capture the screenshot to the report folder
Desktop.CaptureBitmap Reporter.ReportPath & "/Report/ErrorImage.png", True
qtpApp.visible = True
 
'Add the capture to QC
Set oAttachments = QCutil.CurrentRun.Attachments
Set oAttachment = oAttachments.AddItem(null)
oAttachment.FileName = Reporter.ReportPath & "/Report/ErrorImage.png"
oAttachment.Type = 1 'File
 
'Check if the current test is a QTP Test or Business Component
Select Case LCase(qtpApp.CurrentDocumentType)
Case "test"
oAttachment.Description = "Name: " & qtpApp.Test.Name & vbNewLine & "Error: " & qtpApp.Test.LastRunResults.LastError
Case "business component"
oAttachment.Description = "Name: " & qtpApp.BusinessComponent.Name & vbNewLine & "Error: " & qtpApp.BusinessComponent.LastRunResults.LastError
 
'We can also add the Business COmponent to a User Defined Field
'QCUtil.CurrentTestSetTest.Field("TC_USER_01") = qtpApp.BusinessComponent.Name
'QCUtil.CurrentTestSetTest.Post
End Select
 
'Add the attachment
oAttachment.Post
End Sub
End Class
 
'Create the object in one of the attached libraries. When the Test or Business component ends
'the screenshot will be captured
Set oErrorCapture = new QCImageErrorCapture
将上述代码直接复制到函数库中并关联当前QTP脚本,那么在运行过程中发生的错误截图就会自动上传至QC。

将QTP运行时的错误截图上传到QC的更多相关文章

  1. Erlang运行时的错误

    Erlang运行时发生错误时,会返回一些错误信息,理解这些信息,对于学好.用好Erlang来说是必要. Erlang中的运行错误包括:badarg, badarith, badmatch, funct ...

  2. docker 运行时常见错误

    docker 运行时常见错误 (1) Cannot connect to the Docker daemon at unix:///var/run/docker.sock. [root@localho ...

  3. ASP.NET MVC 网站开发总结(三) ——图片截图上传

    本着简洁直接,我们就直奔主题吧,这里需要使用到一个网页在线截图插件imgareaselect(请自行下载). 前台页面: <!DOCTYPE html> <html> < ...

  4. 在Asp.Net Core中配置使用MarkDown富文本编辑器实现图片上传和截图上传(开源代码.net core3.0)

    我们的富文本编辑器不能没有图片上传尤其是截图上传,下面我来教大家怎么实现MarkDown富文本编辑器截图上传和图片上传. 1.配置编辑器到html页 <div id="test-edi ...

  5. JS打开摄像头并截图上传

    直入正题,JS打开摄像头并截图上传至后端的一个完整步骤 1. 打开摄像头主要用到getUserMedia方法,然后将获取到的媒体流置入video标签 2. 截取图片主要用到canvas绘图,使用dra ...

  6. 头像截图上传三种方式之一(一个简单易用的flash插件)(asp.net版本)

    flash中有版权声明,不适合商业开发.这是官网地址:http://www.hdfu.net/ 本文参考了http://blog.csdn.net/yafei450225664/article/det ...

  7. linux 运行时加载不上动态库 解决方法(转)

    1. 连接和运行时库文件搜索路径到设置     库文件在连接(静态库和共享库)和运行(仅限于使用共享库的程序)时被使用,其搜索路径是在系统中进行设置的.一般 Linux 系统把 /lib 和 /usr ...

  8. 关于bootstrap中cropper的截图上传问题

    之前做一个关于截图的东东,搞了好久终于弄好了,其主要关键是把前端截图的数据(x坐标,y坐标,宽度,高度和旋转角度)传到后台,然后在后台对图片做相关处理,记录一下方便以后查看. 后台配置为ssm. Ja ...

  9. iOS之苹果调整 App Store 截图上传规则,截图尺寸、大小等

    作者:ASO100链接:https://zhuanlan.zhihu.com/p/23041522来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 自从 8 月中旬苹果向 ...

随机推荐

  1. Day3---Python的time库的一些简单函数以及用法

    time库的一些函数 time.time () :   获取当前时间戳,即计算机内部时间值,浮点数 >>>import time >>> time.time() 1 ...

  2. Codeforces Round #529 (Div. 3) E. Almost Regular Bracket Sequence (思维)

    Codeforces Round #529 (Div. 3) 题目传送门 题意: 给你由左右括号组成的字符串,问你有多少处括号翻转过来是合法的序列 思路: 这么考虑: 如果是左括号 1)整个序列左括号 ...

  3. elasticsearch 深入 —— Search Type检索类型

    在此我们再给出那个查询的代码: $ curl -XGET localhost:9200/startswith/test/_search?pretty -d '{ "query": ...

  4. 解决Layui数据表格中checkbox位置不居中

    1.情景 使用方法渲染的方式生成数据表格,添加了checkbox,但发现checkbox位置不居中,如下图所示  2.解决办法 通过layui官方社区,找到如下代码,只需要添加如下样式即可解决 < ...

  5. 一、免费API调用

    一.免费API调用: 免费天气api接口 JS调用示例 <!DOCTYPE html> <html lang="zh-CN"> <head> & ...

  6. k8s阅读笔记1-云原生

    前言 阅读书籍地址https://rootsongjc.gitbooks.io/kubernetes-handbook/content/cloud-native/cloud-native-defini ...

  7. HTML5:Canvas-基本用法

    <canvas id="tutorial" width="150" height="150"></canvas> & ...

  8. Linux的运行级别和设置开机启动服务的方式

    Linux的运行级别 什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别.级别是从0到6,具有不同的功能.这些级别定义在/ect/inittab文件中.这个文件是init程序寻找 ...

  9. ivew-admin 校验 自定义验证表单多层嵌套

    1.prop=对象 <FormItem label=" prop="shapeDifference.heightSpaceT2"> <Input v-m ...

  10. vue之templete模板

    1.templete里要用data里的数据的话,不要加this. 2.按理说Js是写在<script></script>标签体内的.但是Vue的templete模板中对所有的数 ...