openwisp / openwisp/openwisp-utils

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

Open Beginner friendly
#717 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
93
Forks
104
Avg merge
14h 10m
Merged PRs (30d)
22

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the get_chrome_webdriver entry point and compare its options with the existing GECKO_LOG handling for Firefox. Trace how the CHROMEDRIVER_LOG environment variable should control ChromeDriver logging, then verify that enabling it produces the requested logfile without changing the default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.