I have recently started work on the SwiftUI framework, I'm writing UI Test Cases using XCTest.
NavigationLink("Login", destination: TabBarDashboardView())
.accessibility(identifier: "linkLogin")
.frame(width: 200, height: 50, alignment: .center)
.foregroundColor(.white)
.background(Color.red)
.padding([.top, .bottom], 40)
In the XCTestCase class, I tried the following code to tap NavigationLink:
func testLoginActionAndNavigation() throws {
let linkLogin = self.app.navigationBars.links["linkLogin"]
linkLogin.tap()
XCTAssertEqual(linkLogin.title, "linkLogin")
}
I'm getting the following error and test case is getting failed:
Failed to get matching snapshot: No matches found for Descendants matching type Link from input {( NavigationBar, identifier: '_TtGC7SwiftUI19UIHosting' )}
I search related to NavigationLink access in XCTestCase class, but didn't find any valid/proper documentation.
Would you please help me on this if anyone already worked on this topic.