未来已来

Qtp如何调用vbs中创建的类?

上一篇 / 下一篇  2008-07-14 18:20:33 / 个人分类:自动化测试

论坛问题http://bbs.51testing.com/thread-119751-1-6.html  

答案代码如下

Option explicit

Public function stack()
    set stack = new clsStack
End Function

Class clsStack

    Private l
    Private Sub Class_Initialize    ' Setup Initialize event.
        set l = linkedList         ' Create a linked list instance
    End Sub

    Public function pop()
        If l.count = 0 Then exit function    ' No items in the list
        pop = l.getlast()          ' Return the last item
        l.deleteLast               ' and delete it
    End Function

    Public sub push(element)       
        l.add element              ' Add an item to the list
    End sub

    Public function peek()           
        peek = l.getlast()         ' Peek at the top item
    End Function

End Class

 

在qtp中加载以上vbs文件然后在qtp中写如下代码:

Dim tStack

set tStack = stack         

以上代码运行会有错误,因为linkedList类的实现我没有给出代码。


TAG: 自动化测试

引用 删除 rayblue   /   2009-06-04 11:35:47
貌似在QTP中Dim tStack

set tStack = stack
这两句不需要,直接用stack调用类就可以了
引用 删除 rayblue   /   2009-06-04 11:06:16
用返回的实例直接调用就好了
引用 删除 rayblue   /   2009-06-04 11:00:40
在qtp中还是无法自由的调用类中的方法和属性,有什么解决方法么?
 

评分:0

我来说两句

Open Toolbar