WinRunner Functions Listed by Category

Following are WinRunner custom functions developed in Data-driven Testing Framework.

To see functions sorted by alphabet follow WinRunner Functions Listed Alphabetically.

Function code can be seen in sample script winrunner_ABC_Functions_en

Script Management Functions

Script management functions are used to execute bunch of several scripts. One atomic/functional script is invoked by ABC_!Batch script, which uses get_next_test and test_process to invoke and handle all scripts.

  • set_GUI_map_configuration To minimize WR setup work, set WR GUI map by code. This could also set by user interface under Tools-GUI Map Configuration.
  • start Environment setup and startup statements for functional test
  • start_batch Environment setup and startup statements for batch test uses start and does additional jobs for only batch tests
  • ABC_Logon Logs on to ABC instance
  • get_next_test read next test and data table from UseScript table
  • test_process invokes test calls and manages its execution
  • finish_batch Environment cleanup and ending statements for batch test
  • finish Environment cleanup and ending statements for each test
  • err_expl Pass in the error code you want to check and the function
  • exception_handler handle application exceptions. Clear environment, write to test log and exit from fuctional script

Analog Functions

Analog functions are used to deal with dynamic HTML pages which content is generated/changed by Javascript. In most cases it works, (if onchange event is passed as shown in Handle DHTML/Javasript pages. If it doesn't work, use analog WinRunner functions. Because analog functions depend on screen layout, several custom functions are developed which prepare object coordinates before invocation of analog functions. These functions use common array for storing object coordinates and other info. Define some array before using functions.

Then usual invocation sequence is following:
  • use analog_set_coords to get coordinatas for one control, or analog_prepare_elements for several elements
  • use analog_prepare_lastrow or analog_prepare_row if elements are located in table row
  • then use analog_click_on_text, analog_edit_set or analog_select_combo to click/type on/in necessary element.
  • use analog_scroll_obj if you need to scroll object content (only navigation till up/down/left/right end is supported)
    Full list of customized analog functions is following:
  • analog_click_on_text find text (i.e. link) in frame and click on it in analog mode
  • analog_edit_set write the given text into the given textbox using analog functions
  • analog_navigate navigate to necessary screen using analog mode
  • analog_prepare_elements set x and y coords for elements in the passed array. Can use either logical name, or physical description of the object
  • analog_prepare_lastrow prepare fieldinfo[] array for using with analog_edit_setcalculates x,y coords for all fields IN THE LAST row of the table
  • analog_prepare_row prepare x and y coords for elements which are in passed row of the table. Elements are calculated using GUI file and by their location
  • analog_prepare_row_elements set set x and y coords for several elements in tables's last (or other, if passed) row. Function doesn't use .gui file
  • analog_scroll_obj scroll content of the object in necessary direction
  • analog_select_combo write the given text into the given field (textbox or combobox) using analogous functions
  • analog_set_coords set x and y coords for ONE mentioned control in passed array. Can use either logical name, or physical description of the object
  • analog_type click (and type something, if necessary) on some graphical element in analog mode, use this function if analog_edit_set is too complex

Date Functions

Mostly used function is date_from_WRsecs which returns current date/time with customizable format, e.g. cdate=date_from_WRsecs("DD/MM/YYYY HH:NN");

  • date_diff desired difference in time and get back it in get_time format
  • date_from_str Pass date as string, and get as Unix seconds (get_time format), or as formatted string in other format.
  • date_from_WRsecs Use this function, if seconds is in get_time format (as diff_date returns)
  • date_from_WRtime Pass format string and [optional] time string (as WinRunner time_str)
  • date_shift returns date shifted by assigned period from passed date

File Management Functions

File management functions are written with more elastic handling of file path and data values, and with more detailed error handling

Window/Object/Message Handling Functions

These functions are for handling application windows and their objects. Some functions are developed for web tests, therefore their usage for Win32 applications could be problematic. win_save and win_restore functions are used to store desktop before and cleanup after test execution.

  • get_message Looks for JavaScript message and returns String it contains
  • get_mainwin_desc Finds a physical description of browser_main_window by partial/suspected label
  • get_obj_desc Returns [almost] any objects physical description by it's name
  • my_set_window Smarter operating with set_window. In more detailed error logging is added, in case of failure exception handler is called
  • obj_get_desc_by_name Finds a physical description of object even it is not in the GUI mapping file
  • save_html_source save html source of the window (html frame) in file
  • screen_shoot save screenshot in passed file name, or generates unique filename in format "yymmddhhnn"
  • win_close_dialogs Check for unexpected browser and Win dialogs, ad close it
  • win_get_property Returns value of window property e.g. Label,Width,Height,Enabled,Focused,etc. see WR help for window property
  • win_restore count windows after running test and delete unexpected. For previous list use global array, or excel file
  • win_save count windows before running test and (optionally) save list of existing windows in excel file
  • window_preserve check, if window shown in TaskManeger should be preserved from killing

Navigation Functions

navigate function is used to navigate to any necessary screen in application in the same way. It includes advanced timeout, error handling, and similar tweaks.

  • navigate Navigates to the necessary window by clicking on passed elements
  • check_navigate Check and log more info and errors than simple navigate by clicking on buttons and links

Edit/Combo/List Box Functions

These function are developed to deal edit and list boxes, which can be lost, or content sometimes is not known exactly. my_edit_set is used in place of usual edit_set for more advanced error handling select_referenced_item is used to select item using search/lookup window in similar way for several items, e.g: Item["Attribute1"]=select_referenced_item("bAttribute1", Item["Attribute1"],"wLookup","wSearchResults","tList1"); Item["Attribute2"]=select_referenced_item("bAttribute2", Item["Attribute2"],"wLookup","wSearchResults","tList2"); Because in current project application is quite unarranged, this function is quite complicated. It can be used as a template your solution.

  • my_edit_set Smarter operating with edit_set. In case of failure log is generated
  • list_check_presence Check if item presents in check list or not
  • list_check_substr Check if list contains passed string as part of any record, or not
  • list_get_copy create copy of GUI list in WR array to improve checking performance
  • list_select_item_byval Allow selecting items by values strating with "#", in difference to list_select_item which treats it as item/record number
  • select_combo select passed item in list or combo box, if value not found or shift required select another value
  • select_referenced_item next generation of function to select referenced value using search form
  • check_values compare control (edit/list/combo box) and passed value

Table/Array Functions

Table/array function are mainly developed to deal with tables with child elements in cells. Several search/selection approaches are made more simpler than using built-in functions.

  • arr_find_text check if passed value exists in array or not
  • arr_max_idx Returns the maximum index in the given array
  • check_from_table set checkbox ON/OFF in table against required value
  • tbl_check_row_with_values check that table has row with required values
  • tbl_find_text Finds a text in a html_table and returns row and column where the text resides.
  • tbl_get_cell_value Returns textual value from cell. Works better than TSL tbl_get_cell_data
  • tbl_get_copy create copy of GUI table in WR array to improve checking performance array (0 based!), count of rows, count of columns
  • tbl_get_row_with_values find row with passed values in columns
  • tbl_get_value Finds a row in a html_table according to passed value and returns contents (value) of another column in the found row.
  • tbl_set_cell_value sets value for child control in a table cell, processes: html_edit,html_combobox,html_listbox,html_check_button and html_radio_button
  • to_array returns arry, created from delimited lists

String/Numeric/Conversion Checking Functions

Following are string/numeric functions which I found useful in my projects.

  • get_part Return one of values in delimited list
  • equal_as_numbers Compares two give strings as numbers
  • parse_number Analyzes the given string and returns the number contained there. Scientific form (e.g. 1e-5) is NOT supported!
  • replace Replace substring from (delimited list of values) with to (delimited list of values) in string str
  • replace_ASCII replace one character in string to other, given by ASCII code
  • trim drops spaces from string
  • int_rand return random integer

Miscellaneous

These are left function which I couldn't put in below categories;-)

  • get_sys_var get system information and initialize appropriate variables
  • get_test_name return name of the functional test, which is currently running
  • my_db_connect Customized db_connect with smarter error handling
  • my_db_execute_query Customized db_execute_query with smarter error handling
  • fill_empty return value of parama["FillEmpty"], in case if it is empty, return default: FILL_EMPTY
  • need_check return value of parama["NeedCheck"], in case if it is empty, return default: NEED_CHECK
  • my_tl_step Write to test WR log and if batch_mode==ON, also into file and database
Top
Tags English Testing
Created by Administrator on 2008-11-23 10:15
Last modified by Administrator on 2021-04-13 14:29
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License