Reputation: 960
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.
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.)
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.
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:
I don't quite understand why this would happen. If I always assign one of the enumerated app.table.cells
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?
XCUIElementQuery* cells = app.tables.cells;
if( cells && level < maxDepth )
{
if( [cells count] > 0 )
{
int iAlert = 0;
int i = 0;
for( i = 0, cells = app.tables.cells; i < [cells count]; ++i )
{
XCUIElement* element = NULL;
bool shouldSwipeUp = false;
if( cells )
{
NSInteger nCells = [cells count];
element = [cells elementBoundByIndex:i];
shouldSwipeUp = ( i < (nCells - 1) );
}
if( element && element.hittable )
{
[element tap];
[self recurseIfChangedScreen:app withCurrentNavBarName:currentNavBarName withLevel:level];
if( shouldSwipeUp )
{
[element swipeUp];
}
}
}
Upvotes: 1
Views: 3546
Reputation: 301
The exact reason behind this is, The swipe begins at the bottom of the view and goes up, which is similar to the gesture used to bring up the Command Center. This will be recognized as an iOS Gesture and command center will be launched, instead of interacting with the App.
To avoid this, always use an element that is present away from the bottom of the screen while doing a swipeUp() or Dragtoelement.
Upvotes: 0