title: Robust React Native element finding using Appium
body: <p>I'm using React Native to develop an app that requires end-to-end testing.</p>
  
  <p>Coming from a Selenium WebDriver background, it seems to me that element finding in Appium can be very awkward compared to WebDriver, since native components only have ID and a single non-user-defined class.</p>
  
  <ol>
  <li>Is there a way I can add some sort of metadata to elements to make them easy to find?</li>
  </ol>
  
  <p>Say if I have a table with complex elements inside a cell, and I need to first find the right row, then the cell, and then find the right components to manipulate inside the cell.</p>
  
  <p>Ideally I'd want to be able to enumerate rows by searching for something like "myTargetRows". That would give me a list of rows.</p>
  
  <ol start="2">
  <li>If I understand it correctly, no two components can have the same ID in native applications, so I can't use ID just like that, right? (I.e. use the same ID, "myTargetRows", for multiple row components).</li>
  <li>If not, should I use numbered IDs like "myTargetRow0", "myTargetRow1", etc, and then use XPath to partially match the ID?</li>
  <li>Isn't there a better way?</li>
  <li>If I can do something like that, can I then just chain those <code>findElement</code> calls to find the right nested elements I want?</li>
  </ol>
  
  <p>P.s.: I don't want to hardcode the exact component hierarchies in my locators to avoid invalidating them should I move anything around in my views, so those point-and-click solutions won't help.</p>
  
  <p>P.s. 2: Solutions must work both on Android and iOS, even if I need to implement some sort of abstraction for it myself.</p>