前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >笔记:NEC QTP 第三个实例

笔记:NEC QTP 第三个实例

作者头像
超级大猪
发布2019-11-22 11:38:06
5010
发布2019-11-22 11:38:06
举报
文章被收录于专栏:大猪的笔记大猪的笔记

仍然还是在测试登录,描述性编程外加 伪类调用。真不方便啊。。。

附带一个自编的代码生成工具,QTP的编译器实在太差了。不能识别外部类。这下妈妈再也不用担心我打错字了。。

CodeHelper.zip

Public Function newClass(className) Dim strSentence,obj          strSentence = strSentence & "set obj = New " & className '创建对象    Execute strSentence  '执行字符串语句 Set newClass = obj   '返回对象 End Function rem 表示所有的excel的类 Class Sheet '定义一些变量 private m_AllRowCount,m_SheetTable rem 定义表实例 Public function SetSheet(filepath,sheetName)     '        Dim sheetcount, dtsheetobj, yourSheetName, isFound '         '        isFound=False '        yourSheetName=sheetName '         '        sheetcount = DataTable.GetSheetCount '        For i=1 to sheetcount '        print DataTable.GetSheet(i).name '        If DataTable.GetSheet(i).name = yourSheetName Then '                isFound=True '                Exit For '        End If '        Next '         '        If isFound=True Then '                MsgBox("haha, found") '        Else '                MsgBox("Not found!") '        End If '             DataTable.AddSheet(sheetName)         DataTable.ImportSheet filepath,"Sheet1",sheetName set m_SheetTable=DataTable.GetSheet(sheetName)         End function rem 只读属性:总行数 Public Property Get AllRowCount         AllRowCount = GetAllRowCount() End Property rem 方法,获取行列值 Public function GetRowColData(row,colname)         GetRowColData=m_SheetTable.GetParameter(colname).ValueByRow(row) End function rem 此方法获取表行数 Private Function GetAllRowCount()       GetAllRowCount= m_SheetTable.GetRowCount rem 获取总行数         End Function End Class rem 表示所有的javaWindow类 Class ClassJavaWindow '定义内部可能出现的控件 private m_JavaWindow Private m_ChildEdit     Private m_ChildJavaButton Private m_ChildJavaStaticText Private m_ChildJavaMenu Private m_ChildJavaDialog rem 根据title定义窗口实例 Public function SetJavaWindow(title) set    m_JavaWindow=JavaWindow("title:="&title) End function rem 只读属性:返回自身 Public Property Get ItSelf set    ItSelf = m_JavaWindow End Property rem 方法,获取该窗口中的一个edit public function GetChildEdit(attachedtext) Set m_ChildEdit=new ClassJavaEdit         m_ChildEdit.SetJavaEdit m_JavaWindow,attachedtext set GetChildEdit=m_ChildEdit End function '     rem 方法,获取该窗口中的一个JavaDialog public function GetChildJavaDialog(title) Set m_ChildJavaDialog=new ClassJavaDialog         m_ChildJavaDialog.SetJavaDialog m_JavaWindow,title set GetChildJavaDialog=m_ChildJavaDialog End function rem 方法,获取该窗口中的一个Button public function GetChildJavaButton(attachedtext) Set m_ChildJavaButton=new ClassJavaButton         m_ChildJavaButton.SetJavaButton m_JavaWindow,attachedtext set GetChildJavaButton=m_ChildJavaButton End function rem 方法,获取该窗口中的一个javastatictext public function GetChildJavaStaticText(label) Set m_ChildJavaStaticText=new ClassJavaStaticText         m_ChildJavaStaticText.SetJavaStaticText m_JavaWindow,label set GetChildJavaStaticText=m_ChildJavaStaticText End function rem 方法,获取该窗口中的一个JavaMenu public function GetChildJavaMenu(label) Set m_ChildJavaMenu=new ClassJavaMenu         m_ChildJavaMenu.SetJavaMenu m_JavaWindow,label set GetChildJavaMenu=m_ChildJavaMenu End function End Class rem 表示某控件下的 javaEdit 的类 Class ClassJavaEdit Private m_JavaEdit rem 根据父窗口和attachedText定义实例 Public function SetJavaEdit(parent,attachedtext) set    m_JavaEdit=parent.JavaEdit("attached text:="&attachedtext) End function rem 只读属性:返回自身 Public Property Get ItSelf set    ItSelf = m_JavaEdit End Property End Class Class ClassJavaButton Private m_JavaButton rem 根据父窗口和attachedText定义实例 Public function SetJavaButton(parent,attachedtext) set    m_JavaButton=parent.JavaButton("attached text:="&attachedtext) End function rem 只读属性:返回自身实例 Public Property Get ItSelf set    ItSelf = m_JavaButton End Property rem  单击一下 Public function ClickButton call m_JavaButton.Click End function End Class Class ClassJavaDialog rem dialog中可能出现的控件 Private m_JavaDialog Private m_ChildJavaButton Private m_ChildJavaStaticText Private m_ChildEdit Private m_ChildJavaDialog Private m_ChildJavaTable rem 根据父窗口和attachedText定义实例 Public function SetJavaDialog(parent,title) If isNull(parent)=true Then set    m_JavaDialog=JavaDialog("title:="&title) Else set    m_JavaDialog=parent.JavaDialog("title:="&title) End If End function rem 只读属性:返回自身实例 Public Property Get ItSelf set    ItSelf = m_JavaDialog End Property rem 方法,获取该窗口中的一个JavaTable public function GetChildJavaTable(tagName) Set m_ChildJavaTable=new ClassJavaTable         m_ChildJavaTable.SetJavaTable m_JavaDialog,tagName set GetChildJavaTable=m_ChildJavaTable End function rem 方法,获取该窗口中的一个Button public function GetChildJavaButton(attachedtext) Set m_ChildJavaButton=new ClassJavaButton         m_ChildJavaButton.SetJavaButton m_JavaDialog,attachedtext set GetChildJavaButton=m_ChildJavaButton End function rem 方法,获取该窗口中的一个javastatictext public function GetChildJavaStaticText(label) Set m_ChildJavaStaticText=new ClassJavaStaticText         m_ChildJavaStaticText.SetJavaStaticText m_JavaDialog,label set GetChildJavaStaticText=m_ChildJavaStaticText End function rem 方法,获取该窗口中的一个javaDialog public function GetChildJavaDialog(title) Set m_ChildJavaDialog=new ClassJavaDialog         m_ChildJavaDialog.SetJavaDialog m_JavaDialog,title set GetChildJavaDialog=m_ChildJavaDialog End function rem 方法,获取该窗口中的一个edit public function GetChildEdit(attachedtext) Set m_ChildEdit=new ClassJavaEdit         m_ChildEdit.SetJavaEdit m_JavaDialog,attachedtext set GetChildEdit=m_ChildEdit End function End Class Class ClassJavaStaticText Private m_JavaStaticText Private m_Text rem 根据父窗口和lable定义实例 Public function SetJavaStaticText(parent,label) set m_JavaStaticText=parent.JavaStaticText("label:="&label) End function rem 只读属性:返回自身实例 Public Property Get ItSelf set    ItSelf = m_JavaStaticText End Property Public Property Get Text         Text = m_JavaStaticText.GetROProperty("text") End Property End Class Class ClassJavaTable Private m_JavaTable rem 根据父窗口和lable定义实例 Public function SetJavaTable(parent,tagname) set m_JavaTable=parent.JavaTable("tagname:="&tagname) End function rem 只读属性:返回自身实例 Public Property Get ItSelf set    ItSelf = m_JavaTable End Property Public Function GetRowColText(rownum,colName)         GetRowColText=m_JavaTable.GetCellData(rownum,colName) End Function End Class Class ClassJavaMenu Private m_JavaMenu Private m_ChildJavaMenu rem 根据父窗口和lable定义实例 Public function SetJavaMenu(parent,label) set m_JavaMenu=parent.JavaMenu("label:="&label) End function rem 只读属性:返回自身实例 Public Property Get ItSelf set    ItSelf = m_JavaMenu End Property rem 方法,获取该窗口中的一个JavaMenu public function GetChildJavaMenu(label) Set m_ChildJavaMenu=new ClassJavaMenu             m_ChildJavaMenu.SetJavaMenu m_JavaMenu,label set GetChildJavaMenu=m_ChildJavaMenu End function End Class

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-02-21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档