winrunner的基本操作

来源:互联网 发布:淘宝开直通车有效果吗 编辑:程序博客网 时间:2024/05/22 00:11

(1),先在Winrunner里建一个脚本(这里以http://www.newtours.demoaut.com的订购飞机票为例)

(2),点击Record开始录制,

for (i=1; i<5; i++)
 
{
# Shell_TrayWnd
 set_window ("Shell_TrayWnd", 3);
 toolbar_button_press ("ToolbarWindow32_0_1", "启动 Internet Explorer 浏览器"); # Button Number 0;

# Browser Main Window
 set_window ("Browser Main Window", 29);
 list_select_item("browser_main_combo_location","http://www.newtours.demoaut.com");

# Welcome: Mercury Tours
 set_window("Welcome: Mercury Tours",11);
 edit_set("userName","pc8");
 obj_type("userName","<kTab>");
 password_edit_set("password","ca7121aa614993e5");
 obj_type("password","<kReturn_E>");
 web_image_click("login", 35, -52);

# Find a Flight: Mercury Tours:
 set_window("Find a Flight: Mercury Tours:",23);
 list_select_item("passCount",i);(把4改成变量i)
 web_image_click("findFlights", 55, 12);

# Select a Flight: Mercury Tours
 set_window("Select a Flight: Mercury Tours",3);
 web_image_click("reserveFlights", 62, 13);
switch (i) {
case"1":
 # Book a Flight: Mercury Tours
 set_window("Book a Flight: Mercury Tours",5);
 edit_set("passFirst0","1");
 edit_set("passLast0","1");
 break;
 
 case"2":
 # Book a Flight: Mercury Tours
 set_window("Book a Flight: Mercury Tours",5);
 edit_set("passFirst0","1");
 edit_set("passLast0","1");
 edit_set("passFirst1","2");
 edit_set("passLast1","2");
 break;
 
    case"3":
 # Book a Flight: Mercury Tours
 set_window("Book a Flight: Mercury Tours",5);
 edit_set("passFirst0","1");
 edit_set("passLast0","1");
 edit_set("passFirst1","2");
 edit_set("passLast1","2");
 edit_set("passLast2","3");
 edit_set("passFirst2","3");
  break;
  
case"4":
# Book a Flight: Mercury Tours
 set_window("Book a Flight: Mercury Tours",5);
 edit_set("passFirst0","1");
 edit_set("passLast0","1");
 edit_set("passFirst1","2");
 edit_set("passLast1","2");
 edit_set("passLast2","3");
 edit_set("passFirst2","3");
 edit_set("passFirst3","4");
 edit_set("passLast3","4");
 edit_set("creditnumber","123456");
 web_image_click("buyFlights", 57, 8);
 break;
 }
# Browser Main Window
 win_close ("Browser Main Window");
}

 

(3)加个for语句的变量,自动往下订购。

for (i=1; i<5; i++)
 
{
# Shell_TrayWnd
 set_window ("Shell_TrayWnd", 3);
 toolbar_button_press ("ToolbarWindow32_0_1", "启动 Internet Explorer 浏览器"); # Button Number 0;

# Browser Main Window
 set_window ("Browser Main Window", 29);
 list_select_item("browser_main_combo_location","http://www.newtours.demoaut.com");

# Welcome: Mercury Tours
 set_window("Welcome: Mercury Tours",11);
 edit_set("userName","pc8");
 obj_type("userName","<kTab>");
 password_edit_set("password","ca7121aa614993e5");
 obj_type("password","<kReturn_E>");
 web_image_click("login", 35, -52);

# Find a Flight: Mercury Tours:
 set_window("Find a Flight: Mercury Tours:",23);
 list_select_item("passCount",i);
 web_image_click("findFlights", 55, 12);

# Select a Flight: Mercury Tours
 set_window("Select a Flight: Mercury Tours",3);
 web_image_click("reserveFlights", 62, 13);

for (j=0; j<i; j++)

{
 # Book a Flight: Mercury Tours
 set_window("Book a Flight: Mercury Tours",5);
 edit_set("passFirst"&j,"1"&j);
 edit_set("passLast"&j,"1"&j);
 edit_set("creditnumber","123456");
 web_image_click("buyFlights", 57, 8);

 }
# Browser Main Window
 win_close ("Browser Main Window");
}

原创粉丝点击