Testing an Android application failed in Eclipse using Appium

I wanted to learn about a tool to test Android application. After a bit of googling I came around this wonderful tool called Appium which is used to test Android application and also is an open source. I wanted to learn about it. So I went ahead and created a simple android application having few button clicks to start with the testing.

I have done all the following:

  1. Plugged in all the necessary jar's into Eclipse IDE.
  2. Downloaded and installed Appium server.
  3. Plugged in Maven and TestNG for Eclipse.
  4. Successfullly installed SampleApp.apk into the Emulator.

I next created a TestNG class to test the SampleApp.apk. The code for which is pasted below. However on running the application I received java.lang.NullPointerException. It's been two days. I tried doing everything, building, cleaning, restarting eclipse, creating a new application, re installing all the dependencies. But still I receive the same exception. I had referred the video by Execute Automation and have done the exact same minus the application which is different in my case.

package com.example.appium;  import java.net.MalformedURLException; import java.net.URL; import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.remote.MobileCapabilityType; import org.junit.BeforeClass; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.Assert; import org.testng.annotations.Test;  public class TestJavaAppium {      AppiumDriver<WebElement> driver;      @BeforeClass     public void Setup() throws MalformedURLException{          DesiredCapabilities capability =  new DesiredCapabilities();         capability.setCapability(MobileCapabilityType.DEVICE_NAME, "Emulator");         capability.setCapability(MobileCapabilityType.APP_PACKAGE, "com.example.sampleapp");         capability.setCapability("avd", "Emulator4.2");                  driver = new AndroidDriver<WebElement>(new URL(""), capability);     }      @Test   public void simpleTest() {        Assert.assertNotNull(driver.getContext());   } } 

My Appium is configured as below just to assure I had all the information correct.Testing an Android application failed in Eclipse using Appium

Ideally the code should run and launch the application (at least it did in the video) successfully. But what I received instead was the below exception:

[TestNG] Running:   C:\Users\KC\AppData\Local\Temp\testng-eclipse-518994855\testng-customsuite.xml  FAILED: simpleTest java.lang.NullPointerException     at com.example.appium.TestJavaAppium.simpleTest(TestJavaAppium.java:37)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)     at java.lang.reflect.Method.invoke(Unknown Source)     at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)     at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)     at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)     at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)     at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)     at org.testng.TestRunner.privateRun(TestRunner.java:773)     at org.testng.TestRunner.run(TestRunner.java:623)     at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)     at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)     at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)     at org.testng.SuiteRunner.run(SuiteRunner.java:259)     at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)     at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)     at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)     at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)     at org.testng.TestNG.run(TestNG.java:1018)     at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)     at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)     at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)   ===============================================     Default test     Tests run: 1, Failures: 1, Skips: 0 ===============================================   =============================================== Default suite Total tests run: 1, Failures: 1, Skips: 0 ===============================================  [TestNG] Time taken by [email protected]: 225 ms [TestNG] Time taken by [email protected]: 230 ms [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 26 ms [TestNG] Time taken by [email protected]: 14 ms [TestNG] Time taken by [email protected]: 14 ms [TestNG] Time taken by [email protected]: 12 ms 

Where I possibly might have gone wrong to anger my Eclipse?


Code looks good. Provide the app activity.

Instead of APP_PACKAGE, you can set up Appium using the .apk full path in your PC:

capability.setCapability(MobileCapabilityType.APP, "/full/path/to/app.apk");

Category: java Time: 2016-01-16 Views: 2

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.238 (s). 12 q(s)