Skip to content

Instantly share code, notes, and snippets.

@matthewreagan
Last active February 11, 2016 03:37
Show Gist options
  • Save matthewreagan/b009cb2daf1256a3853b to your computer and use it in GitHub Desktop.
Save matthewreagan/b009cb2daf1256a3853b to your computer and use it in GitHub Desktop.
Waiting for XCUIElement to exist
//Usage example:
//XCUIElement *newFileButton = self.app.windows.buttons[@"New File"];
//[self waitForElementToExist:newFileButton timeout:20.0];
//[newFileButton click];
- (void)waitForElementToExist:(XCUIElement *)element timeout:(NSTimeInterval)timeout
{
NSPredicate *existsPredicate = [NSPredicate predicateWithFormat:@"exists == 1"];
[self expectationForPredicate:existsPredicate evaluatedWithObject:element handler:nil];
[self waitForExpectationsWithTimeout:timeout handler:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment