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+.

# Clone the repository
git clone https://github.com/lanyi1998/Pynpress.git
cd Pynpress

# Install dependencies (using uv or pip)
pip install .

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynpress-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2b495da76a8a55c7ca98eb379a9e288b194c5e4faf1517fad9c5b195a128d079
MD5 9727c6c9c03a40083662591078a81b5e
BLAKE2b-256 67180a5a12967cef0add543a8baabf21389d1306189eb638e08a21a6b9103080

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynpress-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f2f34c4e8ac8cef8d83a361d5dcf7d281ffab6f9aba3091bb22381a762c94d0
MD5 5501220d270ad2731ee87c183bd9e7a7
BLAKE2b-256 98679d8fffc697de6b9f4644d53c7266b2b8b85cb22a92a3efcf863369b05f8e

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