51Testing软件测试论坛

标题: 关于GUI循环播放的问题,望大虾指点... [打印本页]

作者: lzq1378    时间: 2007-12-29 10:41
标题: 关于GUI循环播放的问题,望大虾指点...
小弟甘接触Robot,在GUI方面有两个问题望大虾指点迷津...谢谢...
1.GUI脚本是否有可设置循环次数的地方??
2.若无,我在下面的脚本中写循环语句不知是否妥当???计算器可循环10次,数据池头一次可以用,接下来的都不行.脚本如下:
'$Include "SQAUTIL.SBH"
Sub Main
    Dim Result As Integer
    dim x as integer
    dim num1 as string
    dim num2 as string
    dim sum as string
    Dim dp as Long
    'Initially Recorded: 2007-12-28  14:59:31
    'Script Name: jsq
     
    For  Result = 0 to 9
   
    StartApplication "C:\WINDOWS\system32\calc.exe"
   
    dp=SQADatapoolOpen("jsq")
   
    for x=1 to 9
   
    Call SQADatapoolFetch(dp)
    Call SQADatapoolValue(dp,1,num1)
    Call SQADatapoolValue(dp,2,num2)
    Call SQADatapoolValue(dp,3,sum)
    'Window SetContext, "Caption=计算器", ""
    InputKeys num1 &"{+}"& num2 &"{ENTER}"
   
      next

    Call SQADatapoolClose(dp)
    Window CloseWin, "", ""

    Next Result  
   
End Sub
作者: lzq1378    时间: 2007-12-29 14:37
自己顶一下....
作者: zjslovetyan    时间: 2008-7-24 13:27
本人也是新学的robot,不敢称什么达人,新人而已。
对于你这个问题,首先要保证你的 datapool中要有足够多的数据。循环时不会取空。如果没有的话。可以在 Call SQADatapoolClose(dp)前加上SQADatapoolRewind (dp)语句。下面是我写的代码可以通过。datapool只有10条数据。
Sub Main
    Dim Result As Integer
    Dim ph As long
    Dim num1 As string
    Dim num2 As string
    Dim sum As string
    Dim x As Integer
    Dim y As Integer
    'Initially Recorded: 2008-7-1  15:44:10
    'Script Name: test
    For  y = 0 to 9 step 1
    StartApplication "C:\WINNT\system32\calc.exe"
    ph = sqadatapoolopen("jsq")
    StartTimer "1"
    for x=0 to 9 step 1
    call sqadatapoolfetch(ph)
    call sqadatapoolvalue(ph,1,num1)
    call sqadatapoolvalue(ph,2,num2)
    call sqadatapoolvalue(ph,3,sum)
    Inputkeys num1 &"{+}"& num2 &"{ENTER}"
    Result = LabelVP (CompareNumeric, "Text="& sum &".", "VP=Alphanumeric;Value="& sum &".")
     next
    StopTimer "1"
    MsgBox Result
    'Result = SQADatapoolRewind (ph)
    Call SQADatapoolClose(ph)
    Window SetContext, "Caption=计算器", ""
    Window CloseWin, "", ""
   next y
End Sub




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