title: Run an automatic test on Android with Appium + TestNG + Eclipse
body: <p>I'm a beginner with automatic tests and Appium specifically, and I'm trying to a test (for android).</p>
  
  <p>I downloaded:</p>
  
  <ol>
  <li><p><strong>Appium</strong> - ran the server </p></li>
  <li><p><strong>Android emulator</strong> (Android Virtual Device Manager)</p></li>
  <li><p><strong>TestNG</strong></p></li>
  </ol>
  
  <p>The purpose of the test is adding a contact to the contact list.</p>
  
  <p>Does anyone know what I am missing?</p>
  
  <p><strong>The test:</strong></p>
  
  <pre><code>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&lt;WebElement&gt; textFieldsList = driver
                  .findElementsByClassName("android.widget.EditText");
          textFieldsList.get(0).sendKeys("Some Name");
          textFieldsList.get(2).sendKeys("Some@example.com");
          driver.swipe(100, 500, 100, 100, 2);
          driver.findElementByName("Save").click();
      }
  
      @AfterSuite
      public void tearDown() throws Exception {
          driver.quit();
      }
  
  }
  </code></pre>
  
  <p><strong>The EXCEPTION</strong></p>
  
  <pre><code>[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.&lt;init&gt;(HttpCommandExecutor.java:62)
      at org.openqa.selenium.remote.HttpCommandExecutor.&lt;init&gt;(HttpCommandExecutor.java:57)
      at org.openqa.selenium.remote.RemoteWebDriver.&lt;init&gt;(RemoteWebDriver.java:153)
      at io.appium.java_client.AppiumDriver.&lt;init&gt;(AppiumDriver.java:109)
      at io.appium.java_client.android.AndroidDriver.&lt;init&gt;(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
  </code></pre>
  
  <p>Thanks!</p>