参数化的三种方式

上一篇 / 下一篇  2013-01-04 08:55:06

不必对说 直接上码
 
''############講EXCEL導入到datatable中進行參數化###################
DataStr= "d:\login.xls"
DataTable.AddSheet("TestData")
DataTable.ImportSheet DataStr,"Sheet1","TestData"
wait 1
For i=1 to DataTable.GetSheet("TestData").GetRowCount
systemutil.Run "D:\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
DataTable.SetCurrentRow i
UserName=DataTable.Value("UserName","TestData")
PassWord=DataTable.Value("PassWord","TestData")
Dialog("Login").WinEdit("Agent Name:").Set UserName
Dialog("Login").WinEdit("Password:").SetSecure PassWord
wait 1
Dialog("Login").WinButton("text:=OK").Click
Next
 
 

''############講EXCEL的值直接參數化###################
filepath="D:\login.xls"
Set myexcel=createobject("Excel.application")
myexcel.Visible=false
Set book=myexcel.Workbooks.Open(filepath)
Set sheet=book.Worksheets("Sheet1")
For i=2 to sheet.usedrange.rows.count
user=sheet.Cells(i,1)
pwd=sheet.Cells(i,2)
systemutil.Run "D:\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set user
Dialog("Login").WinEdit("Password:").SetSecure pwd
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close
Next
myexcel.Quit
Set myexcel=nothing
 

''############鏈接到數據庫,講字段值綁定參數化###################
strDB="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=PCEWH-IT-147\YINLU;Initial Catalog=testDB;Data Source=PCEWH-IT-147\YINLU"
strTableName="login"
Set Conn=createobject("adodb.connection")
Set Rst=createobject("adodb.recordset")
Conn.open strDB
msgbox conn.state
Rst.open "select * from login",conn
msgbox Rst.State
Rst.MoveFirst
Do while not Rst.EOF
systemutil.Run "D:\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
struser=trim(cstr(Rst.Fields("username")))
strpwd=trim(cstr(Rst.Fields("password")))
Dialog("Login").WinEdit("Agent Name:").Set struser
Dialog("Login").WinEdit("Password:").SetSecure strpwd
Rst.MoveNext
wait 2
Dialog("Login").WinButton("text:=OK").Click
window("Flight Reservation").Close
Loop
Rst.close
Set Conn=nothing

TAG:

 

评分:0

我来说两句

日历

« 2024-05-12  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 1465
  • 日志数: 3
  • 建立时间: 2012-09-24
  • 更新时间: 2013-01-04

RSS订阅

Open Toolbar