calykong 发表于 2007-8-18 12:24:23

有关datapool取值的问题

新建了一个名为login的datapool,里面包含两字段username、password,以下代码回放时能取到值,但是取值的时候取的是第1、3、4、6、8行的值,其他的跳过去了,不知道为什么,是不是下面代码的问题,请各位指教

'$Include "sqautil.sbh"
Sub Main
   
    Dim Result As Integer
   
    Dim dp_id as long
   
    'Dim num as Integer
   
    Dim dp_Result as long
   
    Dim username as string
   
    Dim password as string
   
   
    Dim x as Integer
   
    'num=InputBox("10")
   
    x=1
    while x<=10
   

    'Initially Recorded: 2007-8-1710:54:52
    'Script Name: qd_fya_登陆test
    StartBrowser "http://ip/xt", "WindowTag=WEBBrowser"
   
    dp_id = SQADatapoolOpen ("login",FALSE,SQA_DP_SEQUENTIAL,FALSE)
   
    call SQADatapoolFetch(dp_id)
   
    call SQADatapoolValue(dp_id,"username",username)
   
    call SQADatapoolValue(dp_id,"password",password)
   
    call SQADatapoolFetch(dp_id)
   
      
    Window SetContext, "WindowTag=WEBBrowser", ""
    Browser NewPage,"HTMLTitle=××系统",""
    SetThinkAvg 4359
    EditBox Click, "Name=username", "Coords=14,9"
    SetThinkAvg 4125
    TypingDelays "0, 250, 187, 218"
    InputKeys username
    SetThinkAvg 1516
    EditBox Click, "Name=password", "Coords=38,10"
    SetThinkAvg 1032
    TypingDelays "0, 234, 187, 282"
    InputKeys password
    SetThinkAvg 3500
    HTMLImage Click, "Index=1", "Coords=17,26"

    Result = WindowVP (Exists, "Caption=××系统 -", "VP=Window Existence;Wait=20,30")
   
    x=x+1
   
    wend
   
    dp_Result = SQADatapoolClose(dp_id)
   
      
End Sub

[ 本帖最后由 calykong 于 2007-8-18 12:29 编辑 ]

caesarqth 发表于 2007-8-18 17:15:24

1.在循环体里面不断打开datapool不对吧,放到循环体外
2。游标语句在循环体里面有两个,这样是不对的,会导致隔行读取数据
我修改了一下,不知是不是合乎你的要求,^_^

注:如果读取行数还是有问题,那么修改一下Datapool,里面肯定有Cell为空,导致出现问题

'num=InputBox("10")
   
    x=1
    'Initially Recorded: 2007-8-1710:54:52
    'Script Name: qd_fya_登陆test
    StartBrowser "http://ip/xt", "WindowTag=WEBBrowser"
   
    dp_id = SQADatapoolOpen ("login",FALSE,SQA_DP_SEQUENTIAL,FALSE)
   
    call SQADatapoolFetch(dp_id)

    while x<=10
   


   
    call SQADatapoolValue(dp_id,"username",username)
   
    call SQADatapoolValue(dp_id,"password",password)
   
    call SQADatapoolFetch(dp_id)
   
      
    。。。。。。。
   
    wend


dp_Result = SQADatapoolClose(dp_id)
页: [1]
查看完整版本: 有关datapool取值的问题