1

Im trying to automize my App using Appium, but I can't seem to get the configuration right.

Appium Server is running on 127.0.0.1:4723 and started. I emulate a Device using the Android SDK emulator with avd.Im using Eclipse with Selenium and TestNG to test my configuration.

What I get is an Error in the @BeforeMethod

FAILED CONFIGURATION: @BeforeMethod setUp
java.lang.NoClassDefFoundError: org/openqa/selenium/logging/LoggingHandler

Any Suggstion what might be wrong in my configuration?

package xxx_appium.xxx_appium_test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.aspectj.lang.annotation.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.service.DriverCommandExecutor;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;

public class ConnectionTest {

@BeforeMethod
public void setUp() throws MalformedURLException {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("BROWSER_NAME", "Android");
    capabilities.setCapability("avd","ANexus");
    capabilities.setCapability("deviceName", "ANexus");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("platformVersion", "9");
    capabilities.setCapability("app", 
    "C:\\Users\\xxx\\Downloads\\yyyy.apk");

    driver = new AndroidDriver<WebElement>(new         
    URL("http://localhost:4723/wd/hub"), capabilities);

}
@AfterMethod
public void tearDown() {
    driver.quit();
}

@Test
public void sampleTest() {
}

Also here are the maven dependencies so you know which libarys I use jUnit is in there, because I tried it also with jUnit:

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>
    <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>6.1.0</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.14.0</version>
</dependency>
</dependencies>

1 Answer 1

2

You can try two things.

  1. Try with selenium version 2.53

    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.53.0</version>
    </dependency>
    
  2. Also dont pass below capability because you are passing absolute path of apk,so you should not pass browser name capability because one session will be created i.e. with browser or with an app.

     capabilities.setCapability("BROWSER_NAME", "Android");
    
Sign up to request clarification or add additional context in comments.

2 Comments

Worked like a charm. The problem was the selenium version. I don't know what changed so much that my configuration breaks on version 3.x but 2.53 works.
I was getting same error, I need to change Selenium-Java version only. I also mentioned Browser_name and by reviewing your comment I have deleted it, But It was asking for to define Browser_name and so it needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.