QTP對WebTable對象的測試

來源:互聯網
上載者:User

      WebTable對象用於測試Web頁面的表格對象。

      對錶格對象的測試主要是擷取其中的資料,例如表格的行數、列數、儲存格的內容等。WebTable對象常用的方法有:ColumnCount、RowCount、GetCellData、ChildItem等。以下為四個方法的文法。

ColumnCount 方法:

描述

返回表中的列數。

文法

object.ColumnCount (Row)

參數

描述

object

類型 WebTable 的測試對象。

Row

必填. Long 值。 行號。表中的第一行編號為 1。

傳回型別

Long 值。  

 

RowCount 方法:

描述

返回表中的行數。

文法

object.RowCount

參數

描述

object

類型 WebTable 的測試對象。

傳回型別

Long 值。  

 

GetCellData 方法:

描述

返回包含於指定儲存格中的文本。

文法

object.GetCellData (vtRow, vtColumn)

參數

描述

object

類型 WebTable 的測試對象。

vtRow

必填. Variant 值。 儲存格所在行的行號。表中的第一行編號為 1。

vtColumn

必填. Variant 值。 儲存格所在列的編號。表中的第一列編號為 1。

傳回型別

String 值。  返回指定儲存格中包含的資料。
如果指定儲存格無效,該方法返回 micCellDoesNotExist 

 

ChildItem 方法:

描述

按類型和索引返回儲存格中的測試對象。

文法

object.ChildItem (Row, Column, MicClass, Index)

參數

描述

object

類型 WebTable 的測試對象。

Row

必填. Long 值。 儲存格所在行的行號。表中的第一行編號為 1。

Column

必填. Long 值。 儲存格所在列的編號。表中的第一列編號為 1。

MicClass

必填. String 值。 物件類型。

Index

必填. Long 值。 儲存格中 MicClass 類型的對象的索引。當儲存格中有多個 MicClass  類型的對象時,此索引指示所需的元素。第一個對象的索引為 0。

傳回型別

Object 對象。 

 

執行個體一:

Dim RowCount
RowCount  = Browser("Browser").Page("Page").WebTable("WebTable").RowCount
msgbox RowCount
For I = 2 to RowCount
 cons_no=Browser("Browser").Page("Page").Frame("Frame").WebTable("html tag:=table","index:=2").GetCellData(4,2)
 reporter.ReportEvent micDone,"使用者編號","使用者編號為:"&cons_no
Next

 

執行個體二:
Set objTable=Browser("creationTime:=0").Page("index:=0").Frame("name:=TreeMenuFrame").WebTable("html tag:=TABLE","index:=1")
dim intRow
intRow = Browser("creationTime:=0").Page("index:=0").Frame("name:=TreeMenuFrame").WebTable("html tag:=TABLE","index:=1").GetROProperty("rows")

dim intColumn
intColumn=Browser("creationTime:=0").Page("index:=0").Frame("name:=TreeMenuFrame").WebTable("html tag:=TABLE","index:=1").GetROProperty("cols")

Set objLink = objTable.ChildItem(intRow,intColumn,"Image",32)
If  not objLink.Exist(0) Then
 msgbox "系統中沒有您要找的菜單,請檢查!"
 else
 objLink.click
End If

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.