gpt4 book ai didi

ios - springboard.icons ["appName"] 无法识别 XCUITest 中安装的应用程序

转载 作者:行者123 更新时间:2023-11-29 05:32:57 25 4
gpt4 key购买 nike

我引用下面的github代码在运行每个XCUItest后删除应用程序。 https://gist.github.com/KoCMoHaBTa/5d2cecfc17db5f3944bc98bcd6fcde55

但是代码片段 let icon = springboard.icons["myAppName"] 无法识别我的应用程序。我已将 myAppName 替换为我的应用程序名称,并且检查 icon.exists 是否始终返回 false 的 if 条件。跳板类如下所示。我在这里错过了什么吗?

class Springboard {

static let shared = Springboard()

let springboard = XCUIApplication(bundleIdentifier: "com.company.me")

func deleteApp(withName name: String) {

XCUIApplication().terminate()

let springboard = self.springboard
//springboard.resolve()
springboard.activate()
let icon = springboard.icons[name]
sleep(5)
//let icon = springboard.icons.matching(identifier: "ONE").firstMatch
//let icon = springboard.otherElements["Home screen icons"].scrollViews.otherElements.icons["ONE"]
if icon.exists {

let iconFrame = icon.frame
let springboardFrame = springboard.frame

//Tap & Hold the app icon in order to go to edit mode
Thread.sleep(forTimeInterval: 0.5)
icon.press(forDuration: 1.3)

//Tap the little "X" button at approximately where it is. The X is not exposed directly
Thread.sleep(forTimeInterval: 0.5)
springboard.coordinate(withNormalizedOffset: CGVector(dx: (iconFrame.minX + 5) / springboardFrame.maxX, dy: (iconFrame.minY + 5) / springboardFrame.maxY)).tap()

//tap the delete alert button
Thread.sleep(forTimeInterval: 0.5)
springboard.alerts.buttons["Delete"].tap()
}

//Press home once make the icons stop wiggling
Thread.sleep(forTimeInterval: 0.5)
XCUIDevice.shared.press(.home)
}
}

最佳答案

您可能应该更改bundleIdentifier

让 springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")

<小时/>

此外,您还可以使用 simctl 工具删除您的应用

xcrun simctl uninstall --help

关于ios - springboard.icons ["appName"] 无法识别 XCUITest 中安装的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57352569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com