automation-selectors
v1.1.7
Published
accessibilityLabel and testID selectors for Android and iOS test automation
Downloads
53
Maintainers
Readme
Automation selectors for Web and Mobile Apps
A mini-package for iOS (testID), Android (accessibilityLabel) and web (data-test) property assignment based on environment & Platform.
Installation
Install automation-selectors with NPM or yarn
Add automation-selectors as a devDependency:
npm install --save-dev automation-selectors
yarn add -D automation-selectors
In your project create a module and pass in all the necessary props.
RN Example:
import { Platform } from "react-native"; import { qaID } from "automation-selectors"; export const selector = (selectorValue?: string) => { if (process.env.NODE_ENV !== "production") { return qaID(selectorValue || "", Platform.OS); } };
Web Example:
import { qaID } from "automation-selectors"; export const selector = (selectorValue?: string) => { if (process.env.NODE_ENV !== "production") { return qaID(selectorValue || "", 'web'); } };
Invoke selectors in components:
import { selector } from 'path/to/module'; ... <View {...selector('VIEW_HOMEPAGE')} /> ... };
At this point your
selector
becomes a testID, accessibilityLabel or data-test based on OS.