I’d like to add an accessibilityIdentifier
to a React Native component, so that I can use Xcode’s UI testing to navigate around my app.
Is there a way to specify the accessibilityIdentifier
(not the accessibilityLabel
) for React Native?
I’d like to add an accessibilityIdentifier
to a React Native component, so that I can use Xcode’s UI testing to navigate around my app.
Is there a way to specify the accessibilityIdentifier
(not the accessibilityLabel
) for React Native?
You can add an accessibilityIdentifier
on React Native components (View, Text, Image...) using the testID property. This gets added to the component as a accessibilityIdentifier
on iOS.
Note that it doesn't work on custom components.
Here's an example:
<TextInput
placeholderTextColor="#dddddd"
style={[styles.main, styles.textColor]}
placeholder="Add a new todo item"
onChangeText={this.handleInputChanges}
value={inputValue}
testID="addToDoItem"
/>
accessible={true}
and/or accessibilityLabel="something"
, you can have a bunch of undesired effect. A proper answer would explain to everyone how they are related and what are solution for each case. –
Locksmith © 2022 - 2024 — McMap. All rights reserved.