参数化 link四种方法

上一篇 / 下一篇  2014-08-07 11:32:45 / 个人分类:QTP

看了maguschen的两种参数化LINK方法http://bbs.51testing.com/viewthread.php?tid=48945&highlight=2%D6%D6%B2%CE%CA%FD%BB%AFLINK%B5%C4%B7%BD%B7%A8,非常受益,另外想出了两种参数化LINK的方法,供大家参考,举一反三同样可以对webedit,webelement等对象进行参数化

第一种:利用 Description 对象For intLoop = 1 to N
    strText=DataTable.Value(...)
    Set LinkDesc = Description.Create()
    LinkDesc ("Text").Value = strText
   Browser("").Page("").Link(LinkDesc).Click
    DataTable.GetSheet("").SetNextRow
Next
第二种:描述性编程For intLoop = 1 to N
    strText=DataTable.Value(...)
    Browser("").Page("").Link("text:=" & strText).Click
    DataTable.GetSheet("").SetNextRow
Next
第三种:利用SetToproperty方法(以sina为例)
Step1:录制
Browser("新浪首页").Page("新浪首页").Link("墨尔本北航热招营销硕士").click
此时对象库如图1
1.JPG

Step2:欲点击其他新闻
Browser("新浪首页").Page("新浪首页").Link("北大私募基金/企业上市").Click
'点击北大...新闻
Browser("新浪首页").Page("新浪首页").Link("北大私募基金/企业上市").SetTOProperty"text","清华深圳创业板/私募班"
Browser("新浪首页").Page("新浪首页").Link("北大私募基金/企业上市").Click
'点击清华...新闻
Setp3:写循环语句
For intLoop = 1 to N
    strText=DataTable.Value(...)

    Browser("新浪首页").Page("新浪首页").Link("北大私募基金/企业上市").SetTOProperty"text","strText"
    DataTable.GetSheet("").SetNextRow
Next

第四种:利用参数化对象的Text属性实现
Step1:录制
Browser("新浪首页").Page("新浪首页").Link("墨尔本北航热招营销硕士").click
此时对象库如图1


Step2:参数化Text属性,见下图2,步骤省略
2.JPG
Step3:写循环或者设置Action run call propertiesrun on all rows即可



TAG: QTP link参数化

 

评分:0

我来说两句

日历

« 2024-04-24  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 37430
  • 日志数: 28
  • 建立时间: 2014-07-17
  • 更新时间: 2015-03-19

RSS订阅

Open Toolbar