Marionette Harness

raw JSON →
5.0.0 verified Sat May 09 auth: no python

Marionette Harness is a Python test automation framework for Firefox's Marionette protocol, used for Gecko-based browser automation. The current version is 5.0.0, released with support for Python 3 and asynchronous test execution. Release cadence is irregular, tied to Firefox releases.

pip install marionette-harness
error ModuleNotFoundError: No module named 'marionette'
cause Trying to import the old 'marionette' package instead of 'marionette_harness'.
fix
Use 'from marionette_harness import ...' instead.
error ImportError: cannot import name 'Marionette' from 'marionette_harness'
cause Marionette client class is in the separate 'marionette_driver' package, not in 'marionette_harness'.
fix
Install marionette-driver and import from 'marionette_driver'.
error Error: The browser is not responding. The connection to Marionette server is lost.
cause Firefox is not launched with Marionette enabled (--marionette flag) or geckodriver is missing.
fix
Launch Firefox with --marionette flag or ensure geckodriver is installed and in PATH.
breaking In version 5.0.0, the package was renamed from 'marionette' to 'marionette-harness' on PyPI. Old import paths (e.g., 'from marionette import ...') no longer work.
fix Ensure your installation uses 'marionette-harness' and imports from 'marionette_harness'.
deprecated Python 2 support is dropped; the harness now requires Python 3.6+.
fix Upgrade to Python 3 environment.
gotcha The marionette-driver package (imported via 'from marionette_driver import Marionette') is a separate dependency and must be installed explicitly or via marionette-harness[geckodriver].
fix Install marionette_driver: pip install marionette-driver, or use the optional dependency.
pip install 'marionette-harness[geckodriver]'

Basic test using MarionetteTestCase. Requires Firefox with Marionette enabled (--marionette flag).

from marionette_driver import Marionette
from marionette_harness import MarionetteTestCase

class TestBasic(MarionetteTestCase):
    def test_navigate(self):
        self.marionette.navigate('https://example.com')
        self.assertIn('Example', self.marionette.title)

if __name__ == '__main__':
    from marionette_harness import MarionetteHarness
    MarionetteHarness().run_tests()