从QTP参数化到WR参数化

上一篇 / 下一篇  2008-07-03 09:48:37

前几天看了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", "2612   DEN   08:57 AM   LAX   09:55 AM   NW     $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"的对象,但这个对象的物理描述是变化的,所以每次点击都不一样。


TAG: qtp QTP 参数

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2011-05-25  
1234567
891011121314
15161718192021
22232425262728
293031    

我的存档

数据统计

  • 访问量: 753
  • 日志数: 6
  • 建立时间: 2008-07-02
  • 更新时间: 2008-07-03

RSS订阅

Open Toolbar