读取文件没有循环:
# Flight Reservation
win_activate ("Flight Reservation");
set_window ("Flight Reservation", 5);
file_open("C:\\Win_execirses\\Dat2.txt",FO_MODE_READ);
file_getline("C:\\Win_execirses\\Dat2.txt",line);
split(line,array,";");
obj_type ("MSMaskWndClass",array[1]);
list_select_item ("Fly From:",array[2]); # Item Number 0;
list_select_item ("Fly To:", array[3]); # Item Number 0;
obj_mouse_click ("FLIGHT", 32, 45, LEFT);
# Flights Table
set_window ("Flights Table", 2);
button_press ("OK");
# Flight Reservation
set_window ("Flight Reservation", 8);
edit_set ("Name:", array[4]);
button_set ("First", ON);
button_press ("Insert Order");
set_window ("Flight Reservation", 8);
obj_mouse_click ("Button", 7, 13, LEFT);
#obj_mouse_click ("Button_4", 12, 11, LEFT);
file_close("C:\\Win_execirses\\Dat2.txt");
优化上面脚本,带有循环驱动:
# Flight Reservation
win_activate ("Flight Reservation");
set_window ("Flight Reservation", 5);
file_open("C:\\Win_execirses\\Dat2.txt",FO_MODE_READ);
while(file_getline("C:\\Win_execirses\\dat2.txt",line)==0)
{
#file_getline("C:\\Win_execirses\\Dat2.txt",line);
split(line,array,";");
obj_type ("MSMaskWndClass",array[1]);
list_select_item ("Fly From:",array[2]); # Item Number 0;
list_select_item ("Fly To:", array[3]); # Item Number 0;
obj_mouse_click ("FLIGHT", 32, 45, LEFT);
# Flights Table
set_window ("Flights Table", 2);
button_press ("OK");
# Flight Reservation
set_window ("Flight Reservation", 8);
edit_set ("Name:", array[4]);
button_set ("First", ON);
edit_set ("Tickets:", array[5]);
button_press ("Insert Order");
set_window ("Flight Reservation", 8);
# Flight Reservation
set_window ("Flight Reservation", 4);
obj_mouse_click ("Button", 18, 10, LEFT);
#obj_mouse_click ("Button_4", 12, 11, LEFT);
}
file_close("C:\\Win_execirses\\Dat2.txt");
'$include "SQAutil.sbh"
Sub Main
Dim dp_Result As Integer
dim dp_id as long
'dim dp_result as string
dim dp_Date as string
dim dp_Flyfrom as string
dim dp_Flyto as string
dim dp_Name as string
dp_id = SQAdatapoolopen("datapooltest1",FALSE, SQA_DP_SEQUENTIAL,FALSE)
dp_result = SQAdatapoolfetch (dp_id)
Window SetContext, "Caption=Flight Reservation", ""
dp_result = SQAdatapoolvalue (dp_id,1,dp_Date)
InputKeys dp_Date
ComboBox Click, "ObjectIndex=1", "Coords=120,13"
dp_Result=SQADatapoolvalue(dp_id,2,dp_Flyfrom)
ComboListBox Click, "ObjectIndex=1", "Text="&dp_Flyfrom
ComboBox Click, "ObjectIndex=2", "Coords=117,8"
dp_result=SQADatapoolvalue(dp_id,3,dp_Flyto)
ComboListBox Click, "ObjectIndex=2", "Text="&dp_Flyto
PushButton Click, "Text=FLIGHT"
Window SetContext, "Caption=Flights Table", ""
'ListBox Click, "ObjectIndex=1", "Text=16877 LAX 08:00 AM LON 08:45 AM SR $162.30;Coords=272,23"
PushButton Click, "Text=OK"
Window SetContext, "Caption=Flight Reservation", ""
dp_result = SQAdatapoolvalue (dp_id,4,dp_Name)
InputKeys dp_Name
PushButton Click, "Text=Insert Order"
PushButton Click, "ObjectIndex=9"
dp_result=SQADatapoolClose (dp_id)
End Sub
数据驱动脚本-数据池技术 优化版本:
'$include "SQAutil.sbh"
Sub Main
Dim dp_Result As Integer
dim dp_id as long
'dim dp_result as string
dim dp_Date as string
dim dp_Flyfrom as string
dim dp_Flyto as string
dim dp_Name as string
dim i as integer
dp_id = SQAdatapoolopen("datapooltest1",FALSE, SQA_DP_SEQUENTIAL,FALSE)
for i = 1 to 3
dp_result = SQAdatapoolfetch (dp_id)
Window SetContext, "Caption=Flight Reservation", ""
dp_result = SQAdatapoolvalue (dp_id,1,dp_Date)
InputKeys dp_Date
ComboBox Click, "ObjectIndex=1", "Coords=120,13"
dp_Result=SQADatapoolvalue(dp_id,2,dp_Flyfrom)
ComboListBox Click, "ObjectIndex=1", "Text="&dp_Flyfrom
ComboBox Click, "ObjectIndex=2", "Coords=117,8"
dp_result=SQADatapoolvalue(dp_id,3,dp_Flyto)
ComboListBox Click, "ObjectIndex=2", "Text="&dp_Flyto
PushButton Click, "Text=FLIGHT"
Window SetContext, "Caption=Flights Table", ""
'ListBox Click, "ObjectIndex=1", "Text=16877 LAX 08:00 AM LON 08:45 AM SR $162.30;Coords=272,23"
PushButton Click, "Text=OK"
Window SetContext, "Caption=Flight Reservation", ""
dp_result = SQAdatapoolvalue (dp_id,4,dp_Name)
InputKeys dp_Name
PushButton Click, "Text=Insert Order"
PushButton Click, "ObjectIndex=9"
next i
dp_result=SQADatapoolClose (dp_id)
End Sub
数据驱动 - 文件技术:
Sub Main
Dim date1 as string
Dim flyfrom as string
Dim flyto as string
Dim name1 as string
Dim file as string
file="C:\Rational_files\datafile1.txt"
open file for input access read as #1
while not eof(1)
Input #1, date1,flyfrom,flyto,name1
Window SetContext, "Caption=Flight Reservation", ""
InputKeys date1
ComboBox Click, "ObjectIndex=1", "Coords=108,15"
ComboListBox Click, "ObjectIndex=1", "Text="&flyfrom
ComboBox Click, "ObjectIndex=2", "Coords=118,11"
ComboListBox Click, "ObjectIndex=2", "Text="&flyto
PushButton Click, "Text=FLIGHT"
Window SetContext, "Caption=Flights Table", ""
PushButton Click, "Text=OK"
Window SetContext, "Caption=Flight Reservation", ""
InputKeys name1
PushButton Click, "Text=Insert Order"
PushButton Click, "ObjectIndex=9"
wend
close #1
End Sub