数据驱动的问题
脚本:# Shell_TrayWnd
set_window ("Shell_TrayWnd", 1);
toolbar_button_press("ToolbarWindow32_0","Stop");
wait(2);
# WorkerW
set_window ("WorkerW", 1);
list_activate_item ("SysListView32", "Flight 4A (2)");
wait(4);
# Login
set_window ("Login", 4);
edit_set ("Agent Name:", "mercury");
password_edit_set("Password:", "kzptnyoslzjsaz");
button_press ("OK");
wait(7);
table="C:\Documents and Settings\Administrator\My Documents\lesson7\Book1.xls";
rc=ddt_open(table,DDT_MODE_READ);
if (rc!=E_OK && rc!=E_FILE_OPEN)
pause("cann,t open table");
ddt_get_row_count(table,table_RowCount);
for(table_Row = 1;table_Row<=table_RowCount;table_Row ++)
{
ddt_set_row(table,table_Row);
# Flight Reservation
set_window ("Flight Reservation", 9);
menu_select_item ("File;Open Order...");
wait(1);
# Open Order
set_window ("Open Order", 1);
button_set ("Order No.", ON);
#pause(ddt_val(table,"A"));
edit_set ("Edit", ddt_val(table,"A"));
button_press ("OK");
wait(1);
# Flight Reservation
set_window ("Flight Reservation", 8);
menu_select_item ("File;Fax Order...");
wait(4);
# Fax Order No. 3
aa="Fax Order No. "&ddt_val(table,"A");
pause(aa);
form=set_window (aa, 8);
if (form!=E_OK && form!=E_FILE_OPEN)
pause("error");
wait(2);
s=edit_get_text("# Tickets:",tickets);
if (s!=E_OK && s!=E_FILE_OPEN)
pause("error");
t=edit_get_text("Ticket Price:",price);
t=edit_get_text("Total:",total);
pause(tickets);
pause(price);
pause(total);
if (tickets*price==total)
tl_step("total",0,"Total is correct");
else
tl_step("total",1,"Total is not incorrect");
wait(1);
button_press ("Cancel");
}
ddt_close(table);
我在default.xls中加了两个数据 3,1
第一次循环读取3,运行正常
第二次循环读取1,运行到form=set_window (aa, 8);这句话后,pause("error");就会打印出error,这是为什么呢?如何修改呢?请指教 观察一下有没有这个窗体,估计是窗体名不对. 窗体是能看见,也打开了 测试结果文件中显示的是
51 context sensitive error--- obj_get_info:"Fax Order No. 2" Object is not in the GUI map.00:00:58
51 context sensitive error--- set_window:"Fax Order No. 2" Object is not in the GUI map.00:00:58
54 stop run pause lesson7 00:01:02
55 start run run lesson7 00:01:49
57 context sensitive error--- edit_get_text:"# Tickets:" Object is not in the GUI map.00:01:51
60 context sensitive error--- edit_get_text:"Ticket Price:" Object is not in the GUI map.00:01:56
61 context sensitive error--- edit_get_text:"Total:" Object is not in the GUI map.00:01:56
74 tl_step --- Step: total, Status: Fail, Description: Total is not incorrect00:02:04
76 context sensitive error--- button_press:"Cancel" Object is not in the GUI map.00:02:05
80 stop run fail lesson7 00:02:05 我知道了,是你的对象没有保存,你要把对象库SAVE一下. 我保存了一下,然后在gui文件中添加了另一个窗体对象及其中用到的对象,就可以了.
多谢版主
我用循环就是为了方便,可是每个循环都要手动在gui文件中添加相应的对象,请问有没有更方便的办法? 建议使用描述性编程,请参照http://bbs.51testing.com/thread-84070-1-1.html 好的,我去学习一下,不胜感激
页:
[1]