1.Rnd函数,这个函数本人没用过,试了一下,出现情况与楼主所描述的一样,看了下帮助:Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer. 也没看明白,但是应该是联合Randomize 函数一起用吧。
我本人使用RandomNumber函数,比较简单地取到随机数。请参考我最后的例子。
如果用楼主的方法,的确每次都是得到7,导致后面会发雹御闹生数组越界。
2.split函数分割有误,如果以“ ”为分割,则将产生3个地址的数组,当Fly_From1 = myarray(SelectFnumber) ,由于SelectFnumber每次是7,所以数组越界。
解决方法用回车来Split地址产生数组吧。
最后给出我写的参考代码,实验通过,供参考:
ItemsCount1=Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount
RandomCout=RandomNumber(0,ItemsCount1)'产生随机数
msgbox(RandomCout)
myarray = Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("all items")
flyarray=split(myarray,vbLf ) ''用回车分隔
msgbox ubound(flyarray) '数组长度为拆旦结果是10,正确了
FlyItem=flyarray(RandomCout)
Window("Flight Reservation").WinComboBox("Fly From:").Select FlyItem
在脚本的最后一行增加下面的代码wait(5)
括号中的数字是需要等待的秒数
因为第一次迭代漏桐纯结束到第二次返咐迭代需轮哗要有一个时间 自动打开飞机订票应用程序 所以需要等待几秒再进行下一次迭代
Window("Flight Reservation").WinObject("Date of Flight:").Type "121212"这个不就是日期录制进野衡去了么?
Object not visible
Line (6): "Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"
这个可能是因为你的qtp,或者其他的什么界面,遮盖着fly from了吧,世型提示的是对象看不到!
录制的脚本没有问题。颂返做
不行的话,你重新录制一下,做下对比!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)