From a newbie to a test automation rock star, vol. 6: Create you first mobile test and go wild

Tihomir Babić
9 min readJan 7, 2020

--

Image by Thomas Ulrich from Pixabay

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Once you do that go to About phone.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

After seven taps, you will get a message saying „You are now a developer!“.

Image by Tihomir Babić/screenshot

After we’ve enabled developer mode, it should show up in our System menu.

Image by Tihomir Babić/screenshot

Select Developer options and enable USB debugging.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

You should also scroll down and turn the animations off for:

· Window animation scale

· Transition animation scale

· Animator duration scale

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Click on your agent to show more options. Here you can see some technical details about your agent and system.

Image by Tihomir Babić/screenshot

If you select Devices, you’ll see something like this. Your phone should be shown here, with a green dot showing it’s connected.

Image by Tihomir Babić/screenshot

By clicking this eye symbol, you can view your device. If everything’s working, you should see your phone’s screen on your computer.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Clicking this option will show you this screen.

Image by Tihomir Babić/screenshot

Let’s name it youtube since this is an application we’re going to test. Also, select your Android device.

Image by Tihomir Babić/screenshot

Now search applications and find Youtube. Click Finish.

Image by Tihomir Babić/screenshot

It will lead you to this screen.

Image by Tihomir Babić/screenshot

Select Next, then Record and Start Testing.

Image by Tihomir Babić/screenshot

Start Recording, sit back and relax. In few moments TestProject will access your phone, launch a Youtube application and mirror the device screen.

Image by Tihomir Babić/screenshot

Now we’re ready to create a little test. Let’s hover over the search icon and press double Shift to freeze the element.

Image by Tihomir Babić/screenshot

Go to Actions and select Click.

Image by Tihomir Babić/screenshot

Now simply Create step.

Image by Tihomir Babić/screenshot

Whatever embarrassing Youtube search history you have, let’s freeze the first search result. Double Shift click, of course.

Image by Tihomir Babić/screenshot

Go to Validations and select Is visible.

Image by Tihomir Babić/screenshot

Now simply Create step.

Image by Tihomir Babić/screenshot

Hover over the first item in your search history and freeze it. Now we’re going to create Click if visible step.

Image by Tihomir Babić/screenshot
Image by Tihomir Babić/screenshot

Double Shift over options menu, go to Validations and create Is visible step.

Image by Tihomir Babić/screenshot
Image by Tihomir Babić/screenshot
Image by Tihomir Babić/screenshot

Now create Click step for the same element.

Image by Tihomir Babić/screenshot

Hover over Save to playlist, go to Validations and select Contains text.

Image by Tihomir Babić/screenshot

Scroll down to input parameters and type in Save to playlist. Create step.

Image by Tihomir Babić/screenshot

Let’s now create a Click step on the same element. Double Shift over it, go to Actions, then Click.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Select action Click if visible, and create the step.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Again, double Shift over the same element. Go to Actions, then find Clear contents and create step.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Now what? The step has successfully typed in what we wanted.

Image by Tihomir Babić/screenshot

Let’s now simply click in the Youtube search field.

Image by Tihomir Babić/screenshot

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!

Image by Tihomir Babić/screenshot

Let’s select it and click OK. And here they are, videos we’ve been looking for!

Image by Tihomir Babić/screenshot

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.

Image by Tihomir Babić/screenshot

Select the agent and the Android device. Select Run.

Image by Tihomir Babić/screenshot

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!

--

--

Tihomir Babić

Data Analyst and Reporting Expert turned Database Designer and Developer from Zagreb, Croatia. Recently started learning about test automation.