I've got it down to:
XCUIDevice.pressButton(noideawhatgoeshere)
I've tried XCUIDeviceButtonHome, home, Home, 1
How do I simulate pressing the home button in Xcode on iOS?
I've got it down to:
XCUIDevice.pressButton(noideawhatgoeshere)
I've tried XCUIDeviceButtonHome, home, Home, 1
How do I simulate pressing the home button in Xcode on iOS?
You need to get the device instance first. So to simulate pressing the home button:
XCUIDevice.sharedDevice().pressButton(XCUIDeviceButton.Home)
should work (it does for me on a physical device)
Thanks!
Mazen
Swift 5 Version:
XCUIDevice.shared.press(XCUIDevice.Button.home)
Also, verified it works in the simulator, at least in Xcode 11.2.1 on a simulated "iPad Pro (9.7-inch)" running iPadOS 13.2.2.
XCUIDevice.shared().press(.home)
–
Brunette In Swift version 4.0.2 and 4.0.3:
XCUIDevice.shared().press(XCUIDeviceButton.home)
Objective C
[XCUIDevice.sharedDevice pressButton: XCUIDeviceButtonHome];
There are also XCUIDeviceButtonVolumeUp
for volume up button and XCUIDeviceButtonVolumeDown
for volume down button.
Now in Swift 4.1:
XCUIDevice.shared.press(XCUIDevice.Button.home)
© 2022 - 2024 — McMap. All rights reserved.