『急!』如何让Robot在输入框中如实输入数据库中查询出来的内容
我现在写了一个脚本,是在一个页面做新增动作,新增的数据是从数据库中查询出来的,但是在回放脚本时,(假如此时我查出的数据是eric001),则robot只在输入框中输入数字信息:001,不会输入eric,这是怎么回事啊?望高手指教下面是我得脚本:
Sub Main
Dim Result As Integer
'Initially Recorded: 2005-4-1819:25:44
'Script Name: 123
'SQL脚本
Dim connection ,i As long
Dim retcode As Variant
dim outputstr,query as string
Dim out(1 To 1,1 to 2)As Variant
connection = SQLOpen("DSN=LocalServer;UID=sa;PWD=sa", outputstr,)
query = "select employeeid from PSNACCESSIONINFO"
retcode = SQLExecQuery(connection,query)
retcode = SQLRetrieve(connection,out())
i=1
while i<3
Window SetContext, "Caption=GameTest - Microsoft Internet Explorer", ""
Browser SetFrame,"Type=HTMLFrame;HTMLId=WorkSpace;\;Type=HTMLFrame;HTMLId=Disp",""
Browser NewPage,"HTMLTitle=3G游戏",""
EditBox Click, "Type=EditBox;Name=txtName", "Coords=84,9"
InputKeys out(1,i)
ComboBox Click, "Type=ComboBox;Name=ddlItemName", ""
ComboListBox Click, "Type=ComboListBox;Name=ddlItemName", "Text=game"
Browser NewPage,"HTMLTitle=3G手机",""
PushButton Click, "Type=PushButton;Name=cmdAdd"
Window SetContext, "Caption=Microsoft Internet Explorer", ""
PushButton Click, "Text=确定"
i=i+1
wend
retcode = SQLClose(connection)
End Sub 你把out()的定义还成string类型试试吧,因为inputkeys是对string类型的字符串起作用的 inputkeys输入的数据是 你数据库中的数据么?
如果是 那么他是第几行 第几列
然后再看是否代码逻辑问题
如果不是你数据库里面的数据,那么就 看看是否取得数据库的数据操作是否成功? Originally posted by 司空公子 at 2005-4-18 09:12 PM:
你把out()的定义还成string类型试试吧,因为inputkeys是对string类型的字符串起作用的
定义成string类型编译通不过
报错:Error: Type mismatch, parameter 2 in function 'SQLRetrieve'
就是代码中这行:retcode = SQLRetrieve(connection,out()) Originally posted by pcl2004_27 at 2005-4-19 01:11 AM:
inputkeys输入的数据是 你数据库中的数据么?
如果是 那么他是第几行 第几列
然后再看是否代码逻辑问题
如果不是你数据库里面的数据,那么就 看看是否取得数据库的数据操作是否成功?
inputkeys输入的数据是数据库中的数据,我是取的数据库中的第一列数据,从第一行开始,取2次
用代码msgbox测试时,是可以正常取出那一列头2行的数据的 自己先顶一下~ 脚本修改如下:
Sub Main
Dim Result As Integer
Dim strInputsas String
'Initially Recorded: 2005-4-1819:25:44
'Script Name: 123
'SQL脚本
Dim connection ,i As long
Dim retcode As Variant
dim outputstr,query as string
Dim out(1 To 1,1 to 2)As Variant
connection = SQLOpen("DSN=LocalServer;UID=sa;PWD=sa", outputstr,)
query = "select employeeid from PSNACCESSIONINFO"
retcode = SQLExecQuery(connection,query)
retcode = SQLRetrieve(connection,out())
i=1
while i<3
Window SetContext, "Caption=GameTest - Microsoft Internet Explorer", ""
Browser SetFrame,"Type=HTMLFrame;HTMLId=WorkSpace;\;Type=HTMLFrame;HTMLId=Disp",""
Browser NewPage,"HTMLTitle=3G游戏",""
EditBox Click, "Type=EditBox;Name=txtName", "Coords=84,9"
'$$$$$$$$$$$$$$$$$$$$4
‘修改代码
strInputs =out(1,i)
InputKeys strInputs
'$$$$$$$$$$$$$$$$$$$$$$$4
ComboBox Click, "Type=ComboBox;Name=ddlItemName", ""
ComboListBox Click, "Type=ComboListBox;Name=ddlItemName", "Text=game"
Browser NewPage,"HTMLTitle=3G手机",""
PushButton Click, "Type=PushButton;Name=cmdAdd"
Window SetContext, "Caption=Microsoft Internet Explorer", ""
PushButton Click, "Text=确定"
i=i+1
wend
retcode = SQLClose(connection)
End Sub
页:
[1]