title: How to do Android Unit Test using Appium in Ubuntu
body: <p>I want to do a simple unit test for HelloWorld Android application using Appium. My Android application has one Activity and after it loads on the screen, it displays "Hello World" on a TextView. What I want is to write a unit test case using Python that it works as I expect and test using Appium.</p>
  
  <p>The main thing I cannot understand is the connection between my Android project, Appium and Python script. </p>
  
  <p>I think I have configured Appium in my Ubuntu-12.04 correctly. When I give following command in terminal </p>
  
  <pre><code>anuja@anuja-MulTplx:~$ appium &amp;
  </code></pre>
  
  <p>it gives following response</p>
  
  <blockquote>
    <p>anuja@anuja-MulTplx:~$ info: Appium REST http interface listener
    started on 0.0.0.0:4723</p>
  </blockquote>
  
  <p>I have written simple Python script for web unit testing with Selenium WebDriver. But I have no idea how to write a Python script to test my Android application using Appium. Need a example or good documentation. </p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p><strong>I am adding this part after <em>@<a href="https://stackoverflow.com/a/16817165/833007">Dan Cuellar</a></em> answer.</strong></p>
  
  <p>After I have launched the server using one terminal, I ran my python script from another terminal which contains python bindings.</p>
  
  <p>On the Appium server running terminal it gives following out put</p>
  
  <pre><code>debug: Appium request initiated at /wd/hub/session
  
  debug: Request received with params: {"sessionId":null,"desiredCapabilities":{"app-package":"my.app.package","app":"/home/anuja/MobileDev/apks_and_keys/Trickbook.apk","browserName":"","version":"4.0.4","device":"Android","app-activity":"TrickbookSplasher"}}
  
  info: Using local app from desiredCaps: /home/anuja/MobileDev/apks_and_keys/Trickbook.apk
  
  info: Creating new appium session 4788d549-d39a-4730-9bdb-382418c2b2c9
  
  info: Starting android appium
  
  debug: Using fast reset? true
  
  info: Preparing device for session
  
  info: Checking whether app is actually present
  
  info: Checking whether adb is present
  
  info: [ADB] Using adb from /home/anuja/MobileDev/sdk/platform-tools/adb
  
  info: Trying to find a connected android device
  
  info: [ADB] Getting connected devices...
  
  info: [ADB] 1 device(s) connected
  
  info: [ADB] Setting device id to 4d017b1f209a3f7b
  
  info: Found device, no need to retry
  
  info: [ADB] Waiting for device 4d017b1f209a3f7b to be ready and to respond to shell commands (timeout = 5)
  
  info: Checking whether we need to run fast reset
  
  debug: Checking app cert for /tmp/my.app.package.clean.apk: java -jar "/usr/lib/node_modules/appium/app/android/verify.jar" "/tmp/my.app.package.clean.apk"
  
  debug: App not signed with debug cert.
  
  debug: Checking app cert for /home/anuja/MobileDev/apks_and_keys/Trickbook.apk: java -jar "/usr/lib/node_modules/appium/app/android/verify.jar" "/home/anuja/MobileDev/apks_and_keys/Trickbook.apk"
  
  debug: App not signed with debug cert.
  
  info: Building fast reset
  
  error: uncaughtException date=Thu May 30 2013 11:28:22 GMT+0530 (IST), pid=4466, uid=1000, gid=1000, cwd=/home/anuja, execPath=/usr/bin/nodejs, version=v0.10.8, argv=[node, /usr/bin/appium], rss=27017216, heapTotal=19666944, heapUsed=12400392, loadavg=[0.26318359375, 0.201171875, 0.333984375], uptime=2427.250582503, trace=[column=18, file=fs.js, function=Object.fs.openSync, line=427, method=fs.openSync, native=false, column=15, file=fs.js, function=Object.fs.readFileSync, line=284, method=fs.readFileSync, native=false, column=36, file=/usr/lib/node_modules/appium/android/adb.js, function=ADB.buildFastReset, line=131, method=buildFastReset, native=false, column=12, file=/usr/lib/node_modules/appium/android/adb.js, function=null, line=311, method=null, native=false, column=14, file=/usr/lib/node_modules/appium/android/adb.js, function=null, line=283, method=null, native=false, column=7, file=child_process.js, function=ChildProcess.exithandler, line=641, method=exithandler, native=false, column=17, file=events.js, function=ChildProcess.EventEmitter.emit, line=98, method=EventEmitter.emit, native=false, column=16, file=child_process.js, function=maybeClose, line=735, method=null, native=false, column=5, file=child_process.js, function=Process.ChildProcess._handle.onexit, line=802, method=ChildProcess._handle.onexit, native=false], stack=[Error: ENOENT, no such file or directory '/usr/lib/node_modules/appium/app/android/AndroidManifest.xml.src',     at Object.fs.openSync (fs.js:427:18),     at Object.fs.readFileSync (fs.js:284:15),     at ADB.buildFastReset (/usr/lib/node_modules/appium/android/adb.js:131:36),     at /usr/lib/node_modules/appium/android/adb.js:311:12,     at /usr/lib/node_modules/appium/android/adb.js:283:14,     at ChildProcess.exithandler (child_process.js:641:7),     at ChildProcess.EventEmitter.emit (events.js:98:17),     at maybeClose (child_process.js:735:16),     at Process.ChildProcess._handle.onexit (child_process.js:802:5)]
  </code></pre>
  
  <p>AND on the terminal where I have executed the python binding script gives following out out.</p>
  
  <pre><code>Traceback (most recent call last):
  
    File "forth.py", line 12, in &lt;module&gt;
      driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
  
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 72, in __init__
      self.start_session(desired_capabilities, browser_profile)
  
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 114, in start_session
      'desiredCapabilities': desired_capabilities,
  
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 163, in execute
      response = self.command_executor.execute(driver_command, params)
  
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 349, in execute
      return self._request(url, method=command_info[0], data=data)
  
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 396, in _request
      response = opener.open(request)
  
    File "/usr/lib/python2.7/urllib2.py", line 400, in open
      response = self._open(req, data)
  
    File "/usr/lib/python2.7/urllib2.py", line 418, in _open
      '_open', req)
  
    File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
      result = func(*args)
  
    File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
      return self.do_open(httplib.HTTPConnection, req)
  
    File "/usr/lib/python2.7/urllib2.py", line 1180, in do_open
      r = h.getresponse(buffering=True)
  
    File "/usr/lib/python2.7/httplib.py", line 1030, in getresponse
      response.begin()
  
    File "/usr/lib/python2.7/httplib.py", line 407, in begin
      version, status, reason = self._read_status()
  
    File "/usr/lib/python2.7/httplib.py", line 371, in _read_status
      raise BadStatusLine(line)
  
  httplib.BadStatusLine: ''
  </code></pre>
  
  <p>I have used a self signed apk for above testing purpose.</p>
  
  <ul>
  <li>Right click on the Eclipse Android project</li>
  <li>Android Tools</li>
  <li>Export signed application package</li>
  <li>Go thorough the wizard</li>
  </ul>
  
  <p>I am using a real device for this testing.</p>
  
  <p>Can anybody point me where/what I have done wrong?</p>