A simple Python package for managing Selenium Chrome drivers in headless mode.
Project description
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 stringheadless: Run Chrome in headless mode (default: True)chrome_driver_path: Path to chromedriver executableadditional_args: List of extra Chrome argumentsremote_url: Use remote Selenium server if provided
Methods
get_driver(): Returns a Selenium WebDriver instancequit(): Quits the driver and cleans up user data
Running Tests
python -m unittest discover tests
License
MIT
Project details
Release history Release notifications | RSS feed
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.3.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file headless_driver-0.0.3.tar.gz.
File metadata
- Download URL: headless_driver-0.0.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ca268e5eef65ec798e26efb171643baef01eb7a81543d685bbaed309eb2fd9
|
|
| MD5 |
cb48a947c7d57d7dd6f37fce96333766
|
|
| BLAKE2b-256 |
74723d3a26ecf06b5c7a645657654f8a35ac9a57569b1a06de627b9a1cb9a9dd
|
File details
Details for the file headless_driver-0.0.3-py3-none-any.whl.
File metadata
- Download URL: headless_driver-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5e7fc4cdea867b59a241b47acf587c7b43562007cd74e55069810e621ac4598
|
|
| MD5 |
265ec5645e149bee53a6396f9567a0b4
|
|
| BLAKE2b-256 |
6f24900ce7283c4088be30b4dbd5f29345dc7f614786f98fc5a46a7748035176
|