51Testing软件测试论坛

标题: 继续求助,VBS调用启动QTP工程问题 [打印本页]

作者: yuwen123441    时间: 2010-9-10 17:44
标题: 继续求助,VBS调用启动QTP工程问题
使用VBS调用QTP工程,发现qtp运行的时候,总是报“类型不匹配”错误,QTP直接运行的时候,是正确的,郁闷了!
作者: kavensyw    时间: 2010-9-10 17:46
贴出源码
作者: TIB    时间: 2010-9-10 21:35
一般用VBS启动QTP不会有太多问题,按照帮助文档的来用即可,例如:

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtStdLauncher 'As QuickTest.StdLauncher ' Declare an Windows Applications launcher variable
Dim qtStdApp 'As QuickTest.StdApplication ' Declare as StdApplication object variable
Dim strAdded ' Declare a string variable for the added applications

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

' Preparare application and test
qtApp.SetActiveAddins Array() ' Remove all add-ins from the collection so that QuickTest opens with no add-ins loaded
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible
qtApp.Test.SetAssociatedAddins Array() ' Remove all add-ins from the test's associated add-ins list.
Set qtStdLauncher = qtApp.Test.Settings.Launchers.Item("Windows Applications") ' Return the Windows Applications launcher

qtStdLauncher.Active = True ' Instruct QuickTest to open applications when the record session begins

' Set the applications under test
qtStdLauncher.Applications.AddApplication "C:\Viewer.exe", "C:\" ' Add an application
qtStdLauncher.Applications.AddApplication "D:\Apps\Editor.exe", "D:\Apps" ' Add another application

' Save changes and clean up
qtApp.Test.SaveAs "C:\Tests\NewTest" ' Save the test
qtApp.Quit ' Exit QuickTest
Set qtStdLauncher = Nothing ' Release the Windows Applications launcher object
Set qtApp = Nothing ' Release the Application object
作者: yuwen123441    时间: 2010-9-11 21:03
恩,我把错误的函数注释掉,就会报下一个函数“类型不匹配”错误,郁闷,是不是QTPbug??
作者: sterson    时间: 2010-9-12 11:41
一般不会有什么问题,楼主可以查一下
1,源码是否有问题,可以将源码放到VB开发工具去运行
2,VB与VBS还是有些区别,
Set qtApp = CreateObject("QuickTest.Application")
Set qtApp = New QuickTest.Application
3,可能是编写代码的工具引起的,主要是Encode不同,也会引起类型不匹配的提示




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