Marionette Driver
raw JSON → 3.7.0 verified Fri May 01 auth: no python
A Python client for controlling Gecko-based browsers (Firefox, Firefox OS) via the Marionette protocol. Version 3.7.0, actively maintained with irregular releases.
pip install marionette-driver Common errors
error ImportError: No module named 'marionette' ↓
cause Wrong import path; the package is 'marionette_driver'.
fix
Install the correct package with 'pip install marionette-driver', then import from 'marionette_driver'.
error marionette_driver.errors.MarionetteException: Connection refused ↓
cause No Marionette server is running on the specified host:port.
fix
Start Firefox with the --marionette flag or launch geckodriver before connecting.
error AttributeError: 'Marionette' object has no attribute 'start_session' ↓
cause Outdated library version (<3.0) where the API was different.
fix
Upgrade to the latest version: 'pip install --upgrade marionette-driver'
error TypeError: start_session() got an unexpected keyword argument 'timeout' ↓
cause Passing deprecated parameters as keyword arguments in recent versions.
fix
Use capabilities dict: 'client.start_session(capabilities={"marionette": True})'
Warnings
breaking In version 3.0.0, the 'Marionette' class was moved from 'marionette.marionette' to 'marionette_driver.marionette'. Old imports will fail. ↓
fix Use 'from marionette_driver.marionette import Marionette'
deprecated The 'start_session' method parameters changed: 'timeout' and 'page_load_strategy' are now deprecated in favor of a capabilities dict. Using positional arguments may break in future releases. ↓
fix Call 'start_session(capabilities={"marionette": True})' instead.
gotcha The library expects a running Marionette server (Firefox with --marionette or geckodriver). It does not launch the browser automatically. ↓
fix Start Firefox with 'firefox --marionette' or use geckodriver before connecting.
gotcha When using with geckodriver, the host and port must match the geckodriver's listening address (default localhost:2828). ↓
fix Set environment variable MARIONETTE_HOST and MARIONETTE_PORT if not default.
Imports
- Marionette wrong
from marionette import Marionettecorrectfrom marionette_driver.marionette import Marionette - Wait
from marionette_driver.wait import Wait - By
from marionette_driver.by import By
Quickstart
from marionette_driver.marionette import Marionette
client = Marionette(host='localhost', port=2828)
client.start_session()
client.navigate('https://example.com')
print(client.title)
client.delete_session()