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:20
可能是我理解错了 以为group 指的是 items
jlxie2008 2008-10-8 16:26
:L :L :L ,各位给我出出主意啊,在下跪求了... ...
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啊?
jlxie2008 2008-10-8 18:43
dim group
hsjzfling 2008-10-8 21:04
[quote]原帖由 [i]jlxie2008[/i] 于 2008-10-8 15:20 发表 [url=http://bbs.51testing.com/redirect.php?goto=findpost&pid=1081026&ptid=128605][img]http://bbs.51testing.com/images/common/back.gif[/img][/url]
Browser("***").Page("***").Frame("main-frame").WebList("first").Select group //group为定义的变量;
报错信息:“Cannot identify the specified item of the first object. Confirm that the specified ite ... [/quote]
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
:handshake ,明白了,谢谢各位的指点。