backhome 发表于 2010-4-21 20:50:13

请帮我看下短代码获取随机数有什么错误,谢谢!

Browser("Wholesale – Buy China").Page("Wholesale – Buy China").Link("Clothing").Click
ItemCount =Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetItemsCount
SelectItem=RandomNumber(0,ItemCount )
Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").SelectSelectItem

wolaizhinidexin 发表于 2010-4-22 11:35:05

ItemCount =Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetItemsCount
.GetItemsCount存在吗?我咋没见过呢
改用下面这个,应该没问题了
ItemCount =Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetROProperty("items count")

[ 本帖最后由 wolaizhinidexin 于 2010-4-22 11:36 编辑 ]

恋上一支鱼 发表于 2010-4-22 21:15:56

不知道你是报什么错,根据你这段脚本,猜测可能是下面这个地方出错了,
SelectItem=RandomNumber(0,ItemCount )改成SelectItem=RandomNumber(0,ItemCount -1)试试,因为你如果是从0开始的,最多只能取到ItemCount -1,要么就是从1到ItemCount

backhome 发表于 2010-4-27 13:59:20

提示错误

ItemCount =Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetItemsCount
SelectItem=RandomNumber(0,ItemCount )
Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").SelectSelectItem

backhome 发表于 2010-4-27 14:02:41

提示错误为不支持此属性

对象不支持此属性或方法: 'Browser(...).Page(...).WebList(...).GetItemCount'
Line (2): "ItemCount=Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetItemCount".
谢谢了啊,最近比较忙都没怎么上来看过

backhome 发表于 2010-4-27 14:16:19

GetROProperty也不行啊

改为它ItemCount =Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetROProperty("items count")
过是过去了但获取不到随机值总是录制的时候的那个值

TIB 发表于 2010-4-28 10:42:54

原帖由 backhome 于 2010-4-27 14:16 发表 http://bbs.51testing.com/images/common/back.gif
改为它ItemCount =Browser("Wholesale – Buy China").Page("China Wholesale Clothing").WebList("sort").GetROProperty("items count")
过是过去了但获取不到随机值总是录制的时候的那个值

用VBS的Rnd函数来取随机数吧,使用格式:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

参考代码:
Randomize   ' Initialize random-number generator.
MyValue = Int((6 * Rnd) + 1)   ' Generate random value between 1 and 6.
页: [1]
查看完整版本: 请帮我看下短代码获取随机数有什么错误,谢谢!