Skip to content

--headless has no effect for Firefox in some Linux environments #767

@vytas7

Description

@vytas7

I'd like to basically reopen #701 : even if --headless is set (moreover, it should be default on Linux), it has no effect.
geckodriver.log reads:

1609613050327   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "--marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile0dBR8Z"

Using FirefoxOptions.headless (see the PoC patch below) works for me, but AFAICT it should be applied to more places (?), and not sure how that plays together with firefox_capabilities:

--- a/seleniumbase/core/browser_launcher.py
+++ b/seleniumbase/core/browser_launcher.py
@@ -690,7 +690,10 @@ def get_local_driver(
                                   "%s" % e)
                         sys.argv = sys_args  # Put back the original sys args
                 if "linux" in PLATFORM or not headless:
+                    firefox_options = webdriver.FirefoxOptions()
+                    firefox_options.headless = headless
                     firefox_driver = webdriver.Firefox(
+                        firefox_options=firefox_options,
                         firefox_profile=profile,
                         capabilities=firefox_capabilities)
                 else:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUh oh... Something needs to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions