• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

软件测试工具QTP基础代码收集

发布: 2010-5-12 17:48 | 作者: 网络转载 | 来源: 领测软件测试 | 查看: 293次 | 进入软件测试论坛讨论

领测软件测试网

软件测试工具QTP基础代码收集

1、 将bug添加到QC

Dim TDConnection
  Set TDConnection = CreateObject("TDApiOle.TDConnection")
 
  TDConnection.InitConnection "http://yovav/tdbin" ' URL for the DB
  TDConnection.ConnectProject "TD76","bella","pino" ' Valid login information
 
  If TDConnection.Connected Then
  MsgBox("Connected to " + chr (13) + "Server " + TDConnection.ServerName _
  + chr (13) +"Project " + TDConnection.ProjectName )
  Else
  MsgBox("Not Connected")
  End If
 
  'Get the IBugFactory
  Set BugFactory = TDConnection.BugFactory
 
  'Add a new empty bug
  Set Bug = BugFactory.AddItem (Nothing)
 
  'fill the bug with relevant parameters
  Bug.Status = "New"
  Bug.Summary = "Connecting to TD"
  Bug.Priority = "4-Very High" ' depends on the DB
  Bug.AssignedTo = "admin" ' user that must exist in the DB's users list
  Bug.DetectedBy = "admin" ' user that must exist in the DB's users list
 
  'Post the bug to DB ( commit )
  Bug.Post

2、 文件操作函数集:

' Creates a specified file and returns a TextStream object that can be used to read from or write to the file.
  ' Example of usage
  ' Set f = CreateFile("d:\temp\beenhere.txt", True)
  ' f.WriteLine Now
  ' f.Close
  Function CreateFile(sFilename, bOverwrite)
  Set fso = CreateObject("scrīpting.FileSystemObject")
  Set CreateFile = fso.CreateTextFile(sFilename, bOverwrite)
  End Function
 
  ' Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.
  ' iomode: 1 - ForReading, 2 - ForWriting, 8 - ForAppending
  ' Example of usage
  ' Set f = OpenFile("d:\temp\beenhere.txt", 2, True)
  ' f.WriteLine Now
  ' f.Close

Function OpenFile(sFilename, iomode, create)
  Set fso = CreateObject("scrīpting.FileSystemObject")
  Set ōpenFile = fso.OpenTextFile(sFilename, iomode, create)
  End Function
 
  ' Appends a line to a file
  ' Example of usage
  ' AppendToFile "d:\temp\beenhere.txt", Now
  Function AppendToFile(sFilename, sLine)
  Const ForAppending = 8
  If sFilename = "" Then
  sFilename = Environment("SystemTempDir") & "\QTDebug.txt"
  End If
  Set f = OpenFile(sFilename, ForAppending, True)
  f.WriteLine sLine
  f.Close
  End Function
 
  ' Writes a line to a file.
  ' Destroys the current content of the file!
  ' Example of usage
  ' WriteToFile "d:\temp\beenhere.txt", Now
  Function WriteToFile(sFilename, sLine)
  Const ForWriting = 2
  If sFilename = "" Then
  sFilename = Environment("SystemTempDir") & "\QTDebug.txt"
  End If
  Set f = OpenFile(sFilename, ForWriting, True)
  f.WriteLine sLine
  f.Close
  End Function

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/

TAG: qtp QTP 代码 工具 基础 软件测试

31/3123>

关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网