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.3.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.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynpress-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 29a529530f4e010e0f686e6fb7a34aa7eecd7570cca3a7a18726b7bb4a32ba4b
MD5 efcdb3103c853368ea5420037e0d5c34
BLAKE2b-256 8bf082c05e1be4aeef00dbb8c07265db0a159b7f54e6ac7567495cc20000dafc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynpress-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f161b28cb1d521b451d2b32e08a7ed3d4345aa8dc449a13665b02279e1822746
MD5 1877440fd93157d327653022b0d4211b
BLAKE2b-256 c22c2df48d70f8bd0158c7306c419c18ca330148c5c1b68b25e6ec725b6fcba6

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