提示框,在脚本中如何判断这个脚本出现了?
在WinRunner自带得软件中,进入open order界面,输入ordernum为100,点击OK,出现提示框,在脚本中如何判断这个脚本出现了? 太模糊,看了半天没看明白 在数据驱动脚本中,ordernum的数据是1,6,100,8系统运行1和6没有问题,运行到100时,由于系统没有ordernum为100得数据,系统给予一个提示框,这时系统报错
解决办法是:写tsl跳过这个提示框,这时就要判断这个提示框是否存在 table = "lsson8.xls";
rc = ddt_open(table, DDT_MODE_READ);#ddt_open(data_table_name [ , mode ] =>mode分为DDT_MODE_READ(read-only)、DDT_MODE_READWRITE (read or write)。mode 默认为DDT_MODE_READ
if (rc!= E_OK && rc != E_FILE_OPEN)#E_OK 0 Operation successful---E_FILE_OPEN -10007 Cannot open file. File may already be open.
pause("Cannot 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", 3);
menu_select_item ("File;Open Order...");
# Open Order
set_window ("Open Order", 1);
button_set ("Order No.", ON);
edit_set ("Edit_1", ddt_val(table,"Order_Num"));
button_press ("OK");
wait(1);
if(win_exists("Flight Reservations")!=E_OK)
{
# Flight Reservation
set_window ("Flight Reservation", 3);
menu_select_item ("File;Fax Order...");
# Fax Order No. 3
set_window ("Fax Order No. 3", 1);
edit_get_text("# Tickets:",tickets);
edit_get_text("Ticket Price:",price);
edit_get_text("Total:",total);
#tl_step ( step_name, status, description );把测试脚本分成几块,并在当前测试结果里插入状态信息
#Set to 0 for pass, or any other integer for failure.
if(tickets*price==total)
tl_step("总计测试",0,"正确.Order_Num为"ddt_val(table,"Order_Num")":"tickets" 张票,每张 $ "price",总计 $"total".");
else
tl_step("总计测试",1,"Error.Order_Num为"ddt_val(table,"Order_Num")":"tickets" tickets at $ "price" does not equal $"total".");
button_press ("Cancel");
}
else
{
report_msg("Order_Num为"ddt_val(table,"Order_Num")"查询不到数据");
set_window ("Flight Reservations", 3);
button_press ("确定");
set_window ("Open Order", 3);
button_press ("Cancel");
}
}
ddt_close(table); 之前代码差不多也是这样,但是不成功,加了wait(1),就可以了,不知道为什么 #4
直接在win_exists( window [, time ] )中加个延迟时间
if (win_exists ("Flight Reservations",5)==E_OK)
{...}
这样就可以了
[ 本帖最后由 liujinkui 于 2009-7-31 13:42 编辑 ] :)
页:
[1]