标题: WinRunner :Testing multi language applications [打印本页] 作者: pcl2004_27 时间: 2006-10-25 12:58 标题: WinRunner :Testing multi language applications Description
How to make WinRunner scripts language independent
Solution
The easiest way for this is of course to use differnt GUI-maps: one GUI-map for each language. But this causes a lot of additonal work: All these GUI-maps have to be created and what is even worse: to be updated in case of changes to the application.
So I decided to use only one GUI-map for all languages. The first thing to to for this is to avoid language dependent recognition properties (like "label") whereever it is possible. You set this in the GUI-map configuration and we used mainly the 4GL name (eg. "pbname" in case of PowerBuilder) property.
Nevertheless there will always be some objects (especially menu-items etc) which you cannot recognize properly without using the "label".
What I did with these object was to write them in an XLS-Sheet with one column for the logical name, one column for its parent window and one column for each language.
Then I created a startup script which I initialized with a variable for the current language of the AUT to be tested.
With this startup script I open a template GUI-map which contains all objects which are language independent and create a copy of this template GUI-map, which I call "Runtime GUI-map"
By using the language variable I then loop through the XLS-Sheet, get the language dependent label of the object and copy it into the Runtime GUI-map.
After finishing the loop, the Runtime GUI-Map will be closed and loaded and I am ready for language independent testing...
######################################################################################
######################################################################################
# Script one begins here:
# Declare path for locating files in a commonly accessible folder
path="\\\\asoa0004\\Access\\CommDir\\TD_Basel\\Tests";
# the following lines pull the current system time
# from the workstation for use by the script.
CURRENT_TIME= get_time( );
SCHEDULED_TIME=CURRENT_TIME+120;#this is 60 * 2 minute(s)
split ( time_str(SCHEDULED_TIME), date_array, " " );
FORMATTED_TIME= date_array[4];# this displays the time as HH:MM:SS
report_msg("Formatted time written :"&FORMATTED_TIME);
# Write the raw time, expressed in seconds, to a file
file_open(path &"\\results\\time.txt",FO_MODE_WRITE);
file_printf(path &"\\results\\time.txt",SCHEDULED_TIME);
file_close(path &"\\results\\time.txt");
report_msg("correct time written :"SCHEDULED_TIME);
# Script one ends here
######################################################################################
######################################################################################
# Script two begins here:
# In a later script, read the results of the earlier script
file_open(path &"\\results\\time.txt",FO_MODE_READ);
file_getline(path &"\\results\\time.txt",SCHEDULED_TIME);
file_close(path &"\\results\\time.txt");
# Now loop until the SCHEDULED_TIME is past
CURRENT_TIME = get_time();
do
{
CURRENT_TIME = get_time();
} while (CURRENT_TIME < SCHEDULED_TIME);
# Write a tl_step so that Test Director will see that the script
# passed successfully
tl_step("Current time is now past the scheduled time",pass,"The scheduled time arrived");
# Script two ends here
######################################################################################
######################################################################################