QTP的2种脚本调用方法是什么

QTP的2种脚本调用方法是什么,第1张

我不知道你调用脚本是什么概念?在QTP中调用外部脚本?还是启动QTP脚本?

调用外部脚本,你可以采取VBS的程序去调用外部程序,或者你可以写COM接口,然后再QTP的中调用!

启动QTP脚本,你可以采取QTP的COM接口通过程序来调用

(3atesing有大量视频专门介绍QTP的各类实用模式的)

QTP的COM调胡戚拦稿用可参考:

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Launch QuickTest

qtApp.Visible = True ' Set QuickTest to be visible

' Open a test and get the "Login" action's object repositories collection

qtApp.Open "C:\Tests\Test1", False, False ' Open a test

Set qtRepositories = qtApp.Test.Actions("Login").ObjectRepositories ' Get the object repositories collection object of the "Login" action

' Add MainApp.tsr if it's not already in the collection

If qtRepositories.Find("C:\MainApp.tsr") = -1 Then ' If the repository cannot be found in the collection

qtRepositories.Add "C:\MainApp.tsr", 1 ' Add the repository to the collection

End If

' If InnerWnd.tsr is moved down the list - place it back at position 1

If qtRepositories.Count >1 And qtRepositories.Item(2) = "裤衡陵C:\InnerWnd.tsr" Then ' If there's more than one object repository and InnerWnd.tsr is in position 2

qtRepositories.MoveToPos 1, 2 ' Switch between the first two object repositories

End If

' If Debug.tsr is in the collection - remove it

lngPosition = qtRepositories.Find("C:\Debug.tsr") ' Try finding the Debug.tsr object repository

If lngPosition <>-1 Then ' If the object repository was found in the collection

qtRepositories.Remove lngPosition ' Remove it

End If

' Set the new object repository configuration as the default for all new actions

qtRepositories.SetAsDefault ' Set object repositories associated with the "Login" action as the default for all new actions

'Save the test and close QuickTest

qtApp.Test.Save ' Save the test

qtApp.Quit ' Quit QuickTest

Set qtRepositories = Nothing ' Release the action's shared repositories collection

Set qtApp = Nothing ' Release the Application object

Function GetXml (ByVal strXmlFilePath,ByVal xmlNodeName)

      Dim xmlDoc,xmlRoot

      Set xmlDoc = CreateObject("Microsoft.XMLDOM") '创建XML DOM对象

      xmlDoc.async = False  '控制加载模式吵祥为同步模式(xml树加载完毕后再执行后续代码)

      xmlDoc.load strXmlFilePath        '升中搏载入xml文件

      If xmlDoc.parseError.errorCode <> 0 Then

              MsgBox "XML文件格式不对,原因是:" & Chr(13) &  xmlDoc.parseError.reason

              Exit Function

      End If

      Set xmlRoot = xmlDoc.documentElement

      xmlRecursion xmlRoot,xmlNodeName        '调用xml递归函数传入指定的根和节点名

      GetXml = True 'xmlRecursion 培耐(xmlRoot)

End Function

可以使用通用戚州并的QTP内置对象SystemUtil来搞定

如果是Browser还可以使用CreateObject IE来搞定。

甚至可以执行Window Shell执行命令行。

总高迹之迹禅方法多种多样。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12548750.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存