博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一段Winrunner的样例脚本
阅读量:7125 次
发布时间:2019-06-28

本文共 5820 字,大约阅读时间需要 19 分钟。

#########################################################################################################
#
# Test Name     : Date Boundary
# Subject          : Open Order Form
#
# Description    : Checks that the input of illegal values in the Flight Date is blocked and that error messages
#    appear.  The following input should be tested:
#     1. Flight Date Edit field is disabled when button is unchecked
#     2. Characters (not accepted)
#     3. More than six numbers (not accepted)
#     4. Less than six numbers (OK is disabled)
#     5. Invalid Month
#     6. Invalid date of the month
#     7. No entry
#
#
#########################################################################################################
#static variables:
static ret_val,date_str,i;
# Constant declaration
static const DISABLED = FALSE;
# Variable declaration.  Can be anything the user wants.
static date_string_of_chars  = "as/cd/ef";     # Used in STEP 2.  Characters (Not accepted).
static date_seven_numbers = "12/34/567"; # Used in STEP 3.  More than six numbers not accepted.
static date_invalid_month    = "13/20/95";   # Used in STEP 5.  Invalid month.
static date_invalid_day        = "12/32/95";   # Used in STEP 6.  Invalid date of month.
static lib_path = getvar("testname") & " ";
# Static function reinitialize ().  Reinitializes Flight Date to OFF and clears the edit field.
static function reinitialize ()
{
 auto ret_val;
 set_window ("Open Order");
 obj_get_info ("FlightDateEdit", "enabled", ret_val);
 if (ret_val == TRUE) {
     set_window ("Open Order");
  edit_set_insert_pos ("FlightDateEdit", 0, 0);
  type ("<kS_End_E><kDel_E>");
 }
}
# Static function insert_date ().  Inserts the date into the FlightDateEdit field.
static function insert_date (in date)
{
 set_window ("Open Order");
 edit_set_insert_pos("FlightDateEdit",0,0);
 type(date);
}
reload(lib_path);
# Open the flight application
rc = open_flight();
if (rc == E_GENERAL_ERROR){
  tl_step(initialization, FAIL,couldnt_open_flight);
 clean_up();
 texit;
}
 
# Initialization.
open_OpenOrderForm ();
# STEP 1.  Flight Date Edit is disabled
set_window ("Open Order");
# Checking to see if the edit field is disabled when button is unchecked
obj_get_info ("FlightDateEdit", "enabled", ret_val);
if (ret_val == DISABLED)
 tl_step (disabled, PASS, flight_date_disabled);
else
 tl_step (disabled, FAIL, flight_date_not_disabled);
reinitialize ();
# STEP 2.  Characters (not accepted)
button_set ("Flight Date", ON);
# Inserting a date of characters using variable, "date_string_of_chars", defined above.
insert_date (date_string_of_chars);
edit_get_text ("FlightDateEdit", date_str);
# Checking to see if application handled illegal open order procedure
if (date_str == "__/__/__")
 tl_step (characters, PASS, chars_not_accepted);
else
 tl_step (characters, FAIL, chars_accepted);
reinitialize ();
# STEP 3. More than six numbers (not accepted)
button_set ("Flight Date", ON);
# Inserting a date consisting of more than six numbers using variable, "date_seven_numbers", defined above.
insert_date (date_seven_numbers);
edit_get_text ("FlightDateEdit", date_str);
# Checking to see if application handled illegal open order procedure
if (date_str == "12/34/56")
 tl_step(more_than_six, PASS, more_than_six_not_accepted);
else
 tl_step(more_than_six, FAIL, more_than_six_accepted);
