仍然还是在测试登录,描述性编程外加 伪类调用。真不方便啊。。。
附带一个自编的代码生成工具,QTP的编译器实在太差了。不能识别外部类。这下妈妈再也不用担心我打错字了。。
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