Winrunner测试Telnet手机终端框架

建文件夹MainScript, Public

GUI and Batches under Public folder.

Mobile Main script.:

 ######################################################################################
# Load the data Sheet
# Name of the Data Sheet as an input
######################################################################################
# Microsoft Excel - MiscRcpt
ddt_close_all_tables();
#p_file_path - path passed to the script
#file="..//DataSheet//AliasRcpt.xls";
file="";
file=p_file_path;
rc=ddt_open(file,DDT_MODE_READ);
if(rc==E_OK)
 report_msg("File Opened Successfully");
else
 pause("File Not opened");
#SetSearchpath
#setvar("searchpath","");
 
###################################################################################### 
# read the columns of the table - v_rc
# Column Count of the table
#
# Observe in the watch window the pipe symbol shown for list_of_param
# Copy paste it to a script
# it Evaluates to " "
##### Row Count and Column Count
# printf("Row Count is "&v_rc);
# printf("Column count is "&col_cnt_of_param);
######################################################################################
ddt_get_row_count(file,v_rc);
ddt_get_parameters(file,list_of_param,col_cnt_of_param);
######################################################################################
split(list_of_param,data_array," ");
###########################Array of Column Names #####################################
#For Each Row in the Sheet Print The Action ,Action Value,Variable Name,Expected Value
#Row Number should start with 1
###########################Array of Column Names #####################################
v_action=data_array[1];
v_action_value=data_array[2];
v_var_name=data_array[3];
v_expected_val=data_array[4];

v_wait=10;
v_set_window=20;

######################################################################################
# Loop through each line of the data sheet
######################################################################################
for(t_rc=1;t_rc<=v_rc;t_rc++)
{
 #SetRow
 #ddt_set_row(file,t_rc); # Not Mandatory
 ####Read the Action Action Value and Variable Name
 row_action=ddt_val_by_row(file,t_rc,v_action);
 t_row_action_value=ddt_val_by_row(file,t_rc,v_action_value);
 ######If special character like - exists - split by (-) replace by "\-"
 row_action_value=call_close "library\\escape_with_slash"(t_row_action_value);
 row_var_name=ddt_val_by_row(file,t_rc,v_var_name);
 row_expected_val=ddt_val_by_row(file,t_rc,v_expected_val);
 
 ######################################################################################
 # printf("######### ROW : "&t_rc&"##########");
 # printf("row_actionn is : "&row_action);
 # printf("row_action_value is : "row_action_value);
 # printf("row_var_name is : "row_var_name);
 # printf("row_expected_val is : "row_expected_val);
 ###### Based on action Switch the case
 #  Keywords used in Action are
 #  LAUNCH,SET,GET,NAVIGATE,CTRL,SKIP_DOWN,BUTTON_PRESS,CLOSE
 #  VERIFY_STATUSBAR
 #  VERIFY_ON_SCREEN
 ######################################################################################
  switch(row_action)
  {

   case "LAUNCH":
    call_close "library//Launch"(row_action_value);
    break;
    
   case "SET":
    # Enhancement : to accept variable names with values as input
    call_close "library//Set"(row_action,row_action_value,row_var_name);
    break;
    
   case "GET":
    call_close "library//set_val_into_var"(row_action_value,row_var_name);
    #Feb14th - additional Return key event required for get to exit field value
    obj_type ("Term Class","");
    #call_close "library//wait_for_action_complete"("Please Wait ...");
    #Geb 16th
    call_close "library//wait_for_action_complete"("");
    break;
    
   case "NAVIGATE":
    call_close "library//navigate"(row_action_value);
    break;
    
   case "CTRL":
    call_close "library//control_key_set_action"(row_action_value,row_var_name);
    call_close "library//wait_for_action_complete"("");
    break;
    
   case "CTRL_NoEnter":
    call_close "library//control_key_set_action_NoEnter"(row_action_value,row_var_name);
    call_close "library//wait_for_action_complete"("");
    break;
    
   case "SKIP_DOWN":
    call_close "library//skip_down"();
    break;
   #Feb 21st, 2011, added by Jeffrey Guo 
   case "SKIP_UP":
    call_close "library//skip_up"();
    break;
   #feb 21st
   case"ESC":
    call_close "library//esc_key_action"(row_action_value);
    break;
   case "BUTTON_PRESS":
    call_close "library//button_press"();
    break;
    
   case "VERIFY_STATUSBAR":
    call_close "library//verify_statusbar"(row_expected_val);   
    break;
   case "VERIFY_ON_SCREEN":
    call_close "library//verify_on_screen"(row_expected_val);
    break;
   
   case "LOGOUT":
    call_close "library//logout"();
    break;
    
   case "CLOSE":
 #    wait(v_wait);
    call_close "library//close"();
    break;
   # Mar 3rd, 2011,added by Jeffrey Guo
   case "VERIFY_VALUE":
    call_close "library//verify_value"(row_action_value,row_expected_val);
    break;
    
   default:
    report_msg("In Default");
  }#End of Switch
}#End of For
######################################################################################
# Close data tables
######################################################################################
ddt_close(file);
ddt_close_all_tables();
######################################################################################
# Print mobile captured values
######################################################################################

