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>
You can try two things.
Try with selenium version 2.53
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
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");