UFT自动化脚本关键字用法简介
来源:互联网 发布:js给tbody添加行 编辑:程序博客网 时间:2024/04/29 17:48
一、split拆分字符串
函数调用格式:split(expression,delimiter,count,compare)
参数:
Expression为需要拆分的字符串
Delimiter为字符串中的某个字符,用来识别子串的拆分位置
Count为需要返回的子串的个数,-1意味着返回所有子串
Compare为0时是根据二进制方式匹配,为1时为文本方式匹配
示例:
Dim MyString,MyArray, Msg
MyString = "VBScriptXisXfun!"
MyArray = Split(MyString, "x", -1, 1)
' MyArray(0) contains "VBScript".
' MyArray(1) contains "is".
' MyArray(2) contains "fun!".
Msg = MyArray(0) & " " & MyArray(1)
Msg = Msg & " " & MyArray(2)
MsgBox Msg
二、Date获取当前系统日期
示例:
Dim MyDate
MyDate = Date ' MyDate contains the current system date.
三、Mid截取字符
函数调用格式:mid(string,start,length)
参数:
string为需要截取的字符串
start为开始位置
length为需要截取的长度
示例:
Dim myvar
Myvar = mid(“VBScript”,3,6) ‘myvar为“Script”
四、Time返回当前系统时间
示例:
Dim mytime
mytime = Time
五、CreateObject创建并返回一个自动对象的指针
函数调用格式:CreateObject(servername.typename,location)
参数:
servername为应用对象的名字
typename为需要创建对象的类型
location为将要创建对象所在网络服务器的名字
示例1:
,创建一个Microsoft Excel sheet 对象
Dim ExcelSheet
Set ExcelSheet = CreateObject("Excel.Sheet")
,设置相应属性和方法
' Make Excel visiblethrough the Application object.
ExcelSheet.Application.Visible = True
' Place some text inthe first cell of the sheet.
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This iscolumn A, row 1"
' Save the sheet.
ExcelSheet.SaveAs "C:\DOCS\TEST.XLS"
' Close Excel withthe Quit method on the Application object.
ExcelSheet.Application.Quit
' Release the objectvariable.
Set ExcelSheet = Nothing
示例2: '======================================================= '功能名: TestResultLog
'目的: 将输入成功与否的日志输入到日志文件中
'输入参数: judgment,UserName
'=======================================================
Sub TestResultLog(judgment,UserName)
Dim strSuccess,strFail,fso,myfile,strTime
strTime="[" & date & "" & mid(time,1,5) & "]"
strSuccess=strTime & "账户“" & UserName & "登录成功"
strFail=strTime & "账户“" & UserName & "登录失败"
Set fso=CreateObject("Scripting.FileSystemObject")
'判断文件是否存在,如果存在打开,否则创建
If (fso.FileExists("F:\Test_Result_Log\TestResult_log.txt")) Then
'定义常量intCode,作为打开文件函数的参数,防止写入数据是Unicode编码乱码
Const intCode=-1
Set myfile=fso.OpenTextFile("F:\Test_Result_Log\TestResult_log.txt",8,true,intCode)
else
Set myfile=fso.CreateTextFile("F:\Test_Result_Log\TestResult_log.txt",2,true)
End If
If judgment Then
myfile.WriteLine strSuccess
else
myfile.WriteLine strFail
End If
myfile.Close
set myfile=nothing
set fso=nothing
End Sub
- UFT自动化脚本关键字用法简介
- UFT脚本
- UFT脚本
- UFT(Unified Function Testing)自动化测试工具简介
- 自动化脚本之关键字驱动脚本
- 自动化测试工具-UFT
- UFT自动化测试框架
- 传递脚本到UFT
- UFT VB脚本
- UFT的工具简介
- UFT工具简介
- HP UFT简介
- UFT的工具简介
- 2-UFT简介
- 自动化测试软件UFT实验
- UFT中表的用法
- Oracle rollup 关键字用法简介.
- UFT关键字视图的优缺点
- 【项目2-3 - 上三角矩阵——第9周】
- Maven 搭建 SpringMVC
- 函数将数组扩大一倍
- [sicily]1443. Printer Queue
- NYOJ 21 三个水杯(bfs)
- UFT自动化脚本关键字用法简介
- 今天你慕课了吗?
- 关于Python的super用法研究(转)
- phpstrom+xdebug 配置
- Java虚拟机基础知识
- 《leetCode》:Integer to Roman
- 图像处理与计算机视觉:基础,经典以及最近发展(2)图像处理与计算机视觉相关的书籍
- 怎么做一名合格的测试工程师
- window常用命令45个!