GUI Test Automation Example
The article shows how to create and use GUI (Graphical User Interface)
automation test with
RoutineBot. In this
example we will create a test for Balanced Scorecard Designer application,
which will test the ability of application to use new values for indicators,
ability to change these values and ability to re-calculate performance
values once the input values were changed.
GUI Test Automation
- Check if values of indicator can be changed;
- Check if the changes of values have effect on total performance
value;
- Test method: automated GUI test;
Requirements:
- Generating resulted test file. Results of tests should be "PASSED"
if the test was passed and "FAILED" if the test failed;
- Input values: gui_test.bsc file with 4 categories and 12 indicators;
the default values of tested indicators are 50;
GUI Test Automation Script
- First, we need to create test file according to requirements and put
it into separate folder. In our case this is gui_test.bsc
-
Now,
it is time to run
RoutineBot and start
creating GUI test script. I go to the "Script" tab and click "Add
action" button. The action to be added is "Execute", I select
bsc_designer.exe as a program name and gui_test.bsc as a parameter. I'm
using full paths to these files. I'm clicking "Run Script" button to
make sure that everything is fine. I'm saving the RoutineBot script into
the test folder.
- The good idea is to add "Hide" command in the first line of the
script. This will prevent debug script window from opening. Also, in the
end of the script I'm adding KillProcess command, so now I don't have to
think about how to close the application. Check the list of all
possible command in
RoutineBot.
-
Now,
it is necessary to manage RoutineBot to do necessary clicks and changes. I
select "Select Sample" tab, run gui_test.bsc project, the select and
crop image pattern of "New goal 4 indicator" in Balanced Scorecard
Designer. Then I need to click "Save sample" button and save the pattern
under new_goal_4.bmp name. Finally, I click "Select action" button and
use action which is selected by default, it is "MouseFocuse". Then I go
to the "Script" tab and add another action - MouseClick. When
selecting image patterns it is good idea to take in mind possible
test flexibility issues.
-
Then using the GUI script I will try to change indicator's weight and
check if the performance was changed accordingly. I'm focusing on
"Weight" text and then move mouse relatively down, so the mouse pointer
would point on the weight text box. Then I do emulate "Control + A"
key press to
select all text in the text box. And then enter new weight with
EnterKeys command. The new weight should be "2".
-
The new "Total performance" value should be 32.36%. I use "MouseFocuse"
command and try to find the appropriate image on the BSC Designer
screen. If it was found the script will continue with OK status, if the
image was not found, the script will continue with FAILED status.
-
OK, now we will try to change indicators' weight with another method. We
focus on the indicator and change its' value by clicking two times "UP"
key on keyboard (use EnterKeys('{UP 2}'); command for this).
-
The total performance must be 33,5%. I use MouseFocuse to make sure the
performance was changed.
Integrating GUI test script into software test batch file
Now it is time to integrate GUI test script that we created into the set
of software scripts.
- First, I will generate .bat file using RoutineBot. There is a "prepare
bat file" command in Tools menu.
- The bat file should be modified a little for our needs. For "-MessagesFile"
key I will use the text file located in the folder where the other test
files are. The name of the "-MessagesFile" is gui_res.txt. It will
contain "PASSED" text if the script will be executed successfully.
- Now, the task is to run this script file from the software batch
test file and to output there necessary results. For this purpose I use
two commands:
- call gui_test_g1\gui_test_01.bat
- type gui_test_g1\gui_res.txt
GUI test files
GUI test script full text. The script was created with a help of
RoutineBot:
Other samples
|