title: Android: get UI element tree from code (ChimpChat or monkeyrunner) over Hierarchy viewer
body: <p>I want to get all active UI elements from an (active) Activity without accessing the code. Exactly like the <a href="http://developer.android.com/tools/help/hierarchy-viewer.html" rel="nofollow">Hierarchy Viewer Tool</a>, just from code. At the moment I use the .jar files behind the monkeyrunner tool in java, but using the python API wouldn't be a problem, I could switch if necessary. :-)
  So I connect to the emulator and start the init HierarchyViewer like this:</p>
  
  <pre><code>m_chimpchat = ChimpChat.getInstance(options);
  m_device = m_chimpchat.waitForConnection(5000, ".*");
  HierarchyViewer hv = m_device.getHierarchyViewer();
  </code></pre>
  
  <p>(Python equivalent would be)</p>
  
  <pre><code>device = MonkeyRunner.waitForConnection()
  hv = device.getHierarchyViewer()
  </code></pre>
  
  <p>But that's it. I don't know how to get the UI elements from here. It must be possible because the Hierarchy Viewer Tool can do that. </p>
  
  <p>If possible, I want to know what kind of UI component it is, an id, its position (x, y) and its txts (for example Button txt, TextView, ...) to implement tests.</p>
  
  <p>Thanks, Soeren</p>