1.GetCellData函数
作用:获取单元格的值
例:
rowCount = Browser("xxx ").Page("xxx ").Frame("xxx").WebTable("xxx").RowCount For counter = 1 To rowCount text = Browser("xxx").Page("xxx").Frame("xxx").WebTable("xxx").GetCellData(counter,1) If (text = "xxx") Then counter = counter - 1 selectNO = "#" & counter Browser("xxx").Page("xxx").Frame("xxx").WebRadioGroup("xxx").Select selectNO Exit For End If Next |
2.把值插入datatable里
例:
datatable.setcurrentrow(i) datatable.value("name","Global")="name" datatable.value("passwd","Global")="passwd" |
3.用代码来启动浏览器
Browser1 = "IE" StartURL = "www.51testing.com" IF Browser1 = "IE" THEN set IE = CreateObject("InternetExplorer.Application") IE.Visible = true IE.Navigate StartURL END IF |
4.ExecuteFile函数
作用:ExecuteFile 可以直接执行vbs文件,而不需要将其导入resource中
ExecuteFile FileName
说明:where FileName is the absolute or relative path of your VBscrīpt file.
例:ExecuteFile("F:\test.vbs")
5.Strcomp函数
作用:比较文本
例:
dim strtext1,strtext2,str ,str1,comp1 strtext1 = "xxx" strtext2 = "xxx" str = VbWindow("xxx").VbWindow("xxx").VbLabe1("xxx").GetTOProperty("text") str1= VbWindow("xxx").VbWindow("xxx").VbLabel("xxx").GetTOProperty("text") comp1=strcomp(strtext1,str,0) If comp=0 Then msgbox “这两个串相等” else msgbox str End If |
6.CaptureBitmap
作用:捕获屏幕
7. GetROProperty
作用:取对象属性值
例:VbWindow("xxx").VbWindow("xxx").VbWindow("xxx").ActiveX("xxx").GetROProperty("TextMatrix(1,0)")
8.ExitAction - 退出当前操作,无论其循环属性如何。
ExitActionIteration - 退出操作的当前循环。
ExitRun - 退出测试,无论其循环属性如何。
ExitGlobalIteration - 退出当前全局循环。
9.如何使用Excel对象处理数据?
Dim xl 打开excel文件 Function OpenExcelFile(strFilePath) Set xl = CreateObject("Excel.Application") xl.Workbooks.Open strFilePath End Function 获得指定单元格数据 Function GetCellData(strSheet,rwIndex,colIndex) GetCellData = xl.WorkSheets(strSheet).Cells(rwIndex,colIndex) End Function 填充单元格数据 Function PutCellData(strSheet,rwIndex,colIndex,varData) xl.WorkSheets(strSheet).Cells(rwIndex,colIndex) = varData End Function 保存并推出 Function SaveAndQuit() xl.Activeworkbook.save xl.Quit Set xl = nothing End Function |
10.连接sql数据库
例:
Dim res,cmd,sql Set Res=createobject("adodb.recordset") Set Cmd=createobject("adodb.command") Cmd.activeconnection="Provider=SQLOLEDB.1;Password=111111;Persist Security Info=True;User ID=sa;Initial Catalog=xhq;Data Source=192.168.191.142" '这句话是连接数据库的数据源,要做修改 Cmd.CommandType = 1 sql="selec t * from 表 where name=username" Cmd.CommandText = sql Set res = Cmd.Execute() Set res = nothing Set cmd.ActiveConnection = nothing Set Cmd= nothing |