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

Uploaded Python 3

File details

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

File metadata

  • Download URL: headless_driver-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f709553f9ac0d39f00ab12543153fc8c4dfcf9f62a0dfcc7b8992107299d165b
MD5 07513a335c77995f2edacc21ea35e80f
BLAKE2b-256 7503be523f390c018c35ac349d5a67da64a5a6d32252c243dbfe369c459c5832

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for headless_driver-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28e743aac7a37035b53511aa4a9b55e43e42aff3f38e830edda90e8874665231
MD5 9e53e3d3f9a3671094065481f66f9361
BLAKE2b-256 7841851b9d250a4ed234cedabb2c32d615a639d4e7ad1ff8c684233a20464115

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