How to launch system apps in an iOS Xcode UI test case -


i've got app main purpose enter data healthkit. i'd write xcode ui tests verify it's writing data successfully, i'm having difficulty verifying data in health app.

when recorded test, skipped simulated home button press, recording swiped on first home screen , navigated health app show data points.

i searched how press home button, , found (which works):

xcuidevice.shareddevice().pressbutton(.home) 

however, none of other calls recorded work navigation outside of app. recorded code swiping on home screen looks wrong, , doesn't work when replace tap() 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 next couple of lines, launching app on home screen, don't work app icon that's on visible page:

let elementsquery = app.scrollviews.otherelements elementsquery.icons["health"].tap() 

is there way achieve i'm trying do, or need wait verify end-to-end testing until add ability read healthkit app?

xcode 9

here's solution using xcode 9

let messageapp = xcuiapplication(bundleidentifier: "com.apple.mobilesms") messageapp.activate() 

you can find list of bundle identifier system apps in this post

xcode 8

for xcode 8 it's little bit more complicated in order launch application springboard need import following headers

https://github.com/facebook/webdriveragent/blob/master/privateheaders/xctest/xcuielement.h https://github.com/facebook/webdriveragent/blob/master/privateheaders/xctest/xcuiapplication.h

then use following (for example health)

objective-c

@interface springboard : nsobject  + (void)launchhealth;  @end  @implementation springboard  + (void)launchhealth {     xcuiapplication *springboard = [[xcuiapplication alloc] initprivatewithpath:nil bundleid:@"com.apple.springboard"];     [springboard resolve];      xcuielement *icon = springboard.icons[@"health"];      if (icon.exists) {         [icon tap];          // query elements in health app         xcuiapplication *health = [[xcuiapplication alloc] initprivatewithpath:nil bundleid:@"com.apple.health"];     } }  @end 

swift

class springboard {     static let springboard = xcuiapplication(privatewithpath: nil, bundleid: "com.apple.springboard")      class func launchhealth() {          springboard.resolve()          let icon = springboard.icons["health"]         if icon.exists {             icon.tap()              // query elements in health app             let health = xcuiapplication(privatewithpath: nil, bundleid: "com.apple.health")         }     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -