您的位置:首页 > 编程语言 > Qt开发

如何在QTP中使用IntelliSense(智能敏感)访问自定义的VBS函数和对象?

2010-01-01 15:52 639 查看
如何在
QTP

中使用
IntelliSense

(智能敏感)访问自定义的
VBS

函数和对象?



 


由于
QTP
采用
VBS
作为脚本开发语言,具有天生的
OO
缺陷,在
IntelliSense
方面也由于
QTP

IDE
缺陷而造成脚本编写效率的降低。

 

下面介绍一种方法,通过
WSC
封装
VBS
脚本,注册成
COM
对象,然后添加到
QTP
保留对象注册表中,从而实现在
QTP

IntelliSense
访问。

 


1

)创建
WSC

文件



<?xml version="1.0"?>

<component>

 

<?component error="true"
debug="true"?>

<reference
object="Scripting.Dictionary" />

<registration
description="Functions" progid="QTP.Functions"
version="1.00" classid="{d
7c
40957-00d4
-41a
5-a87b-89d1db311423}">

</registration>

 

<public>

<method name="SetID"
internalName="SetID" dispid="0">

      
<parameter
name="sValue"/>

</method>

<method name="GetID">

</method>

<method
name="PrintMessage">

      
<parameter
name="strMessage"/>

</method>

</public>

 

<script language =
"VBScript">

<![CDATA[

      
Dim
pID

      
Function
GetID()

             
GetID
= pID

      
End
Function

      
Function
SetID(sValue)

             
pID
= sValue

      
End
Function

      
Function
PrintMessage(strMessage)

             
Msgbox
strMessage

      
End
Function

      
]]>

</script>

 

</component>


2

)注册
WSC

文件



选中
WSC
文件,单击鼠标右键,选择“注册”

或者运行“
regsvr32 

"D:/QTP/MyWork/IntelliSenseTest1/test.wsc"
”命令进行注册

 


3

)注册到
QTP





打开注册表,添加“
Functions
”项,以及
ProgID

UIName


 


4

)在
QTP

中使用
IntelliSense


重新启动
QTP
后就可以使用
WSC
文件中定义的函数。在专家视图中就可以使用“
Functions
”的
IntelliSense
功能,输入“
Functions
”加点号后,就会自动弹出其所有可用的属性和方法。

 

 

参考:

http://www.advancedqtp.com/knowledge-base/articles/qtp-tricks4/qtp-hacks/intellisense-and-com/

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vbscript 脚本 语言 ide oo c
相关文章推荐