0

I have a loading indicator created by the code below. How can I add an identifier that will allow me to test for its presence on the page using XCUIApplication.something["identifier"].isHittable or similar?

    var body: some View {
        HStack {
            Circle()
                .fill(dotColor)
                .opacity(shouldAnimate ? 1 : 0.1)
                .frame(width: dotSize, height: dotSize)
                .scaleEffect(shouldAnimate ? 1.1 : 0.9)
                .animation(easyDoesIt, value: shouldAnimate)
            Circle()
                .fill(dotColor)
                .opacity(shouldAnimate ? 1 : 0.1)
                .frame(width: dotSize, height: dotSize)
                .scaleEffect(shouldAnimate ? 1.1 : 0.9)
                .animation(easyDoesIt.delay(0.2), value: shouldAnimate)
            Circle()
                .fill(dotColor)
                .opacity(shouldAnimate ? 1 : 0.1)
                .frame(width: dotSize, height: dotSize)
                .scaleEffect(shouldAnimate ? 1.1 : 0.9)
                .animation(easyDoesIt.delay(0.4), value: shouldAnimate)
            }
            .onAppear {
                self.shouldAnimate = true
            }
    }
JM Gelilio
  • 3,482
  • 1
  • 11
  • 23
  • Does this answer your question https://stackoverflow.com/a/62392959/12299030? – Asperi Jul 07 '22 at 04:37
  • Sort of.... I don't want to give it the isButton trait for accessibility reasons. I can give it the isImage trait and an identifier and test it that way but it's not really an image either. Is there a more appropriate trait or way to reference it in a test? – Surplus Yogurt Jul 07 '22 at 04:47
  • "I only show you a door" ;) – Asperi Jul 07 '22 at 05:02
  • 1
    Does this answer your question? [How do I access a VStack while UI testing my SwiftUI app](https://stackoverflow.com/questions/62392499/how-do-i-access-a-vstack-while-ui-testing-my-swiftui-app) – Alexander M. Sep 15 '22 at 21:21
  • 1
    Please see the solution with a GroupBox here: https://stackoverflow.com/a/73722420/3792318 – Alexander M. Sep 15 '22 at 21:21

0 Answers0