模拟在Xcode 7 UI Automation中按下Home按钮 [英] Simulating pressing the Home button in Xcode 7 UI Automation

查看:77
本文介绍了模拟在Xcode 7 UI Automation中按下Home按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将其归结为:

XCUIDevice.pressButton(noideawhatgoeshere)

我已经尝试过XCUIDeviceButtonHome,home,Home,1

I've tried XCUIDeviceButtonHome, home, Home, 1

如何模拟在iOS上的Xcode中按下主屏幕按钮?

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)

谢谢!

Mazen

Swift 5版本:

XCUIDevice.shared.press(XCUIDevice.Button.home)

还要验证它至少可以在模拟器中运行,至少可以在运行iPadOS 13.2.2的模拟"iPad Pro(9.7英寸)"上的Xcode 11.2.1中使用.

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.

这篇关于模拟在Xcode 7 UI Automation中按下Home按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