笔记:NEC QTP 第二个实例 类间的调用Set testWindow=new ClassJavaWindowtestWindow.SetJavaWindow("User Login")Set inputSheet=new Sheetinputsheet.SetSheet("Action1")rem 定义用户名输入框Dim editUserset editUser=testWindow.GetChildEdit("User:")rem 定义密码输入框Dim editPwdset editPwd=testWindow.GetChildEdit("Password:")editUser.set "yinzihao"editPwd.set "yzh"Class Sheet '定义一些变量 private m_AllRowCount,m_SheetTable rem 定义表实例 Public function SetSheet(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 ClassClass ClassJavaWindow '定义一些变量 private m_JavaWindow Private m_ChildEdit rem 根据title定义窗口实例 Public function SetJavaWindow(title) set m_JavaWindow=JavaWindow("title:="&title) End function rem 方法,获取该窗口中的一个edit public function GetChildEdit(attachedtext) Set m_ChildEdit=new ClassJavaEdit m_ChildEdit.SetJavaEdit m_JavaWindow,attachedtext set GetChildEdit=m_ChildEdit.ItSelf End function End ClassClass 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 PropertyEnd Class 来自 大脸猫 写于 2014-02-20 16:43 -- 更新于2020-10-19 13:06 -- 2 条评论