从QTP参数化到WR参数化
前几天看了xiaonan和gp_jl对QTP参数化的讲解和实际应用的帖子,感觉方法不错,从另一个角度对回放过程中的对象参数化。这些天一直在做WR的学习,觉得WR与QTP对对象的识别很类似, 那么WR中应该也可以通过修改GUI文件(QTP中就是对象库)中逻辑名的物理识别属性达到参数化的效果,于是同样录制了flight例子,脚本及关键语句如下:
# Login
set_window ("Login", 4);
edit_set ("Agent Name:", "mercury");
obj_type ("Agent Name:","<kTab>");
password_edit_set("Password:", "kzptnyoslzjsaz");
obj_type ("Password:","<kReturn>");
# Flight Reservation
set_window ("Flight Reservation", 6);
edit_set ("Date of Flight:", "11/11/11");
list_select_item ("Fly From:", "Denver"); # Item Number 0;
list_select_item ("Fly To:", "Los Angeles"); # Item Number 2;
obj_mouse_click ("FLIGHT", 25, 29, LEFT);
# Flights Table
set_window ("Flights Table", 1);
list_select_item ("Flight", "2612DEN08:57 AMLAX09:55 AMNW $130.80"); # Item Number 2;
button_press ("OK");
# Flight Reservation
set_window ("Flight Reservation", 5);
edit_set ("Name:", "dionysus");
# rc = GUI_buf_get_desc_attr(".\\gui.gui","Flight Reservation","First","label",x); # GUI_buf_get_desc_attr()函数可以得到某一个对象的属性值
# pause(x);
for(i=1;i<=3;i++)
{
switch(i)
{
case 1:
{
val = "First";
break; #一定要有这个break语句
}
case 2:
{
val = "Business";
break;
}
case 3:
{
val = "Economy";
break;
}
}
rc = GUI_buf_set_desc_attr(".\\gui.gui","Flight Reservation","First","label",val);
button_set ("First", ON);
wait(2);
}
button_press ("Insert Order");
最后回放的时候可以看到button_set函数点击逻辑名称为"Frist"的对象,但这个对象的物理描述是变化的,所以每次点击都不一样。
页:
[1]