treturn;

Set function example:

 ##################################################
# Set Window
#printf("RowNumber ");
# Set Searchpath
#Feb20th - t_row_action_Value set to blank to refresh values
t_row_action="";
t_row_action_value="";
t_row_var_name="";

t_row_action=p_row_action;
t_row_action_value=p_row_action_value;
t_row_var_name=p_row_var_name;
##################################################
set_window ("WMS Mobile - HyperTerminal", v_set_window);
## Code added feb 16th
## Wait for message "Please Wait.." or "Other Message" to dissappears on the screen
## Exanmple on Login When Password is entered - Value Connecting is displayed for long time
## Wait for no message in status bar before entering value
#call_close "wait_for_action_complete"("");
###################################################
# Feb 17th
# if Action value starts with a ":" the value is a variable
# Example :v_org_name- comes from forms
# DEFINE :var_org_name  Value
###################################################
# Substr
t_new_value="";


if(substr(t_row_action_value,1,1)==":")
{
 t_new_value=substr(t_row_action_value,2);
 t_row_action_value=mob_arr[t_new_value];# mob_arr["v_org_name"];
 # If the value is from Winrunner escape it-eg \-
 t_row_action_value=call_close "escape_with_slash"(t_row_action_value);
}
#else Action Value is : String not a variable
###############END17th##################
#Type the text
#Ifvalue contains - replace with \-
# Read character by character and replace
obj_type ("Term Class",t_row_action_value);
report_msg("Value entered is: " & t_row_action_value);
obj_type ("Term Class","");
if(p_row_var_name!="")
 
#wait
#wait(v_wait);
# Wait for
# this statement can be moved before the user punches the value onto the screen
# user should wait for "Enter Name" or "blank"    
#call_close "wait_for_action_complete"("Please Wait ...");
# if Variable_value is not blank
# Call Set into script
#if(p_row_var_name!="")
 call_close "set_val_into_var"(t_row_action_value,t_row_var_name);
# wait(v_wait); After a user enters a value only when the return key is pressed
# will a message appear, hence wait for action complete is not required
call_close "wait_for_action_complete"("Please Wait ...");
# Enter Return Key


#######################################################################################
# After the enter key is pressed - Status bar displays messages such as
# "Connecting","Please Wait ..","Enter Name "
# Soltion : Script. needs to wait for such messages to dissaper to move to next action
#######################################################################################
##feb16th - can eb removed if other actions are not dependent on it
#call_close "wait_for_action_complete"("");
treturn;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15698984/viewspace-702007/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/15698984/viewspace-702007/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值