Skip to content

[feature] Add CHROMEDRIVER_LOG env var to enable logfile in get_chrome_webdriver #717

Description

@asmodehn

Is your feature request related to a problem? Please describe.
When debugging selenium issues with chrome, we currently cannot get the log.

Describe the solution you'd like
Just like we have a GECKO_LOG for firefox, we should have a CHROMEDRIVER_LOG for chrome.

Additional context
I am already internally using a version that works, but could probably be improved:

    @classmethod
    def get_chrome_webdriver(cls):
        options = webdriver.ChromeOptions()
        options.page_load_strategy = "eager"
        if os.environ.get("SELENIUM_HEADLESS", False):
            options.add_argument("--headless")
        CHROME_BIN = os.environ.get("CHROME_BIN", None)
        if CHROME_BIN:
            options.binary_location = CHROME_BIN
        options.add_argument("--window-size=1366,768")
        options.add_argument("--ignore-certificate-errors")
        options.add_argument("--no-sandbox")
        options.add_argument("--disable-gpu")
        options.add_argument("--disable-dev-shm-usage")
        options.add_argument("--disable-features=VizDisplayCompositor")
        options.add_argument(f"--remote-debugging-port={free_port()}")
        options.set_capability("goog:loggingPrefs", {"browser": "ALL"})
        kwargs = dict(options=options)
        CHROMEDRIVER_LOG = os.environ.get("CHROMEDRIVER_LOG", None)
        if CHROMEDRIVER_LOG:
            kwargs["service"] = webdriver.ChromeService(
                service_args=["--verbose", "--log-path=chromedriver.log"]
            )
        return webdriver.Chrome(**kwargs)

Metadata

Metadata

Assignees

No one assigned

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions