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. dp(最长升序列)

    http://poj.org/problem?id=2533   题意:给你n(1-1000)个数,求这n个数的最长升序列.   题解:dp[i]表示以第i个数结尾的最长升序列. #include & ...

  2. Anaconda Jupyter WinError2:The system cannot find the file specified

    Traceback (most recent call last): File "C:\Users\builder\Miniconda3\Scripts\conda-build-script ...

  3. Python自学第二天学习之《字符串与数字》

    一.基本数据类型: 数字:int类型,不可变类型 格式 : a=10 1.其他类型转换成int型 : b=“123” c=int(b) #转换类型 print(c)----- 123 print(ty ...

  4. thinkphp开发微信小程序后台流程

    thinkphp开发微信小程序后台流程,简单分享一下微信开发流程 1,注册微信小程序账号 2,注册好后,登陆微信小程序,下载微信小程序开发工具 3,用thinkphp开发企业后台,前台数据用json返 ...

  5. Kaldi学习手记(一):Kaldi的编译安装

    下载 安装git sudo apt-get install git 下载Kaldi git clone https://github.com/kaldi-asr/kaldi.git kaldi-tru ...

  6. NotePad++安装 html.css.js智能提示【转】

    https://www.cnblogs.com/alirong/archive/2012/04/12/2443971.html

  7. Elastic Search快速入门

    https://blog.csdn.net/weixin_42633131/article/details/82902812 通过这个篇文章可以快速入门,快速搭建一个elastic search de ...

  8. Kettle5.4.0 java.lang.OutOfMemoryError

    CPU: Intel i3 3.40GHz Memory : 8G Kettle默认配置 将MySQL上的一张29W条数据的表,通过Kettle增量抽取到Vertica数据库中,结果在排序这一步报内存 ...

  9. pylab和pyplot的区别

    Pylab combines the functionality of pyplot with the capabilities of NumPy in a single namespace, and ...

  10. Spring Transaction Isolation

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11530702.html Reference http://docs.spring.io/spring/ ...