zoukankan      html  css  js  c++  java
  • QTP对WebTable对象的测试

          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

    专注于自动化、性能研究,博客为原创,转载请注明文章来源于:http://www.cnblogs.com/Automation_software/ 只求在IT界有一个清闲的世界让我静心的去专研,不求功名利禄,只为心中的那份成就感及自我成长、自我实现的快感。
  • 相关阅读:
    计算两个字符串的最大公共字串的长度,字符不区分大小写
    任何一个整数m的立方都可以写成m个连续奇数之和。
    求一个byte数字对应的二进制数字中1的最大连续数
    Elasticsearch的过滤查询
    如何在Elasticsearch中安装中文分词器(IK+pinyin)
    使用Linux的alternatives命令替换选择软件的版本
    PHP如何与搜索引擎Elasticsearch交互?
    如何安装搜索引擎Elasticsearch?
    如何修改MAC自带的PHP的版本?
    程序员技能图谱
  • 原文地址:https://www.cnblogs.com/Automation_software/p/2024386.html
Copyright © 2011-2022 走看看