[英]XCUITest - Task-kill App
Trying to find a solution to automate task-kill the app for XCUITest... 试图找到一种解决方案以自动执行任务以杀死XCUITest应用程序...
static let springboard:XCUIApplication? = XCUIApplication(bundleIdentifier: "com.apple.springboard")
class func killApp(app:XCUIApplication) -> Bool
{
app.terminate()
if let springboard = springboard
{
springboard.activate()
XCUIDevice.shared.press(.home)
XCUIDevice.shared.press(.home)
Thread.sleep(forTimeInterval: 1.0)
let appTask = app.otherElements["appID"]
if appTask.isHittable
{
appTask.swipeUp()
XCUIDevice.shared.press(.home)
return true
}
else
{
print("App task is not hittable!")
return false
}
}
return false
}
But it's not working. 但这不起作用。 The two home button taps seem not to be recognized as a quick double-tap.
似乎没有将两次Home键轻按两次即可快速识别。 Does anyone know a workable solution for this?
有谁知道一个可行的解决方案?
Instead of depending on Springboard and double tap try this (I assume you are trying to close the app and not uninstall it) 无需依赖Springboard并双击尝试此操作(我假设您正在尝试关闭该应用程序而不是将其卸载)
closeApp(background: Bool = false) {
if (background) {
XCUIDevice.shared().press(.home)
} else {
application.terminate()
}
快速双击主页按钮仍然无法实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.