'''''''''''''''''''''''''''''''
'一个简单的架构练习
'数据驱动的一个简单练习
'作者:limenglei321
'''''''''''''''''''''''''''''''
'config的Function 模块,主要是从xls表中取的参数再传递
config
Function config
' 创建ADO
Set conn= createobject("ADODB.Connection")
' 打开链接
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\51testing\桌面\login.xls;Extended Properties=Excel 8.0"
' 查询
sql= "SELECT * FROM [ADOExcel$]"
Set RecSet = conn.Execute(sql)
' RecSet.MoveFirst
named= RecSet.Fields("username").Value
word=RecSet.Fields("password").Value
' RecSet.MoveNext
Parameter("user")=named
Parameter("pass")=word
conn.close
End Function
'config_open的Function 模块,主要是从xls表中取的参数再传递
config_open
function config_open
' 创建ADO
Set conn= createobject("ADODB.Connection")
' 打开链接
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\51testing\桌面\open.xls;Extended Properties=Excel 8.0"
' 查询
sql= "SELECT * FROM [ADOExcel$]"
Set RecSet = conn.Execute(sql)
' RecSet.MoveFirst
orderno= RecSet.Fields("order no").Value
parameter("number")=orderno
conn.close
end function
'一个主调模块
main
Function main
systemutil.CloseProcessByName("flight4a.exe")
SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
RunAction "Action_login", oneIteration
RunAction "Action_insert", oneIteration
RunAction "Action_open", oneIteration
End Function
'Action_login是登陆模块
RunAction "Action_login_config", oneIteration
username=parameter("Action_login_config","user")
password=parameter("Action_login_config","pass")
'msgbox username
'msgbox password
Dialog("Login").WinEdit("Agent Name:").Set username
Dialog("Login").WinEdit("Agent Name:").Type micTab
Dialog("Login").WinEdit("Password:").SetSecure password
Dialog("Login").WinButton("OK").Click
'Action_open是查询的一个模块
wait 7
RunAction "Action_open_config", oneIteration
num=parameter("Action_open_config","number")
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").Click 19,137
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set num
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
'这里没有给Action_insert模块设置单个config,直接访问xls表中的数据
' 创建ADO
Set con= createobject("ADODB.Connection")
' 打开链接
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\51testing\桌面\insert.xls;Extended Properties=Excel 8.0"
' 查询
sql= "SELECT * FROM [ADOExcel$]"
Set RecSet = con.Execute(sql)
' RecSet.MoveFirst
data= RecSet.Fields("data").Value
flyfrom=RecSet.Fields("flyfrom").Value
flyto=RecSet.Fields("flyto").Value
table=RecSet.Fields("table").Value
named=RecSet.Fields("name").Value
num=RecSet.Fields("num").Value
Window("Flight Reservation").ActiveX("MaskEdBox").Type data
Window("Flight Reservation").WinComboBox("Fly From:").Select flyfrom
Window("Flight Reservation").WinComboBox("Fly To:").Select flyto
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select table
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set named
Window("Flight Reservation").WinRadioButton("First").Set
Window("Flight Reservation").WinEdit("Tickets:").SetSelection 0,1
Window("Flight Reservation").WinEdit("Tickets:").Set num
Window("Flight Reservation").WinButton("Insert Order").Click
con.close