Running Junit Test script on Eclipse on Android Emulator with Appium Driver

Hi All,

I am very new to Appium trying to run Junit Test script on Android emulator using eclipse IDE.
below is my code : Please help me where I am going wrong

package appiumSeminarSession1;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;

import java.util.concurrent.TimeUnit;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class wordpressTest {

public AppiumDriver driver;

public void setUp() throws Exception {

 File classpathRoot = new File(System.getProperty("user.dir"));
 File appDir = new File(classpathRoot,"/app");
 File app = new File(appDir,"WorkPress.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();  
    capabilities.setCapability("browserName", "");  
    capabilities.setCapability("deviceName", "emulator-5554");  
    capabilities.setCapability("platformVersion", "4.4");  
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("app", app.getAbsolutePath());
    capabilities.setCapability("appPackage", "");
    capabilities.setCapability("appActivity", ".Dashboard");
    capabilities.setCapability("appWaitActivity", ".Dashboard");

    //create a RemoteWebDriver, the default port for Appium is 4723
    //driver = new AppiumDriver( new URL(""), capabilities);
    //driver = new AppiumDriver(new URL(""),; 
    driver = new AppiumDriver(new URL(""), capabilities) {

        public MobileElement scrollToExact(String arg0) {
            // TODO Auto-generated method stub
            return null;

        public MobileElement scrollTo(String arg0) {
            // TODO Auto-generated method stub
            return null;
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

public void TestUI(){

POM File -

4.0.0 Mindfire appiumSeminarSession1 0.0.1-SNAPSHOT io.appium java-client 1.5.0

and Jar which I am using are


Error which I am getting is:

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Bad app: C:\JavaPractice\appiumSeminarSession1\app\WorkPress.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\JavaPractice\appiumSeminarSession1\app\WorkPress.apk’) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 105 milliseconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:03’
System info: host: ‘MININT-9RPP4EL’, ip: ‘’, ‘Windows 8.1’, os.arch: ‘amd64’, os.version: ‘6.3’, java.version: ‘1.8.0_11’
Driver info: appiumSeminarSession1.wordpressTest$1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at io.appium.java_client.AppiumDriver.execute(
at org.openqa.selenium.remote.RemoteWebDriver.startSession(
at org.openqa.selenium.remote.RemoteWebDriver.(
at org.openqa.selenium.remote.RemoteWebDriver.(
at io.appium.java_client.AppiumDriver.(
at appiumSeminarSession1.wordpressTest$1.(
at appiumSeminarSession1.wordpressTest.setUp(
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
at org.junit.runners.model.FrameworkMethod.invokeExplosively(
at org.junit.internal.runners.statements.RunBefores.evaluate(
at org.junit.runners.ParentRunner.runLeaf(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.BlockJUnit4ClassRunner.runChild(
at org.junit.runners.ParentRunner$
at org.junit.runners.ParentRunner$1.schedule(
at org.junit.runners.ParentRunner.runChildren(
at org.junit.runners.ParentRunner.access$000(
at org.junit.runners.ParentRunner$2.evaluate(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

1 Like


As it mentions here, you are referring to an app path that does not exist, verify that the app is in that path and try again as Appium fails to start sometimes in the first run and then runs correctly in consecutive runs.

You didn’t mention which version of Appium server are you using?? Also try to update Appium’s Java client to the latest revision as they fixed a lot since version 1.5

Hi Hassan,

Thanks for responding, I found what was the exact problem the app was in correct path but there was spelling mistake, It should have be “WordPress” not “WorkPress” :smile:

And I am using Appium Version and now everything is running properly. Thanks again for your valuable comments.