Skip to main content

Python SDK for Axon browser automation

Project description

Axon Python SDK

A Python client library for Axon browser automation.

Installation

pip install axon-browser

Quick Start

import asyncio
from axon import Axon

async def main():
    async with Axon("http://localhost:8020/api/v1") as axon:
        # Create a session
        session = await axon.create_session("mysession")
        print(f"Created session: {session.session_id}")
        
        # Navigate to a URL
        await axon.navigate("mysession", "https://github.com")
        
        # Get snapshot
        snapshot = await axon.snapshot("mysession")
        print(f"Page title: {snapshot.title}")
        
        # Click an element
        result = await axon.click("mysession", "e1")
        print(f"Action result: {result.success}")

asyncio.run(main())

Configuration

The Axon client can be configured via:

  1. Constructor parameter:

    axon = Axon("http://localhost:8020/api/v1")
    
  2. Environment variable:

    export AXON_API_URL=http://localhost:8020/api/v1
    
    axon = Axon()  # Uses AXON_API_URL env var
    

API Reference

Session Management

# Create a session
session = await axon.create_session("mysession")

# Get session info
info = await axon.get_session("mysession")

# List all sessions
sessions = await axon.list_sessions()

# Delete a session
await axon.delete_session("mysession")

Navigation

# Navigate to a URL
await axon.navigate("mysession", "https://github.com")

Snapshots

# Get page snapshot
snapshot = await axon.snapshot("mysession")

# Print page elements
for element in snapshot.elements:
    print(f"{element.role}: {element.name}")

Actions

# Click
await axon.click("mysession", "e1")

# Fill input
await axon.fill("mysession", "e2", "Hello World")

# Hover
await axon.hover("mysession", "e3")

# Select option
await axon.select("mysession", "e4", "option1")

# Generic action
await axon.act("mysession", "click", "e1")

Find and Act

# Find element by semantic description and perform action
result = await axon.find_and_act(
    "mysession", 
    "click", 
    "search button"
)

Development

# Clone the repository
git clone https://github.com/rennissance-jomt/axon
cd axon/python

# Install in development mode
pip install -e .

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Lint
ruff check .

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

axon_browser-1.0.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.

axon_browser-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file axon_browser-1.0.0.tar.gz.

File metadata

  • Download URL: axon_browser-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for axon_browser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4c4d43e9e06389350dfab50b5ae29be88fe11dc836ae60c21633409fc66f61c7
MD5 28fbd462321b8052cb41ca4b7d896604
BLAKE2b-256 93e6560d8a463fa1c13d38883d0688061cdc67a9cf252bc17b215b54432e716d

See more details on using hashes here.

File details

Details for the file axon_browser-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: axon_browser-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for axon_browser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a354354c3bf747df48c9980b76169f6845f2a4535f4a1fe2185e3aa0871b514
MD5 6961d27e036218392be5ae2ac3360e99
BLAKE2b-256 e74e7f31e7caa570f6a5e45be6456b9db43727559499a3c6dd5690a9c3e70796

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