I have an application whose main goal is to enter data into HealthKit. I would like to write some tests of the Xcode interface to verify that it successfully writes this data, but I find it difficult to verify the data in the Health application.
When I originally recorded my test, it skipped my click on the “Modified Home” button, but it was recorded when I moved to the first home screen and went to the Health app to display data points.
I searched how to click the Home button and found this (which works):
XCUIDevice.sharedDevice().pressButton(.Home)
However, none of the other calls he recorded actually worked for navigation outside the application. The recorded code for scrolling on the main screen clearly looks wrong, and also does not work when I replace tap() with swipeRight() or swipeLeft() :
app.childrenMatchingType(.Window).elementBoundByIndex(1).childrenMatchingType(.Other).elementBoundByIndex(1).childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).elementBoundByIndex(0).childrenMatchingType(.ScrollView).element.tap()
The following two lines, to launch the application on the main screen, do not even work for the application icon on the currently visible page:
let elementsQuery = app.scrollViews.otherElements elementsQuery.icons["Health"].tap()
Is there a way to achieve what I'm trying to do, or do I need to wait to check end-to-end testing until I add the ability to read from HealthKit to my application?
source share