不谋万世者,不足谋一时;不谋全局者,不足谋一域。君子敏于事而慎于言 新浪微薄:土司阿哈

webRadionGroup和webtable的使用技巧

上一篇 / 下一篇  2008-04-16 20:53:57 / 个人分类:qtp

1208328177
  • 自动化测试:
  • 测试文档:
51Testing软件测试网/R {d!S/Ld(e Z

'   演示环境http://newtours.demoaut.com/mercuryreservation.php
"]hu,CW#wf0Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").Select "oneway"
9Q4g(MG1_M%E$l1q8W0' all items  获取所有单选框的对象,
o%l%PR4~5\3U.pu0 msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("all items")51Testing软件测试网;I:yo~gH3`H
'items count  获取单选框的个数51Testing软件测试网KOQ!j"t0QBJ;{2r
  msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("items count")51Testing软件测试网Y[ eoE"E/X:Z
 
+t0Wgv/[C.j9seR0  'selected item index   获取当前所选对象index51Testing软件测试网0z?z1e_Xj}M] y4{
 msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("selected item index")
/HQ2Y8tw0  msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("value")51Testing软件测试网&_'w(rP%{A6B o

51Testing软件测试网s'M7^ZXLc,ka

 51Testing软件测试网-]4wiJ:ML]!p

51Testing软件测试网/u V,Min$Wm

如图,知道其中黄色部分,要找到器绿色部分的信息,同时,在本页找不到的情况下,翻页继续找,直到最后一页!51Testing软件测试网 `#d%]1|eL

51Testing软件测试网nt|+T2y"Xql"Z4I

具体代码如下:

Y Zo-D.]_#Te0

XY#C8s4l0n'c%l3k0Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Activate
Gg#W?_*CWQ T0'Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Page("查询").Link("5").Click51Testing软件测试网%z u(sB,i-F ~4r'RV

tG;M] S/q6F0A0If
51Testing软件测试网`*qzz o"_h
msgbox Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Page("查询").WebTable("序号").GetCellData(2,3)51Testing软件测试网-H iy.o.T"d
Dim row ,link51Testing软件测试网8q U?r|[*['W$HN+P
row = Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Page("查询").WebTable("序号").GetRowWithCellText(DataTable("p_Text", dtGlobalSheet), 2, 3)
Z@f p$g3P0msgbox row51Testing软件测试网ty'f b/g&d

51Testing软件测试网 Z]7RZl{S8b#A-Lw

Set Link = Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Page("查询").WebTable("序号").ChildItem(row, 1, "Link", 0)

HW5E7QB)m N2{051Testing软件测试网:@ w0Ha^+iW N Y1G!B

Link.Click51Testing软件测试网$c oHB{8yN u

51Testing软件测试网g'^,v6K0G

同时,webtable常用的方法还有

h Pr o+t/^1gg051Testing软件测试网1k/d8]+q4Da

if  Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Page("查询").WebTable("序号").Exist then

$V"{F0h_$]!A4\0

pY.m6H J.C0reporter.ReportEvent 0,"pass","系统显示了所有的资讯列表!"

op3Dpr"{#w051Testing软件测试网.n4h;?&G$R.sXRQ"Rx&^

else
3P'Q Ab[(uk P6w0  reporter.ReportEvent 1,"fail","
系统没有显示资讯列表!

U,A:fCj+f0

4U-OSLkN,o:] G0end if51Testing软件测试网:F$?KY WzB

~ m F^YP0获取表格行数:
_'E$O,i*qj1b R0
Browser("欢迎使用信贷综合管理系统").Window("查询 -- 网页对话框").Page("查询").WebTable("序号").RowCount
51Testing软件测试网n1MduE,wa Y/L?


TAG: QTP qtp

土司*阿哈空间 引用 删除 wonew1228   /   2008-11-03 15:37:24
str="Blue Skies Airlines$361$271$7:10"
aa=split(str,"$")
xx= aa(0)&aa(1)&aa(2)
msgbox xx
angelia_liu的个人空间 引用 删除 angelia_liu   /   2008-10-29 16:35:21
您好,这样的话我取出来的值是"Blue Skies Airlines$361$271$7:10".
请问怎么把这个"$"去掉?
谢谢
土司*阿哈空间 引用 删除 wonew1228   /   2008-10-27 22:18:03
可以把所选的值设为参数,存在excel中,以供后面使用;
或者用GetROProperty("value") 去得他所选的值,如下:
Browser("Welcome: Mercury Tours").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("value")
angelia_liu的个人空间 引用 删除 angelia_liu   /   2008-10-27 15:58:51
Browser("Find a Flight: Mercury\").Page("Find a Flight: Mercury").WebRadioGroup("tripType").Select "oneway"51Testing软件测试网^L'Y4t3h'KX0N.M
' all items  获取所有单选框的对象,
t w*IER169422 msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("all items")51Testing软件测试网`#\Z2I*nk` G
'items count  获取单选框的个数51Testing软件测试网1b5Jm-lWi9?PV'a6GYx
  msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("items count")
(C%?@4B)az q169422  51Testing软件测试网7sm\*lSl
  'selected item index   获取当前所选对象index 51Testing软件测试网jQ:f%Uy;T
msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("selected item index")
"j.|+^VfHp8b"`4f(N169422  msgbox Browser("Find a Flight: Mercury").Page("Find a Flight: Mercury").WebRadioGroup("tripType").GetROProperty("value")

我有一个问题,希望您帮忙解答,
就是当我获取了我们选择的这个选项的值后,如何把这个值保存起来以备后面要用.
 

评分:0

我来说两句

Open Toolbar