mardi 31 décembre 2019

Setting accessibility identifier doesn't work in react native

I want to set accessibility identifiers to my controls, mostly touchable controls for automation purpose. I am setting testID for iOS and accessibilityLabel for android but it isn't working. Not even in iOS.

Here is my code:

<TouchableHighlight
          btnTitle="Login"
          accessible={true}
          testID={"ButtonText"}
          accessibilityLabel={"ButtonTextDesc"}
        >
          <Text>Do something</Text>
</TouchableHighlight>

With this code, when I run app in simulator and check accessibility values in Accessibility Inspector, I don't see any identifier is setting up:

enter image description here

And when I do same thing for Text component only like:

<Text 
testID={testID} 
accessibilityLabel={accessibilityLabel} 
accessible={accessible}>
    Hello Test
</Text>

I get to see following in Accessibility Inspector app. enter image description here

Ideally I am expecting to see accessibilityIdentifier set for iOS components.

Aucun commentaire:

Enregistrer un commentaire