SwiftUI slider in accessibilityRepresentation & XCUITest slider's normalizedSliderPosition

Hi everybody,

given the following case using SwiftUI:

Button("testButton", action: noop)
.accessibilityRepresentation{representation: {
    Slider(value: $sliderData.sliderValue)
})
.accessibilityIdentifier("testSlider")

I'm trying to control the slider using XCUITest via slider.adjust(toNormalizedSliderPosition: 0.2)

and receive the following error message:

Failed: Unable to get expected attributes for slider, found {
    "XC_kAXXCAttributeMaxScrubberPosition" =     {
        X = 0;
        Y = 0;
    };
    "XC_kAXXCAttributeMinScrubberPosition" =     {
        X = 0;
        Y = 0;
    };

Similarly, print (slider.normalizedSliderPosition) leads to the error message "Failed to determine current position of slider "0 %".

Is there a way to set and read the value of accessibilityRepresentation-Sliders with XCUITest?

Thanks!

@sasro I am stuck with the exact same problem.

Did you manage to solve this issue? If so how?

There seem to be some issues with normalizedSliderPosition in the new version of iOS. We have been using coordinates to work around this issue: https://developer.apple.com/documentation/xctest/xcuielement/1500960-coordinate

This may not get you the current value of the slider, but it will let you adjust the slider to the correct position.

SwiftUI slider in accessibilityRepresentation & XCUITest slider's normalizedSliderPosition
 
 
Q