Skip to main content

A simple Python package for managing Selenium Chrome drivers in headless mode.

Project description

PyPI version License: MIT Build Status

headless-driver

A simple Python package for managing Selenium Chrome drivers in headless mode.

Features

  • Headless Chrome driver management
  • Temporary user data directory
  • Custom window size and user agent
  • Easy cleanup and context manager support
  • Remote and local driver support

Installation

pip install headless-driver

Usage

from headless import Headless

hl = Headless()
driver = hl.get_driver()
driver.get("https://example.com")
print(driver.title)
hl.quit()

Or use as a context manager:

from headless import Headless

with Headless() as driver:
    driver.get("https://example.com")
    print(driver.title)

API Documentation

Headless class

Headless(
    user_data_dir: Optional[str] = None,
    window_size: Tuple[int, int] = (1920, 1080),
    user_agent: Optional[str] = None,
    headless: bool = True,
    chrome_driver_path: Optional[str] = '/opt/homebrew/bin/chromedriver',
    additional_args: Optional[List[str]] = None,
    remote_url: Optional[str] = None,
)
  • user_data_dir: Path for Chrome user data (temporary if not provided)
  • window_size: Browser window size (default: 1920x1080)
  • user_agent: Custom user agent string
  • headless: Run Chrome in headless mode (default: True)
  • chrome_driver_path: Path to chromedriver executable
  • additional_args: List of extra Chrome arguments
  • remote_url: Use remote Selenium server if provided

Methods

  • get_driver(): Returns a Selenium WebDriver instance
  • quit(): Quits the driver and cleans up user data

Running Tests

python -m unittest discover tests

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

headless_driver-0.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

headless_driver-0.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file headless_driver-0.0.2.tar.gz.

File metadata

  • Download URL: headless_driver-0.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for headless_driver-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c462fd0c543c78e9cf3c279bbfefb3fd6603863a54b7b411a14295d92ea54bd8
MD5 e7a53c96c3b907e4d5d9c4aca2520c76
BLAKE2b-256 cd7fc020ef22c3619d9c9dae5881b81540468c09412392715c8f0c5aff310920

See more details on using hashes here.

File details

Details for the file headless_driver-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for headless_driver-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 25fb71f4183d28e78c49a6d691c710dc538fd8b8ba62d3e73234e09b1416b1c9
MD5 3b9f63b74d4ad5490c5ebd0ed95945f9
BLAKE2b-256 b3a910d3b5196554accfab54967b6b12dbfba5fee3a08fa8a5b62781f7c25912

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