Search code examples
seleniumappiumselendroid

Androiddriver not working in appium


I am trying to run a test on my android mobile.

I am using the latest appium windows exe.
I am using the below code:

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.*;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;


public class Test 
{

    public static void main(String[] args) throws MalformedURLException
    {
        WebDriver dr;
        File app=new File("C://Users//TarunVats//Desktop//atoms.apk");
        DesiredCapabilities capabilities=new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("deviceName", "Xiaomi Mi3");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "4.4.4");
        capabilities.setCapability("app",app.getAbsolutePath());

        capabilities.setCapability("appPacakage", "com.AndroidTest");
        capabilities.setCapability("appActivity", "com.Test.Main");
        dr=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);

        dr.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
    }
}

Gson-2.0 jar is added in externa jars. java client.jar for appium. All selenium based jar is imported. My Phone is in debugging mode. In eclipse DDMS is showing my phone is connected

Still, I am getting the error:

Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.remote.ErrorHandler.<init>(Lorg/openqa/selenium/remote/ErrorCodes;Z)V
at io.appium.java_client.AppiumDriver.<clinit>(AppiumDriver.java:46)
at Test.main(Test.java:29)

Could someone explain what's going on?


Solution

  • You have problem in the appPackage capability. You wrote

    capabilities.setCapability("appPacakage", "com.AndroidTest");
    

    but need

    capabilities.setCapability("appPackage", "com.AndroidTest");