51Testing软件测试论坛

标题: 报告优化 [打印本页]

作者: dqf    时间: 2012-3-13 16:30
标题: 报告优化
  1. '检查点
  2. Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").Check CheckPoint("wd")
  3. Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").Check CheckPoint("百度一下")

  4. '手工代码
  5. Dim wd_value,wd_name,wd_type,wd_visible
  6. Dim bt_name,bt_type,bt_visible
  7. wd_value=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("value")
  8. wd_name=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("name")
  9. wd_type=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("type")
  10. wd_visible=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("visible")
  11. If wd_value="" Then
  12. Reporter.ReportEvent micPass,"默认值","期望为空,实际为:" & wd_value
  13. else
  14. Reporter.ReportEvent micFail,"默认值","期望为空,实际为:" & wd_value
  15. End If

  16. If wd_name="wd"Then
  17. Reporter.ReportEvent micPass,"名称","期望为wd,实际为:" & wd_name
  18. else
  19. Reporter.ReportEvent micFail,"名称","期望为wd,实际为:" & wd_name
  20. End If

  21. If wd_type="text" Then
  22. Reporter.ReportEvent micPass,"类型","期望为text,实际为:" & wd_type
  23. else
  24. Reporter.ReportEvent micFail,"类型","期望为text,实际为:" & wd_type
  25. End If

  26. If wd_visible=true Then
  27. Reporter.ReportEvent micPass,"状态","期望为可用,实际为:" & wd_visible
  28. else
  29. Reporter.ReportEvent micFail,"状态","期望为可用,实际为:" & wd_visible
  30. End If

  31. bt_name=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").GetROProperty("name")
  32. bt_type=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").GetROProperty("type")
  33. bt_visible=Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").GetROProperty("visible")

  34. If bt_name="百度一下" Then
  35. Reporter.ReportEvent micPass,"名称","期望为百度一下,实际为:" & bt_name
  36. else
  37. Reporter.ReportEvent micFail,"名称","期望为百度一下,实际为:" & bt_name
  38. End If

  39. If bt_type="submit" Then
  40. Reporter.ReportEvent micPass,"类型","期望为submit,实际为:" & bt_type
  41. else
  42. Reporter.ReportEvent micFail,"类型","期望为submit,实际为:" & bt_type
  43. End If

  44. If bt_visible=true Then
  45. Reporter.ReportEvent micPass,"状态","期望为可用,实际为:" & bt_visible
  46. else
  47. Reporter.ReportEvent micFail,"状态","期望为可用,实际为:" & bt_visible
  48. End If
复制代码

前面2句是用QTP的标准检查点来做的,后面是自己写的代码,问题:
1.在QTP的标准检查点中是否可以自行配置各检查项呢?例如它是没有visible这项检查项,是否在哪能将此添加进行?
2.报告显示问题:
能否在自己写的代码生成的报告中也能象检查点生成的报告那样,以不同的图标来显示不同类型的对象;
树状结构,自己写的代码生成的报告中能否像“wd“的检查点生成的报告一样将4项做为一个结果来显示;另外在显示的层次结构上是否也可向检查生成的报告那样呢?
请大家帮忙看一下,如果可能的话请大家指教一下如何改。谢谢!
作者: dqf    时间: 2012-3-13 16:32
本帖最后由 dqf 于 2012-3-13 16:33 编辑

图片怎么没上来呀 放附件中吧
作者: snakeshiy    时间: 2012-3-13 16:48
1. 应该是不能自行配置的(不是很确定),使用自定义验证的方式会更加灵活
2. 使用Reporter对象的隐藏方法LogEvent,SetContext,UnSetContext,GetContext等方法可以达到你需要的效果,具体参考http://www.ltesting.net/ceshi/ce ... 11/1215/203769.html
作者: dqf    时间: 2012-3-14 15:30
非常感谢 层次感出来了,但那个图标好象还是不行呀(无论我写210还是310、510的显示都是同一个);另外将此函数注册进去,像内置函数使用方便还是去了解一下
作者: snakeshiy    时间: 2012-3-14 16:32
回复 4# dqf
图标我有试过从200~210之间的会有不一样的图标,其他的就不知道了。。。
作者: pl80601983    时间: 2012-3-14 17:07
同意3楼
作者: dqf    时间: 2012-3-15 16:18
如何将自定义函数注册成像内置函数一样使用方便呀。
http://www.51testing.com/html/95/n-96995.htmlhttp://www.51testing.com/html/89/n-96989.html;这两个已经参见过了,但在运行时报错,提示:需要对象
作者: dqf    时间: 2012-3-21 08:45
等人解决




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2