4 Tips for Test Automation on Android 7

android-nougat-logoAs a mobile app tester I am always eager to try the newest OS releases. So when the latest Android version was released, I obviously wanted to run my automated test scripts on that version too. I quickly found out my setup needed some updates and tweaks, which I share with you in this blog post.

I have used Webdriver and Appium now and again for the past few years, and haven’t updated my Appium app version (1.4.13) for a while now. After the new OS releases, I quickly found out that this version of Appium is not suitable for running tests on Android 7 and iOS 10. This meant I needed to update my setup with the latest Appium version. First I started with the Appium Beta, now I use the stable 1.6 release, which is the Appium Server, not the .app. If you’ve been using the app and want to try out the server to test Android 7 and iOS 10, check this page for an installation and usage guide: https://github.com/appium/appium

Tip 1

Compared to Appium 1.4.13, there have been some major changes to Appium which forced me to update my tests. For instance, the “name locater strategy” is deprecated. Instead of that I can use xpath, id, class name or accessibility id to locate elements. The xpath can differ across different platform versions so I recommend you use the resource id or class name instead. Of course if an accessibility id is available, that’s an option too (it isn’t on my project). As long as you remember that xpath should be your last option here due to cross platform compatibility.

Tip 2

Another change for me in Appium 1.6 is the switch from using the app version of Appium to having to use the server version. This has had some impact on the way I locate elements, because the server doesn’t come with that wonderful inspector which is really useful for finding elements when you build your test scripts. As a workaround I just use Appium 1.4.13 to inspect elements on older platform versions and run the scripted tests using Appium server for the newer platform versions.

If you have trouble finding elements using these locators and tactics, check with your favorite colleague-developer, who might find a way to help you out.

appiumTip 3

Another difference when using the new Appium version and the server instead of the app, is the way the tests are launched. In the app I could just edit my settings, hit launch and start going. Now I have to find the best way to start the server. I advocate to keep things simple and start Appium using node. But you will need to set the parameters as well, so this is what I did for Android 7.

I launched the Appium app which logs its own launching command:

Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --address "" --command-timeout "7200" --pre-launch --debug-log-spacing --automation-name "Appium" --platform-name "Android" --platform-version "5.1" --app "<path to you apk>/<;yourapk.apk>" --app-activity "<launch activity for your app>" --app-wait-activity "<possible activity to wait for like onboarding>" --native-instruments-lib

Then I changed the launching command to make it compatible with Android 7 using the Appium server:

node . --address "" --command-timeout "7200" --pre-launch --debug-log-spacing --automation-name "Appium" --platform-name "Android" --platform-version "7.1.1" --app '<path to you apk>/<yourapk.apk>' --app-activity "<launch activity for your app>" --app-wait-activity "<possible activity to wait for like onboarding>"

Tip 4 And last but not least, in my DesiredCapabilities, I adjusted the Appium version, the platformVersion and the deviceName to reflect the new versions:

capabilities.setCapability("appium-version", "1.6.0");
capabilities.setCapability("platformVersion", "7.1.1");

Bit of overkill, but you can get your device name by the adb command “adb devices”

These changes launched Appium and my tests like a charm, and I was able to start updating my tests to work with Appium 1.6 and Android 7.

Hopefully these tips help you out as well!

1 thought on “4 Tips for Test Automation on Android 7”

Leave a Reply

Your email address will not be published. Required fields are marked *