51Testing软件测试论坛

标题: 菜鸟求助:关于"select”变量时出错,为什么? [打印本页]

作者: jlxie2008    时间: 2008-10-8 15:20
标题: 菜鸟求助:关于"select”变量时出错,为什么?
Browser("***").Page("***").Frame("main-frame").WebList("first").Select group //group为定义的变量;

报错信息:“Cannot identify the specified item of the first object. Confirm that the specified item is included in the object's item collection.”
作者: jlxie2008    时间: 2008-10-8 15:43
直接赋值是可以的,实在弄不明白!!!
如:
Browser("***").Page("***").Frame("main-frame").WebList("first").Select “10000” //这样是通过的

请高人指点一下!!!
作者: helius    时间: 2008-10-8 15:45
Browser("***").Page("***").Frame("main-frame").WebList("first").Select "#"&group
这个样子 试试
作者: jlxie2008    时间: 2008-10-8 16:03
回复:
Browser("***").Page("***").Frame("main-frame").WebList("first").Select "#"&group
这个样子 试试


还是不行,同样的报错信息:
Cannot identify the specified item of the first object. Confirm that the specified item is included in the object's item collection.
作者: helius    时间: 2008-10-8 16:08
msgbox group
作者: helius    时间: 2008-10-8 16:20
可能是我理解错了  以为group 指的是 items
作者: jlxie2008    时间: 2008-10-8 16:26
,各位给我出出主意啊,在下跪求了... ...
作者: gy21st    时间: 2008-10-8 16:44
是不是你用了group=10000? 试试group="10000"
作者: jlxie2008    时间: 2008-10-8 16:51
回复:
是不是你用了group=10000? 试试group="10000"

我前面加了循环啊(For group=10001 to 10011),group="10000"无法办到哦!
作者: helius    时间: 2008-10-8 17:00
Num=Browser("***").Page("***").Frame("main-frame").WebList("first").GetRoproperty("items count")
For group=0 to Num
Browser("***").Page("***").Frame("main-frame").WebList("first").Select "#"&group
Next
假如 items=0 对应“10001”items=Num 对应“10011”
作者: jlxie2008    时间: 2008-10-8 17:14
因为我是先添加一个:
Browser("***").Page("***").Frame("main-frame").WebEdit("item1").Set group
然后直接:
Browser("***").Page("***").Frame("main-frame").WebList("first").Select group,在他的列表VALUE里存在啊,为什么不可以直接SELECT啊?
作者: lgzlphph    时间: 2008-10-8 17:17
你变量是怎么定义的啊?
作者: jlxie2008    时间: 2008-10-8 18:43
dim group
作者: hsjzfling    时间: 2008-10-8 21:04
原帖由 jlxie2008 于 2008-10-8 15:20 发表
Browser("***").Page("***").Frame("main-frame").WebList("first").Select group //group为定义的变量;

报错信息:“Cannot identify the specified item of the first object. Confirm that the specified ite ...


8楼都已经给你指出错误的原因了。。。

你的group变量是个数字,而Select的值如果是数字,则QTP会认为你选的是index,从0开始计算,也就是说实际上qtp要去select 该weblist的第10001个选项。

明白这一点就容易了,只需要将数字变量转换为字符串就行了,一个CStr就搞定了,即
Browser("***").Page("***").Frame("main-frame").WebList("first").Select CStr(group)
作者: jlxie2008    时间: 2008-10-9 09:34
,明白了,谢谢各位的指点。




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2