Automation Tips for React Native App Development

You are here:
< All Topics
  • To identify elements on both iOS and Android platforms, we should assign “testID” and “accessibilityLabel” to every view in react native.
  • We can assign “testID” and “accessibilityLabel” as string literals but it is better to store them in a separate .JS file and access it from the .JS file, So all the automation IDs
    reside in one place.
  • You can create a separate .JS file and store all automation IDs like follows:


export default (automationIds = {
password: 'Password',
userName: 'USER NAME',
emailAddress: 'EMAIL ADDRESS',
nameTextField: 'nameTextField',
  • You can import the your automationIds JS file as follows :
import automationIds from '../../appConfig/automationIds';
  • Once you have imported the automationIds JS file, you can use all automation Ids declared in file and assign it to any element.

For Example:

onSubmitEditing={() => Keyboard.dismiss()}

Here we have assigned “nameTextField” as an identifier to the TextInput element. The same identifier will be used for iOS and Android platforms.

Table of Contents