【发布时间】:2021-05-25 05:43:57
【问题描述】:
我最近开始研究 SwiftUI 框架,我正在使用 XCTest 编写 UI 测试用例。
NavigationLink("Login", destination: TabBarDashboardView())
.accessibility(identifier: "linkLogin")
.frame(width: 200, height: 50, alignment: .center)
.foregroundColor(.white)
.background(Color.red)
.padding([.top, .bottom], 40)
在 XCTestCase 类中,我尝试了以下代码来点击 NavigationLink:
func testLoginActionAndNavigation() throws {
let linkLogin = self.app.navigationBars.links["linkLogin"]
linkLogin.tap()
XCTAssertEqual(linkLogin.title, "linkLogin")
}
我收到以下错误并且测试用例失败:
Failed to get matching snapshot: No matches found for Descendants matching type Link from input {( NavigationBar, identifier: '_TtGC7SwiftUI19UIHosting' )}
我在 XCTestCase 类中搜索与 NavigationLink 访问相关的内容,但没有找到任何有效/正确的文档。
如果有人已经在这个主题上工作过,请你帮助我。
【问题讨论】:
-
有什么更新吗?....
标签: ios swift swiftui swiftui-navigationlink xctestcase