Reputation: 21
I'm a beginner with automatic tests and Appium specifically, and I'm trying to a test (for android).
I downloaded:
Appium - ran the server
Android emulator (Android Virtual Device Manager)
TestNG
The purpose of the test is adding a contact to the contact list.
Does anyone know what I am missing?
The test:
package com.appium;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import java.io.File;
import java.net.URL;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
public class One {
private AppiumDriver driver;
@BeforeSuite
public void setUp() throws Exception {
//driver.launchApp();
// set up appium
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Nexus5");
capabilities.setCapability("platformV01ersion", "4.1.2");
capabilities.setCapability("appPackage",
"com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManager");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
}
@Test
public void addContact() {
WebElement el = driver.findElement(By.name("Add Contact"));
el.click();
List<WebElement> textFieldsList = driver
.findElementsByClassName("android.widget.EditText");
textFieldsList.get(0).sendKeys("Some Name");
textFieldsList.get(2).sendKeys("[email protected]");
driver.swipe(100, 500, 100, 100, 2);
driver.findElementByName("Save").click();
}
@AfterSuite
public void tearDown() throws Exception {
driver.quit();
}
}
The EXCEPTION
[TestNG] Running:
C:\Users\nadav.miran\AppData\Local\Temp\testng-eclipse-451394169\testng-customsuite.xml
FAILED CONFIGURATION: @BeforeSuite setUp
java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:88)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:57)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:39)
at com.appium.One.setUp(One.java:37)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 25 more
===============================================
Default test
Tests run: 0, Failures: 0, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 0, Failures: 0, Skips: 0
Configuration Failures: 1, Skips: 1
===============================================
[TestNG] Time taken by org.testng.reporters.XMLReporter@517ceb9b: 13 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@37610393: 7 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@54fba1ac: 0 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@9e12aac: 34 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@61ed627d: 29 ms
Thanks!
Upvotes: 2
Views: 3751
Reputation: 1846
I got this error.
It occurred as I pressed the 'run' button in Eclipse but the correct way to run a TestNG test suite is as follows:
Right Click on testng.xml
Run as > TestNG Suite
I understand this is an old question however I hope this helps
Upvotes: 1
Reputation: 1895
Please add the following dependency to your project
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.2</version>
</dependency>
Also please download the Selenium-server-standalone.jar from here and add to the class path. Please see this link for more details.
Upvotes: 1