From a newbie to a test automation rock star, vol. 6: Create you first mobile test and go wild
So far we have learned how to install TestProject Agent, then we’ve covered basic software testing theory. After that, we were ready to make our first test and also upgrade it. Once we’ve learned that, we learned what to do if something goes wrong and how to debug the test. And now for something completely different! Everything we did so far was web testing and now we feel quite comfortable with it. Let’s now see how we can use our knowledge to create mobile tests for Android applications.
Preparing your Android phone
Let’s login to our TestProject site.
Before we start doing anything with TestProject, we have to prepare our phone and make sure it can communicate with TestProject. Some guy called Abe Lincoln said,
“Give me six hours to chop down a tree and I will spend the first four sharpening the axe.”
He didn’t say what should we do in those four hours if we have a chainsaw. However, we won’t be chopping down the tree nor will we spend four hours preparing our Android axe. Nevertheless, we have to prepare it for our test recording to be successful. To do that we have to enable developer mode. First, go to Settings and select System.
Once you do that go to About phone.
Scroll down to Build number. Then tap it quickly seven times in a row. This will enable developer mode. Once you start tapping, the message will appear that will count down the remaining taps.
After seven taps, you will get a message saying „You are now a developer!“.
After we’ve enabled developer mode, it should show up in our System menu.
Select Developer options and enable USB debugging.
Scroll up and enable option Stay awake. With this option enabled, the phone won’t go to sleep mode, which is helpful when you’re testing something.
You should also scroll down and turn the animations off for:
· Window animation scale
· Transition animation scale
· Animator duration scale
Once we did that, we can use a USB cable to connect our phone with any device that has TestProject Agents installed on it. Plug in your phone and TestProject should prompt you for Device Authorization.
Allow it and your phone should be connected to TestProject. To check that, go to Agents in our TestProject. You’ll see your agent(s) there.
Click on your agent to show more options. Here you can see some technical details about your agent and system.
If you select Devices, you’ll see something like this. Your phone should be shown here, with a green dot showing it’s connected.
By clicking this eye symbol, you can view your device. If everything’s working, you should see your phone’s screen on your computer.
Now that we’ve checked the phone is communicating with TestProject, let’s create our first mobile test!
Creating first mobile test
Click on New Test for a start. The screen that opens will probably be familiar.
Now we’re creating a mobile test, not a web test. So, somewhat surprisingly, we will select Mobile. We will not create a new project. We’ll also use our existing project to save this new test.
Click Next, so we can give our test a name and description. Let’s name it FirstMobileTest with Description being Creating first mobile test for Android.
Click Next. Now we have to choose between Android and iOS. We’ll choose Android, of course. Also, we have to add an application we’re going to test. Since this is our first test, there will be no application shortlist. So we have to click Add a new application for testing.
Clicking this option will show you this screen.
Let’s name it youtube since this is an application we’re going to test. Also, select your Android device.
Now search applications and find Youtube. Click Finish.
It will lead you to this screen.
Select Next, then Record and Start Testing.
Start Recording, sit back and relax. In few moments TestProject will access your phone, launch a Youtube application and mirror the device screen.
Now we’re ready to create a little test. Let’s hover over the search icon and press double Shift to freeze the element.
Go to Actions and select Click.
Now simply Create step.
Whatever embarrassing Youtube search history you have, let’s freeze the first search result. Double Shift click, of course.
Go to Validations and select Is visible.
Now simply Create step.
Hover over the first item in your search history and freeze it. Now we’re going to create Click if visible step.
Double Shift over options menu, go to Validations and create Is visible step.
Now create Click step for the same element.
Hover over Save to playlist, go to Validations and select Contains text.
Scroll down to input parameters and type in Save to playlist. Create step.
Let’s now create a Click step on the same element. Double Shift over it, go to Actions, then Click.
It will open a list of your playlists with checkboxes by their names. We’ll now check if the boxes are clickable or not. Double Shift over checkbox, go to Actions and find Tap and create the step.
Let’s now create the step that will check if the video can be saved to our playlist and save it. Hover over Done, double Shift and go to Actions.
Select action Click if visible, and create the step.
Now that we’ve saved the video, let’s now search for another video. First, we’ll create a step that clicks on the search field then the step that clears its content. Hover over it, double Shift, go to Actions and find Click action. Now create the step.
Again, double Shift over the same element. Go to Actions, then find Clear contents and create step.
Now we’re going to check if the search field can be used for typing and finding the desired video. Again, double Shift over search element. Go to Actions, find Type text.
Once you select it, scroll down to input parameters and let’s type in „santana live“, which is the text that’ll be typed in the Youtube search field. Create the step.
Now what? The step has successfully typed in what we wanted.
Let’s now simply click in the Youtube search field.
Aaaaaah it does something! What do we want now that we’ve typed our search text? We want to hit enter and see if the search works. You can see in this small menu there’s an icon with the description Send ‘ENTER’ key after typing text. Exactly what we want!
Let’s select it and click OK. And here they are, videos we’ve been looking for!
We’re going to stop recording now by clicking Save & Exit in the upper right corner. Now we’re back in our project. We’re going to run the test from here and see if everything’s working.
Select the agent and the Android device. Select Run.
I hope you’ve made it through the test! Mine was completed successfully. It’s so 100% green that it’s an environment-friendly test!
Conclusion
Now we can go wild! Because we’ve just created our first mobile test! After we’ve learned how to create web tests, this was something new for us. However, what we’ve learned so far about navigating in TestProject, creating steps and different possibilities came quite handy this time. We’ve applied our knowledge to mobile testing and, at the same, we’ve learned something new. There were some interesting actions and validations that we used. Next time who knows what awaits us!
Keep on being wild in a test automation world!