Skip to main content

A Python client for interacting with React Native applications via the Hermes debugger

Project description

React Native Debugger Client

A Python client for interacting with React Native applications via the Hermes debugger.

Features

  • Connect to a React Native app's Hermes debugger
  • Execute JavaScript code in the React Native context
  • Interact with UI elements (tap, scroll, enter text)
  • Get the React component tree
  • Navigate between screens
  • Debug utilities (toggle debug features, performance overlay)
  • Widget finder utilities

Installation

pip install react-native-debugger-client

Usage

Basic Usage

from react_native_debugger_client import ReactNativeDebuggerClient

# Connect to a React Native app running on your device or emulator
client = ReactNativeDebuggerClient(device_ip="localhost", metro_port=8081)
success, message = client.connect()

if success:
    # Get the UI tree
    ui_tree = client.get_ui_tree()
    
    # Tap a button
    client.tap_element(test_id="submit_button")
    
    # Enter text in an input field
    client.enter_text(test_id="email_input", text="user@example.com")
    
    # Scroll down
    client.scroll("down")
    
    # Navigate to a screen
    client.navigate_to_screen("HomeScreen")
    
    # Execute custom JavaScript
    client.execute_js("console.log('Hello from Python!');")
    
    # Close the connection when done
    client.close()

Context Manager

You can also use the client as a context manager:

with ReactNativeDebuggerClient() as client:
    success, message = client.connect()
    if success:
        client.tap_element(text="Login")

API Reference

Connection

  • __init__(device_ip="localhost", metro_port=8081) - Initialize the client
  • connect(timeout=10) - Connect to the React Native app's Hermes debugger
  • close() - Close the connection

UI Interaction

  • tap_element(test_id=None, text=None, timeout=5) - Tap an element by test ID or text content
  • enter_text(test_id, text, timeout=5) - Enter text into a TextInput element
  • scroll(direction="down", distance=300, timeout=5) - Scroll the screen
  • scroll_element(test_id=None, direction="down", distance=300, timeout=5) - Scroll a specific element

Navigation

  • get_current_screen(timeout=5) - Get the name of the current screen
  • navigate_to_screen(screen_name, params=None, timeout=5) - Navigate to a specific screen

Widget Utilities

  • find_widgets(search_by="all", search_value="", timeout=5) - Find widgets matching criteria
  • tap_widget_by_key(key_value, timeout=5) - Tap a widget by its key
  • tap_widget_by_text(text, timeout=5) - Tap a widget by its text content
  • tap_widget_by_type(widget_type, timeout=5) - Tap a widget by its type
  • tap_widget_by_tooltip(tooltip_text, timeout=5) - Tap a widget by its tooltip text
  • enter_text_by_key(key_value, text, timeout=5) - Enter text in a widget by its key
  • enter_text_by_type(widget_type, text, timeout=5) - Enter text in a widget by its type
  • enter_text_by_text(widget_text, text, timeout=5) - Enter text in a widget by its text content

Debug Utilities

  • toggle_debug_paint_feature(enable=True, timeout=5) - Toggle debug paint feature
  • toggle_performance_overlay(enable=True, timeout=5) - Toggle performance overlay
  • toggle_repaint_rainbow(enable=True, timeout=5) - Toggle repaint rainbow
  • toggle_debug_banner(enable=True, timeout=5) - Toggle debug banner

Requirements

  • Python 3.7+
  • requests>=2.28.0
  • websocket-client>=1.3.0

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

react_native_debugger_client-0.0.1.dev1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file react_native_debugger_client-0.0.1.dev1.tar.gz.

File metadata

File hashes

Hashes for react_native_debugger_client-0.0.1.dev1.tar.gz
Algorithm Hash digest
SHA256 49253700b8866a0b648e846f12020ea629c394bc7ed5b8f88e92a694335c1e13
MD5 1652a5f2c0bd93bbcaaca4347a91b7c1
BLAKE2b-256 fc41d24242aa5ad76022fe46a743f9dc781fbb9784908fa3b7234969b6a33857

See more details on using hashes here.

File details

Details for the file react_native_debugger_client-0.0.1.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for react_native_debugger_client-0.0.1.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 02f4f06fc8c2ca62196982ee944920b1ddaa99e3437409252b5daadf2ec65c16
MD5 f2c1035ca62a684bd6bad3bcd52a08a6
BLAKE2b-256 13ad5a5f4b74fbf6bfa164db3c3333fe070c78db5e4409619b7808cdbcdbd2cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page