• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

robot函数实例讲解(一)

发布: 2008-7-24 17:59 | 作者: 网络转载 | 来源: 51testing sincky | 查看: 74次 | 进入软件测试论坛讨论

领测软件测试网

功能说明:出现一个提示对话框,N秒后消失,比如说:提示等待一个窗口阿,有时候这个窗口没了,我也不知道脚本运行到什么地方了,提示一下挺好,也方便其他的测试员修改,而且,也不影响无人值守的操作

例子:SQAMsgbox "test","title",5

Global iTime as Integer

Declare Function TimedDlgFunc(id As String, Action As Integer, Suppvalue As Long) As Integer

Declare Function SQAMsgBox(sMsgText as String, Optional vMsgCaption as Variant, Optional vTimeOut as Variant) as Integer


Function TimedDlgFunc(id As String, Action As Integer, Suppvalue As Long) As Integer
    Static StartTime
    Dim EndTime
    Dim vTimeoutvalue as Variant

    Select Case Action
        Case 1      'Dialog box Initialization
                StartTime = Timer

                If StartTime + iTime >= 86400 Then
                        StartTime = 86400 - StartTime - iTime
                End If
                TimedDlgFunc = 1

        Case 2      'Button pushed or any control changed (except typing in text or combo box)
            Select Case Suppvalue
                Case 1
                    DlgEnd -1
                Case 2
                    DlgEnd 0
                Case Else
                    TimedDlgFunc = 0
            End Select

        Case 3      'Change in text or combo box contents
                TimedDlgFunc = 1

        Case 4      'Change of control focus
                TimedDlgFunc = 1

        Case 5      'Idle state (return 0 to prevent this being continually called)
                EndTime = Timer
                If (EndTime - StartTime) >= iTime Then
                        DlgEnd -1
                End If
                vTimeoutvalue = Format(iTime - (EndTime - StartTime), "#.#")
                DlgText DlgControlID("txtTimevalue"), CStr(vTimeoutvalue)
                TimedDlgFunc = 1
    End Select

End Function


Function SQAMsgBox(sMsgText as String, Optional vMsgCaption as Variant, Optional vTimeOut as Variant) as Integer
    Dim Result as Integer
    Dim TotalTime As Integer
    Dim sCmdText as String   
    Dim sTimeoutText as String
    Dim vvalue as Variant

   
    If IsMissing(vMsgCaption) Then
        vMsgCaption = "SQAMsgBox"
    End If
    If IsMissing(vTimeOut) Then
        vTimeOut = 20       'seconds
    End If

    sTimeoutText = "Timeout: "
   
'-----
    Begin Dialog dlgMsgBox 200, 80, vMsgCaption, .TimedDlgFunc
        GroupBox 5, 2, 190, 40, "", .grpMsgTxt
        Text 15, 11, 175, 25, sMsgText, .txtMsgText
        Text 15, 47, 180, 20, sCmdText, .txtCmdText
'--------------
        Button 20, 60, 40, 14, "&OK", .btnOK
        Button 140, 60, 40, 14, "&Cancel", .btnCancel
        Text 78, 63, 30, 10, sTimeoutText, .txtTimeText
        Text 108, 63, 20, 10, vTimeout, .txtTimevalue
    End Dialog
'-----

    Dim TimedDlg As dlgMsgBox
    iTime = CInt(vTimeOut)
    Result = Dialog(TimedDlg)
   
    If Result = 2 Then
        SQAMsgBox = sqaFail
    Else
        SQAMsgBox = sqaPass
    End If   
   
End Function

关于Recognition
一共分为Recognition, ParentRecognition, FullRecognition
1. To find the recognition method of the currently active window:
Result=SQAGetProperty(".\","Recognition",value)
Returned value:
Type=Window;Name=frmMain
抓出来的是当前窗口的一些信息

2. To find the immediate parent of the tree view item Bach:
Result=SQAGetProperty("Name=treMain;\;ItemText=Bach","ParentRecognition",value)
Returned value:
Type=TreeView;Name=treMain
抓出来的是树型结构的父结点的信息

3. To find the complete object path of the tree view item Bach, beginning with the desktop and ending with the target object itself:
Result=SQAGetProperty("Name=treMain;\;ItemText=Bach","FullRecognition",value)
Returned value:
Type=Window;Name=frmMain;\;Type=TreeView;Name=treMain;\;Type=TVItem;ItemText=Bach
抓出来的是树型结构中指向该控件的全部路径

Rational Robot中自动进行100次操作
Rational Robot中的SQA Basic与Basic语言极为类似,下面是一个for循环的例子,其中cstri()函数把整数转换成字符串。
Sub Main
    Dim Result As Integer
    Dim i As Integer
    ……
  
     'begin of for loop
     for i=1 to 100 step 1
     ……
     InputKeys cstr(i*3) '这个地方设置输入值为I*3.
     ……
    next
    'end of for loop
    ……
End Sub

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/

TAG: robot Robot String 函数 讲解 实例

31/3123>

关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网