In our last post we see how to install Robotium on our Eclipse IDE. In this post we will explain on how to record an android application and playback the script.
Step 1 : Open Eclipse IDE. Before started recording we need to run the Android virtual device. Click on the Android Virtual device icon.
AVD manager window is displayed and start a device that is already configured. How to configure a Virtual device will be posted later in separate post. Select a device and click on Start button.
Launch Options window is displayed and click on Launch button.
Virtual device will start for Launching.
Now minimize the virtual device window, close AVD window and proceed for Robotium recording.
Step 2 : Go to File > New > Other
Step 3 : Click on Android – Robotium Recorder from New Window. Select New Robotium Test.
Step 4 : Click on Next button.
Step 5 : A pop up dialog is displayed with the message “Please Select the root Java JDK folder”. This message is only displayed if JDK folder is not defined and configured. Click on OK button.
Step 6 : Java JDK window is displayed. Locate the JDK folder on the machine. Click Ok button.
Step 7 : Robotium Recorder window is displayed and select the apk file. In our case we have downloaded android calculator apk file from this location. Select the apk file and enter the project name. Click on Next button.
Step 8 : Click on New Robotium Test button.
Step 9 : Recording Started. Wait for the application starts at Virtual device.
Step 10 : Go to Virtual device window and note that application will start on that window.
Step 11 : Enter 4 at First text box
Step 12 : Click on the second text box and enter 5 at second text box
Step 13 : Click on Multiply button.
Step 14 : Result will be displayed at Result text box.
Step 15 : In order to verify the result click on the Result text box. It will create an assert script.
Step 16 : Note that steps are written at plain text and click on Stop recording button.
A window may appear and click on OK button.
Step 17 : Click on Save button
Step 18 : A window is displayed to ask for Test Case name. Enter Test Case name as “Multiplication” and click on OK button.
Step 19 : Click on Finish button.
Step 20 : Code will be generated for this script at Eclipse editor. Expand the project of the package explorer window.
Step 21 : Double click on the class name “Multiplication.java”. We see the step by step script on the code. We will explain about code on future post.
Step 22 : Now Run the script. Right click on the Script name and click Run as > Android JUnit test.
Step 23 : Go to Virtual device window and inspect that script will run and execute test.
Step 24 : Result is displayed at JUnit Editor.
That’s all for now. Our next Robotium related post, we will show on how to refactor the Robotium script and write more manageable test.
Happy Automation day with Robotium …!!!