kif-framework / KIF

Keep It Functional - An iOS Functional Testing Framework
Other
6.2k stars 909 forks source link

KIF with SwiftUI element #1270

Closed blyscuit closed 1 year ago

blyscuit commented 1 year ago

My SwiftUI view is a simple view

struct ContentView: View {

    var body: some View {
        Button {
        } label: {
            Text("Close")
        }
        .accessibilityIdentifier("button")
    }
}

KIF doesn't seem to be able to locate the button (or any other view types) with the accessibility identifier.

I followed the steps in README, not sure what is missing or if it's UIAccessibilityElement *element = [self accessibilityElementWithLabel:label value:value traits:traits fromRootView:fromView error:error]; not being able to pick up SwiftUI view?

Screen Shot 2022-12-02 at 14 55 15

Full source code

dostrander commented 1 year ago

I think it's becuase you are adding it to a UI test target, try doing this in your project in the other testing target and this should work

blyscuit commented 1 year ago

@dostrander Thank you. Works great.