reinitialize ();
# STEP 4. Less than six numbers (OK is disabled)
edit_set_insert_pos ("FlightDateEdit", 0, 0);
# Using for_loop to systematically check if OK button is disabled for any date with less than six numbers in it
for (i = 1; i <= 6; i++) {
 type(i);
 if (button_check_enabled ("OK", TRUE) == E_OK)
  break;
}
#  The actual check to make sure that OK was disabled for date less than six numbers
ts_msg = sprintf(ok_not_disabled, i);
if (i < 6)
 tl_step (less_than_six, FAIL, ts_msg);
else
 tl_step (less_than_six, PASS, ok_disabled);
reinitialize ();
# STEP 5. Invalid Month
set_window ("Open Order");
# Inserting a date with an invalid month using variable, "date_invalid_month", defined above.
insert_date (date_invalid_month);
# Checking to verify that unless there is a valid month, an error message will pop up when trying to press "OK"
set_window("Open Order");
button_press("OK");
if(win_exists("Flight Reservation Message",10) != E_OK){
 tl_step (invalid_month, FAIL, invalid_month_msg_popup);
 clear_main_window();
 open_OpenOrderForm ();
}
else{
 set_window("Flight Reservation Message");
 static_get_text("Message", txt);
 if(txt !=invalid_month_entered_msg)
  tl_step (invalid_month, FAIL, invalid_month_wrong_msg);
 else
  tl_step (invalid_month, PASS, invalid_month_correct_msg);
 button_press("OK");
}
reinitialize ();
# STEP 6.  Invalid day of month.
set_window ("Open Order");
# Inserting a date with an invalid day using variable, "date_invalid_day", defined above.
insert_date (date_invalid_day);
# Checking to verify that unless there is a valid day of the month the "OK" button will be disabled
set_window("Open Order");
button_press("OK");
if(win_exists("Flight Reservation Message",10) != E_OK){
 tl_step (invalid_day, FAIL, invalid_day_no_err_msg);
 clear_main_window();
 open_OpenOrderForm ();
}
else{
 set_window("Flight Reservation Message");
 static_get_text("Message", txt);
 if(txt !=invalid_day_entered_msg)
  tl_step (invalid_day, FAIL, invalid_day_wrong_err_msg);
 else
  tl_step (invalid_day, PASS, invalid_day_not_accepted);
 button_press("OK");
}
reinitialize ();
# STEP 7.  No Entry.
set_window ("Open Order");
# Inserting no date to see if OK is disabled.
insert_date ("__/__/__");
# Checking to see if OK is disabled without any date set in edit field
if (button_check_enabled ("OK", TRUE) != E_OK)
 tl_step (no_entry, PASS, ok_button_disabled);
else
 tl_step (no_entry, FAIL, ok_button_enabled);
# Returning to initial state.
button_press ("Cancel");
clean_up();
# End of test.
本文转自 fish_yy 51CTO博客,原文链接:http://blog.51cto.com/tester2test/138722,如需转载请自行联系原作者
你可能感兴趣的文章
我的友情链接
查看>>
bash的基本特性之文件名通配 及IO重定向,管道详解
查看>>
mysql主主互备+原来mysql主从架构
查看>>
hadoop2.1.0和hadoop2.2.0编译安装教程
查看>>
php过滤处理手机自带Emoji表情
查看>>
错误集:org.hibernate.AssertionFailure: null id in xxx.xx.xx的问题
查看>>
python2.6升级到2.7
查看>>
linux下mysql的root密码忘记解决方
查看>>
(原创)ubuntu x86_64下搭建redmine+svn+mysql+nginx+apache2
查看>>
我的友情链接
查看>>
classes.dex文件转smali文件
查看>>
CentOS6启动过程超详解分析
查看>>
求最小公倍数简便方法
查看>>
oracle错误ora-01658的解决办法
查看>>
linux服务器宕机分析/性能瓶颈分析
查看>>
将 SLE HA 11 SP3 升级到 SLE HA 11 SP4
查看>>
jbpm:java.lang.LinkageError
查看>>
centOS 安装mp4box
查看>>
iOS中堆和栈的区别
查看>>
C语言之结构体
查看>>