Skip to content

feat: improve React Native support with new locators and assertions#4

Open
krismuhi wants to merge 1 commit intomainfrom
feat/rn-locator-improvements
Open

feat: improve React Native support with new locators and assertions#4
krismuhi wants to merge 1 commit intomainfrom
feat/rn-locator-improvements

Conversation

@krismuhi
Copy link
Copy Markdown
Member

Summary

  • React Native role mapping — adds ReactTextView, ReactEditText, ReactImageView, ReactScrollView to ROLE_TYPE_MAP so getByRole('text'), getByRole('textfield'), getByRole('image'), getByRole('list') work on Android RN apps. ReactViewGroup maps to button only when clickable="true" or accessible="true" to avoid false positives.
  • Full resource-id matching — stores resourceId on ViewNode so getByTestId('com.example:id/login_button') works alongside the existing short form getByTestId('login_button'). Useful for Appium migration.
  • getByPlaceholder() locator — new locator strategy for matching elements by placeholder text (Android hint, iOS placeholderValue). Supports exact and substring matching.
  • New assertionstoBeDisabled(), toBeSelected(), toHaveFocus(), toBeChecked(), toHaveValue() with full .not negation and auto-retry support.
  • New Locator queriesisSelected(), isFocused(), isChecked(), getValue().
  • isChecked on ViewNode — populated from Android checkable/checked attributes.
  • Framework support table in README showing what works out of the box.

Test plan

  • All 77 existing + new unit tests pass
  • Verify role mapping against a real React Native app on Android
  • Verify getByPlaceholder on both iOS and Android
  • Review framework support table for accuracy

- Add RN-specific types (ReactTextView, ReactEditText, ReactImageView,
  ReactScrollView) to ROLE_TYPE_MAP so getByRole works on Android RN apps
- Smart ReactViewGroup → button mapping (only when clickable/accessible)
- Store full Android resource-id on ViewNode for exact testId matching
- Add getByPlaceholder() locator strategy
- Add isChecked field to ViewNode, populated from Android checked attr
- Add assertions: toBeDisabled, toBeSelected, toHaveFocus, toBeChecked, toHaveValue
- Add Locator queries: isSelected, isFocused, isChecked, getValue
- Add framework support table to README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant