• 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界有一个清闲的世界让我静心的去专研,不求功名利禄,只为心中的那份成就感及自我成长、自我实现的快感。
  • 相关阅读:
    (已解决)mac安装mysql出现:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/my...
    非root用户启动redis容器报错mkdir: cannot create directory '/bitnami/redis': Permission denied
    VirtualBox虚拟机E_INVALIDARG (0x80070057)
    非root用户启动redis容器报错mkdir: cannot create directory '/bitnami/redis': Permission denied
    添加共享文件夹
    Skipping acquire of configured file ···doesn't support architecture 'i386' acquire of configured file
    docker镜像运行错误排查
    debian9使用国内源安装docker以及一些使用方法
    docker创建镜像及push镜像出错问题
    mongodb参数
  • 原文地址:https://www.cnblogs.com/Automation_software/p/2024386.html
Copyright © 2020-2023  润新知