我把它归结为:
XCUIDevice.pressButton(noideawhatgoeshere)我试过XCUIDeviceButtonHome,家,家,1
如何模拟在iOS上按Xcode中的home按钮?
发布于 2015-10-12 17:47:55
您需要首先获得设备实例。因此,要模拟按home按钮:
XCUIDevice.sharedDevice().pressButton(XCUIDeviceButton.Home)应该能工作(对我来说是物理设备)
谢谢!
马赞
Swift 5版本:
XCUIDevice.shared.press(XCUIDevice.Button.home)此外,验证它在模拟器中工作,至少在Xcode 11.2.1上模拟运行iPad 13.2.2的“iPadOS Pro (9.7-英寸)”。
发布于 2017-10-21 22:44:01
Swift 4
XCUIDevice.shared.press(.home)发布于 2017-12-13 15:11:59
在Swift版本4.0.2和4.0.3中
XCUIDevice.shared().press(XCUIDeviceButton.home)https://stackoverflow.com/questions/32853818
复制相似问题