title: XCTest UI tests: why does my attempt to swipe the last table cell upwards instead slide up the brightness and volume panel?
body: <p>I'm trying to use XCode 7's UI test functionality to run an automated test that can walk through the entirety of a hierarchy of table views. (I'm using depth-first search with iterated deepening.) In each screen, I get the ui tester to tap each of the cells in turn. If that opens a new view, that view (itself a table) will be visited thoroughly, and eventually the system will return to the previous view and tap the next cell. In this manner, each cell (and thus each table view) in the hierarchy ought to be visited.</p>
  
  <p>One irritation of the system is that if you have e.g. ten cells but only seven fit on the screen, it seems to be incumbent on you to make the UI test system scroll the cells up as part of its exploration, because cells[7] is not going to be tappable unless it is visible onscreen. (If there is any way to get around this, this might constitute a short-circuit answer that obviates the need for my main question to be answered.)</p>
  
  <p>My plan was that after each cell has been pressed and any newly-opened screen visited, I execute a swipe upwards action on that cell before moving on to the next cell. This ought to ensure that the immediate successor is on screen before I ask the system to try tapping it.</p>
  
  <p>But when I attempt to swipe upwards on a cell that is resting right at the bottom of the screen, the action instead acts as though I have performed a swipe up from the very bottom edge of the screen, pulling the volume control and brightness into the screen, and throwing off my tree walking completely:</p>
  
  <p><a href="https://i.stack.imgur.com/9ojBa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ojBa.png" alt="Unwanted swipe results"></a></p>
  
  <p>I don't quite understand why this would happen. If I always assign one of the enumerated <code>app.table.cells</code> list to be the XCUIElement that receives the swipe action, why would the system end up swiping the bottom of the screen? Is this some quirk/bug of the XCTest ui testing system, or is the error mine?</p>
  
  <pre><code>XCUIElementQuery* cells = app.tables.cells;
  if( cells &amp;&amp; level &lt; maxDepth )
  {
      if( [cells count] &gt; 0 )
      {
          int iAlert = 0;
          int i = 0;
          for( i = 0, cells = app.tables.cells; i &lt; [cells count]; ++i )
          {
              XCUIElement* element = NULL;
              bool shouldSwipeUp = false;
  
              if( cells )
              {
                  NSInteger nCells = [cells count];
                  element = [cells elementBoundByIndex:i];
                  shouldSwipeUp = ( i &lt; (nCells - 1) );
              }
  
              if( element &amp;&amp; element.hittable )
              {
                  [element tap];
  
                  [self recurseIfChangedScreen:app withCurrentNavBarName:currentNavBarName withLevel:level];
  
                  if( shouldSwipeUp )
                  {
                      [element swipeUp];
                  }
              }
          }
  </code></pre>