Skip to main content

Add your description here

Project description

Pynpress 🐍

Pynpress is a Python-based E2E (End-to-End) testing library for Web3 dApps, heavily inspired by the renowned Synpress.

Built on top of Playwright for Python, Pynpress allows you to automate interactions with cryptocurrency wallets (like MetaMask) and dApps directly from your Python test suites.

⚠️ Note: This project is currently in early development.

🌟 Features

  • Wallet Support: Out-of-the-box support for MetaMask (more coming soon).
  • Playwright Native: Leverages the power and speed of Playwright.
  • Easy Setup: Automatically launches a browser with the wallet extension pre-loaded.
  • Deterministic: Initialize wallets with seed phrases and passwords for reproducible tests.
  • Automation: built-in helpers for common wallet interactions:
    • Connect to dApps (approve_connect)
    • Sign messages (Soon)
    • Confirm transactions (Soon)

📦 Installation

Requires Python 3.10+.

# Install pynpress
pip install pynpress

# Install Playwright browsers
playwright install

🚀 Usage

Here is a basic example of how to launch Pynpress with MetaMask and interact with a dApp.

1. Prepare Environment

Ensure you have the wallet extension downloaded (e.g., ./metamask-chrome-13.15.0).

2. Write the Test

from pynpress import Launcher, WalletType

def main():
    # Initialize launcher for MetaMask
    launcher = Launcher(WalletType.METAMASK)
    
    # Launch browser with wallet setup
    context, wallet = launcher.launch(
        seed_phrase="your twelve word seed phrase ...",
        password="securePassword123",
        headless=False,
        extension_path="./metamask-chrome-13.15.0"
    )

    # Create a new page and navigate to your dApp
    page = context.new_page()
    page.goto("https://metamask.github.io/test-dapp/")
    
    # Interact with the dApp (e.g., click 'Connect')
    connect_btn = page.locator("#connectButton")
    if connect_btn.is_visible():
        connect_btn.click()
        
        # Approve the connection in MetaMask
        print("Approving connection...")
        wallet.approve_connect()
        print("Connected!")

    # Clean up
    context.close()

if __name__ == "__main__":
    main()

🛠 Architecture

Pynpress wraps Playwright's BrowserContext to inject Web3 wallet extensions. It provides a high-level Wallet interface that abstracts away the complexity of switching contexts and interacting with the extension's popups.

🤝 Contributing

Contributions are welcome! Please check out the issues or submit a Pull Request.

📄 License

MIT

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

pynpress-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

pynpress-0.1.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pynpress-0.1.2.tar.gz.

File metadata

  • Download URL: pynpress-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pynpress-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3331d68dff50607f4a4e5bc9b53ab71819355abf5d4e2030d921cef262a9c235
MD5 738e64b897e0b2c488166579edf1bf88
BLAKE2b-256 04875cfab51f4c346781190e08ec24d7f784865a387c3eef13381e08f19833f2

See more details on using hashes here.

File details

Details for the file pynpress-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pynpress-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pynpress-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5c84f3bf334331a31d71f0c91e5ac728684c1d4b0a08cc079caf3b2526435d15
MD5 e6cef8402f8739118286157bd7ec7532
BLAKE2b-256 1e2e4739e61b6b7b47e6d60ee38eca76c7ffaaf9349dabea471caab8de74dde7

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