I am writing a react-native
bridge for healthkit that includes the initialization of Healthkit. I also need to write an unit test for the modules.
I would like to use Travis to auto test on the project. Therefore, I need a automatic way that can press on the Allow
button. Otherwise, the permission UI will block the unit testing process.
So, I need to know how automatically press on the allow button.
I'm using this library in my XCTests, I didn't specifically test HealthKit alerts but it seems to be supported.
https://github.com/PGSSoft/AutoMate/blob/master/AutoMate/Models/HealthAlerts.swift
I was able to reach those buttons with:
lazy var turnOnAllCategories = app.tables.cells.firstMatch
lazy var allowCategoriesConnectionButton = app.navigationBars.buttons.element(boundBy: 1)
On my test I check if the popup form is displayed with:
if turnOnAllCategories.waitForExistence(timeout: waitForExistenceTimeFrame) {
turnOnAllCategories.tap()
allowCategoriesConnectionButton.tap()
}
Keep in mind that base on your UI, maybe you will need to filter a bit more the results of app.tables and app.navigationBars.buttons
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.