openwisp / openwisp/openwisp-utils
[feature] Add CHROMEDRIVER_LOG env var to enable logfile in get_chrome_webdriver
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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