筆記:NEC QTP 第二個實例

  • 2019 年 11 月 22 日
  • 筆記

類間的調用

Set testWindow=new ClassJavaWindow testWindow.SetJavaWindow("User Login") Set inputSheet=new Sheet inputsheet.SetSheet("Action1") rem 定義用戶名輸入框 Dim editUser set editUser=testWindow.GetChildEdit("User:") rem 定義密碼輸入框 Dim editPwd set 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 Class Class 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 Class 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

Tags: