|
本人在写一个脚本的时候,碰到一个问题,一直难以理解,特向各位大虾求教.
我的脚本中写了一个Exception Handle Function,结构如下
static function Error_Handler(in window)
{
extern excp_flag;
auto err_message;
CaptureImg(capture_file);
excp_flag=1;
if(window=="Error")
{
exception_off("Error_handle");
# excp_flag=1;
set_window(window,SYS_EIGHT);
if(obj_exists("st_message")==E_OK)
static_get_text ( "st_message", err_message );
tl_stepm("Make Subscription",1,"Record execution failed!--in row "& table_Row&",error message:"&err_message);
button_press ("pb_ok" );
Cursor_Wait();
exception_on("Error_handle");
}
else if(window=="Edit Pattern Validation Error")
{
exception_off("Validation_Error_handle");
# excp_flag=1;
set_window(window,SYS_EIGHT);
if(obj_exists("st_message")==E_OK)
static_get_text ("st_message", err_message );
tl_stepm("Make Subscription",1,"Record execution failed!--in row "& table_Row&",error message:"&err_message);
button_press ("pb_ok" );
Cursor_Wait();
exception_on("Validation_Error_handle");
}
else if(window=="Pop_window")
{
exception_off("Popup_Error_handle");
# excp_flag=1;
set_window(window,SYS_EIGHT);
if(obj_exists("st_message")==E_OK)
static_get_text ("st_message", err_message );
tl_stepm("Make Subscription",1,"Record execution failed!--in row "& table_Row&",error message:"&err_message);
button_press ("pb_ok" );
Cursor_Wait();
exception_on("Popup_Error_handle");
}
}
exception_off_all();
define_popup_exception("Error_handle","Error_Handler","Error");
define_popup_exception("Validation_Error_handle","Error_Handler","Edit Pattern Validation Error");
define_popup_exception("Popup_Error_handle","Error_Handler","Pop_window");
exception_on("Error_handle");
exception_on("Validation_Error_handle");
exception_on("Popup_Error_handle");
然后在脚本中有一段
edit_set_ex("e_fundcode",Record["I_Fundcode"]);
if (excp_flag==1)
{
excp_flag=0;
report_msg("Fund code is not correct");
continue;
}
这里edit_set_ex就是往Edit中输入数据,这个时候可能会有Popup Window 出来
当我运行脚本的时候发现,每次popup window出来的时候,Exception Handle函数都能工作
但是就是excp_flag不是1
WinRunner的脚本是异步而不是同步执行的,也就是说edit_set_ex("e_fundcode",Record["I_Fundcode"]);执行了之后
不是先去执行 Exception Handle函数,再执行if (excp_flag==1),而是两者好像同时执行,这就是我感觉到不可理解的地方
如果这样的话,我的脚本里面怎么能够做到出错处理完了之后再根据条件进行下一步的操作呢?
我的WinRunner 是7.5 |
|