I've got it down to:
XCUIDevice.pressButton(noideawhatgoeshere)
I've tried XCUIDeviceButtonHome, home, Home, 1
Not sure how to simulate pressing the home button, does anyone have any pointers? I'm new to xCode/swift
I've got it down to:
XCUIDevice.pressButton(noideawhatgoeshere)
I've tried XCUIDeviceButtonHome, home, Home, 1
Not sure how to simulate pressing the home button, does anyone have any pointers? I'm new to xCode/swift
You need to get the device instance first. So to simulate pressing the home button:
should work (it does for me on a physical device)
Thanks!
Mazen
Now in Swift 4.1:
Swift 4:
I know of no way to simulate the home button - this might not be possible. You can sorta brute force it with:
[[UIApplication sharedApplication] terminate];
or you can put your app in the background for a specified duration with:UIATarget.localTarget().deactivateAppForDuration(seconds);
(excuses for using objc)
In Swift version 4.0.2 and 4.0.3:
Objective C
Home button = 1, Volume up button = 2, Volume down button = 3.