• 测试技术
  • 博客
  • 视频
  • 开源
  • 论坛
  • 沙龙
  • 下载
  • 杂志
  • 招聘

字号: | 推荐给好友 上一篇 | 下一篇

QTP解决webtable对象利用嵌套字典对象来转化

发布: 2008-9-28 13:53 | 作者: 网络转载 | 来源: 网络转载 | 查看: 64次 | 进入软件测试时代论坛讨论

软件测试时代

页面中存有大量的webtable,利用getcelldata方法,需要指定行、列的index. 但若在页面上用户

进行操作上排序,数据排列将发生变化,下面的方法,利用嵌套字典对象来转化,从而具有逻辑意义

表现访问单元格的值,从而减少参考物理单元格。(数据表如附件所示:)

 

 

 Dim oDataTable
 Dim solarExch
 Dim nRows

 set  ōDataTable=objIdentifyPage ("阿里助手","n").WebTable("text:=操作指南.*","index:=0").WebTable("text:=选择.*")
 Set solarExch = CreateObject("scrīpting.Dictionary")
 nRows=oDataTable.rowcount  
 For  nRow=2 to nRows
  symbolKey =oDataTable.getcelldata(nRow,2)
  solarExch.add symbolkey, createObject("scrīpting.Dictionary")
  solarExch(symbolKey).add "quantity", oDataTable.getcelldata(nRow,3)
  solarExch(symbolKey).add "price", oDataTable.getcelldata(nRow,4)
  solarExch(symbolKey).add "oneprice", oDataTable.getcelldata(nRow,5)
  solarExch(symbolKey).add "highprice", oDataTable.getcelldata(nRow,6)
  solarExch(symbolKey).add "situation", oDataTable.getcelldata(nRow,7)
  
 Next

    msgbox solarExch("asf").item("oneprice")'显示附土中,asf(关键词)这一行,一口价的值,并不依赖当前行列的顺序,即便重新排序。
    msgbox solarExch("试纸").item("price")


picture11

文章来源于软件测试时代 http://www.testage.net/

TAG: qtp QTP 对象 嵌套 webtable 字典


软件测试时代开课信息
Google
关于我们 | 合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2007 TestAge(测试时代) 北京慧灵科技有限公司 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备05002925号
技术支持和业务联系:info@testage.com.cn 电话:010-51297073