0

I'm trying to run a simple appium test case , but when executing the test this exception is throwed Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/ConnectionPool for this line of code AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), caps); the code I used is

DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("deviceName", "blustack");
    caps.setCapability("udid", "emulator-5554"); //Give Device ID of your mobile phone
    caps.setCapability("platformName", "Android");
    caps.setCapability("platformVersion", "7.1.2");
    caps.setCapability("appPackage", "com.sourcey.materialloginexample");
    caps.setCapability("appActivity", "com.sourcey.materialloginexample/com.sourcey.materiallogindemo.LoginActivity");
    caps.setCapability("noReset", "true");

    //Instantiate Appium Driver
    try {
            AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), caps);

    } catch (MalformedURLException e) {
        System.out.println(e.getMessage());
    }

I found a same issue here but the proposed solution doesn't work.

daliDV
  • 67
  • 11

1 Answers1

0

Make sure your are importing all the required jars files.

If you are using Maven project import following dependency

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.13.0</version>
</dependency>

If you are using java project, check Adding jars for appium

Suban Dhyako
  • 2,436
  • 4
  • 16
  • 38