发布新日志

  • Action级别的参数调用

    2006-12-14 18:15:00

    Action级别的参数调用:

    1、  设置参数

    Action  Properters >> Action Parameter

    增加input的参数和output的参数

     

    2、  Action 1 的脚本:

    parameter("output")="Action1 Output"

    msgbox("Action1 Input:"&parameter("input"))

    msgbox("Action1 Output:"&parameter("output"))

    3、  Action 2 的脚本:

    RunAction "Action1", oneIteration,"Action2 Input",action2

    msgbox("Output in Action2:"&action2)

     

    我们不难发现在QTPAction之间关系

    作为被调用Action1,都是使用parameter("参数名")来使用的。

    作为调用Action1Action2而言,input参数是可以往被调用Action1的操作输入的参数。Output的参数是从被调用的Action1返回的值。

    注:调试脚本

    http://blog.51testing.com/?3528/action_viewspace_itemid_1412.html

  • QTP中几个截取字符串的函数

    2006-12-14 10:01:22

    Left 函数(Right函数就是从右边开始算起)
    返回指定数目的从字符串的左边算起的字符。Left(string, length)
    参数
    string:字符串表达式,其最左边的字符被返回。如果 string 参数中包含 Null,则返回 Null。
    Length:数值表达式,指明要返回的字符数目。如果是 0,返回零长度字符串 ("");如果大于或等于 string 参数中的字符总数,则返回整个字符串。
    例子:
    Dim MyString, LeftString
    MyString = "VBscrīpt"
    LeftString = Left(MyString, 3) ' LeftString contains "VBS".
    ***********************************
    Mid 函数
    从字符串中返回指定数目的字符。
    Mid(string, start[, length])
    参数:
    string:字符串表达式,从中返回字符。如果 string 包含 Null,则返回 Null。
    Start:string 中被提取的字符部分的开始位置。如果 start 超过了 string 中字符的数目,Mid 将返回零长度字符串 ("")。
    Length:要返回的字符数。如果省略或 length 超过文本的字符数(包括 start 处的字符),将返回字符串中从 start 到字符串结束的所有字符。
    例子
    Dim MyVar
    MyVar = Mid("VB scrīpt is fun!", 4, 6) ' MyVar contains "scrīpt".
    ********************
    InStr函数(InStrRev函数相反从最后向前起)
    返回指定的字符串在另一字符串中最先出现的位置。
    InStr([start, ]string1, string2[, compare])
    参数:
    start:起始位置,默认从第一位
    string1:主体字符串,从左向右查找。如果string1为 Null,则返回 Null。
    string2:查找的字符串,如果string2为 Null,则返回 Null。找不到就返回0。
    compare:0是二进制比较,1是文本比较。0为缺省值。个人感觉区别就是在大小写。
    例子
    Dim SearchString, SearchChar, MyPos
    SearchString ="XXpXXpXXPXXP"   ' String to search in.
    SearchChar = "P"   ' Search for "P".
    MyPos = Instr(4, SearchString, SearchChar, 1)   ' A textual comparison starting at position 4. Returns 6.
    MyPos = Instr(1, SearchString, SearchChar, 0)   ' A binary comparison starting at position 1. Returns 9.   
    MyPos = Instr(SearchString, SearchChar)   ' Comparison is binary by default (last argument is omitted). Returns 9.
    MyPos = Instr(1, SearchString, "W")   ' A binary comparison starting at position 1. Returns 0 ("W" is not found).
    ******************
    Split 函数
    在指定的 delimiter 参数出现的所有位置断开 String 对象,将其拆分为子字符串,然后以数组形式返回子字符串。
    Split(expression[, delimiter[, count[, compare]]])
    参数
    expression:主体字符串,也就是要被拆分处的字符或字符串。
    delimiter:拆分元素,默认是(" ")
    count:Number [可选] 要放入数组中的项目数。
    compare:0是二进制比较,1是文本比较。0为缺省值。
    例子
    Dim MyString, MyArray, Msg
    MyString = "VBscrīptXisXfun!"
    MyArray = Split(MyString, "x", -1, 1)
    ' MyArray(0) contains "VBscrīpt".
    ' MyArray(1) contains "is".
    ' MyArray(2) contains "fun!".
    Msg = MyArray(0) & " " & MyArray(1)
    Msg = Msg   & " " & MyArray(2)
    MsgBox Msg
  • 在EXCEL里面添加超联接(hyperlink)的方法

    2006-12-12 10:35:58

    Sub ReportInformation(filename)
    ' create the Excel object
    Set ExcelObj = CreateObject("Excel.Application")
    ' add a new Workbooks and a new Sheet
    ExcelObj.Workbooks.Add
    Set NewSheet = ExcelObj.Sheets.Item(1)
    NewSheet.Name = "Page Information"
     ' customize the Sheet layout
    NewSheet.Cells(1,1).Value = "Tom"
    NewSheet.Cells(2,1).Value = "Sohu"
    NewSheet.Hyperlinks.Add NewSheet.Cells(1,1), "http://www.tom.com/"
    NewSheet.Hyperlinks.Add NewSheet.Cells(2,1), "http://www.sohu.com/"
     ' save the Excel file
          ExcelObj.ActiveWorkbook.SaveAs filename
          ' close the application and clean the object
          ExcelObj.Quit
          Set ExcelObj = Nothing
       End Sub
    call ReportInformation("c:\test.xls")

     


     

433/3<123
Open Toolbar