0

My stepper is defined as follows (Standalone WatchOS app)

Stepper(value: $myCount) {
    Text("\(myCount)").font(.footnote).accessibilityIdentifier("count_label")
}.accessibilityIdentifier("my_stepper")

It is fully functional on the real / simulator devices. During a test case, defined below, I am unable to invoke the increment button. (I get an error and the button itself is not hittable, ever)

XCTAssertTrue(app.steppers["my_stepper"].waitForExistence(timeout: 10))
XCTAssertFalse(app.steppers["my_stepper"].buttons["Remove"].isEnabled)
XCTAssertTrue(app.steppers["my_stepper"].buttons["Add"].isEnabled)
-> (Error)  app.steppers["my_stepper"].buttons["Add"].tap()

Error kAXErrorCannotComplete performing AXAction kAXScrollToVisibleAction on element AX element pid

I tried to forceTap (using coordinates) with no luck. Any idea how to invoke the increment action?

stackich
  • 3,607
  • 3
  • 17
  • 41
angryip
  • 2,140
  • 5
  • 33
  • 67
  • Did you try to generate the code with recorder to see how Xcode sees those buttons? Also, just an advice: Insead of constantly using `app.steppers["my_stepper"]`, you better declare it as a variable and just access it. – stackich Oct 31 '22 at 13:07
  • If it is the only stepper on the screen, I think you can try something like `let stepper = app.otherElements["Stepper"].firstMatch` – stackich Oct 31 '22 at 13:10
  • what is a recorder? any links so i can try? – angryip Oct 31 '22 at 21:21
  • 1
    yes, check 04:40 : `https://www.youtube.com/watch?v=ECuc3qoRm90`. – stackich Nov 01 '22 at 06:14
  • i'll give that a go. that might uncover the mystery – angryip Nov 01 '22 at 14:31

1 Answers1

0

While the increment and decrement buttons exist in the view stack, they are not hittable. Likely a bug in SwiftUI that impacts either WatchOS or all platforms. Best way I have found to temporarily get past the issue is using the following tutorial :

app.steppers["my_stepper"].coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.5)).tap()
    

This is a workaround that will probably fail on different devices. For me, it would only work with Ultra 49mm watchOS 9.0. Accepting this until a better answer is found.

angryip
  • 2,140
  • 5
  • 33
  • 67