Skip to content

[feature] Add ChromeDriver log output #717#718

Closed
iamdhrv wants to merge 1 commit into
openwisp:masterfrom
iamdhrv:issues/717-chromedriver-log
Closed

[feature] Add ChromeDriver log output #717#718
iamdhrv wants to merge 1 commit into
openwisp:masterfrom
iamdhrv:issues/717-chromedriver-log

Conversation

@iamdhrv

@iamdhrv iamdhrv commented Jul 10, 2026

Copy link
Copy Markdown

Summary

  • add optional verbose ChromeDriver file logging when CHROMEDRIVER_LOG is set
  • keep the default Chrome WebDriver configuration unchanged
  • cover enabled and opt-in behavior with mocked Selenium constructors

Validation

  • mocked ChromeDriver configuration check
  • isort --check-only openwisp_utils/tests/selenium.py tests/test_project/tests/test_selenium_mixin.py
  • black --check openwisp_utils/tests/selenium.py tests/test_project/tests/test_selenium_mixin.py
  • flake8 openwisp_utils/tests/selenium.py tests/test_project/tests/test_selenium_mixin.py

Fixes #717

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@iamdhrv, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6a5006a6-3865-46b4-876b-fbe8886f42cd

📥 Commits

Reviewing files that changed from the base of the PR and between 4a39370 and a18cf05.

📒 Files selected for processing (3)
  • docs/developer/test-utilities.rst
  • openwisp_utils/tests/selenium.py
  • tests/test_project/tests/test_selenium_mixin.py
📝 Walkthrough

Walkthrough

get_chrome_webdriver() now constructs Chrome with keyword arguments and conditionally adds a verbose ChromeService writing to chromedriver.log when CHROMEDRIVER_LOG is set. New tests mock Chrome and ChromeService to verify both the enabled and cleared environment-variable paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Environment
  participant SeleniumTestMixin
  participant ChromeService
  participant ChromeWebDriver
  Environment->>SeleniumTestMixin: Read CHROMEDRIVER_LOG
  SeleniumTestMixin->>ChromeService: Create verbose service when set
  SeleniumTestMixin->>ChromeWebDriver: Construct with options and optional service
Loading

Suggested labels: enhancement


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
General Rules ❌ Error CHROMEDRIVER_LOG adds a new setting, but the Selenium docs weren’t updated; the linked issue also has labels but no project assignment. Document CHROMEDRIVER_LOG in docs/developer/test-utilities.rst. If this PR is from a non-org contributor, put issue #717 into one of the required OpenWISP projects.
Features ⚠️ Warning Issue #717 exists and is triaged, but the feature is not documented; the Selenium docs still omit CHROMEDRIVER_LOG. Add CHROMEDRIVER_LOG documentation to the Selenium test-utilities docs (or changelog) so the new feature is discoverable.
Changes ⚠️ Warning Tests were added, but the Selenium docs weren’t updated to mention the new CHROMEDRIVER_LOG behavior. Add documentation for CHROMEDRIVER_LOG/chromedriver.log in the SeleniumTestMixin docs, mirroring the existing GECKO_LOG note.
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests add CHROMEDRIVER_LOG support and preserve default Chrome WebDriver behavior as requested in #717.
Out of Scope Changes check ✅ Passed The changes stay focused on ChromeDriver logging and matching tests, with no unrelated code paths introduced.
Bug Fixes ✅ Passed The patch fixes the ChromeDriver logging path and adds deterministic mocked regression tests that fail if the new service setup is removed; default behavior stays unchanged.
Title check ✅ Passed The title is descriptive, matches the ChromeDriver logging change, and includes the required type prefix and issue reference.
Description check ✅ Passed The description covers summary, validation, and issue reference, but it omits the checklist and screenshot sections from the template.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openwisp_utils/tests/selenium.py`:
- Around line 284-287: Update get_chrome_webdriver so CHROMEDRIVER_LOG uses a
worker-unique log filename when tests run in parallel, incorporating the
existing free_port() debugging-port value or equivalent unique suffix; preserve
the current filename for non-parallel runs and keep the change consistent with
the geckodriver.log handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6b6b53d1-3784-4301-ad76-6d0bddc5990c

📥 Commits

Reviewing files that changed from the base of the PR and between 9f3639a and 4a39370.

📒 Files selected for processing (2)
  • openwisp_utils/tests/selenium.py
  • tests/test_project/tests/test_selenium_mixin.py
📜 Review details
⏰ Context from checks skipped due to timeout. (15)
  • GitHub Check: CodeRabbit / Review
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=5.2.0
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{py,html,txt}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_utils/tests/selenium.py
  • tests/test_project/tests/test_selenium_mixin.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Place imports at the top of the file; only defer imports when necessary (e.g., Django model imports inside functions or methods where the app registry is not yet ready)
Avoid unnecessary blank lines inside function and method bodies
Add or update tests for every behavior change
Run openwisp-qa-format after editing
Prefer in-process tests so coverage tools can measure changed code
When checking coverage for a changed module, use python -m pytest <test_path> --cov=<dotted.module.path> --cov-report=term-missing
Watch for unsafe file paths, unsafe subprocess usage, token or secret exposure, and changes that could weaken QA or release safeguards
Write comments and docstrings only when they explain why code is shaped a certain way; place comments before the relevant code block instead of scattering them inside it

Files:

  • openwisp_utils/tests/selenium.py
  • tests/test_project/tests/test_selenium_mixin.py
**/tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

For bug fixes, write the regression test first, run it against the unfixed code, confirm it fails for the expected reason, then implement the fix

Files:

  • openwisp_utils/tests/selenium.py
  • tests/test_project/tests/test_selenium_mixin.py
🧠 Learnings (1)
📚 Learning: 2026-06-15T22:45:01.529Z
Learnt from: nemesifier
Repo: openwisp/openwisp-utils PR: 701
File: setup.py:72-72
Timestamp: 2026-06-15T22:45:01.529Z
Learning: When reviewing changes that require a minimum Selenium Python version for specific APIs (e.g., BiDi features like `Options.enable_bidi`, console/message handlers like `Script.add_console_message_handler`, or event handlers like `BrowsingContext.add_event_handler`), do not use the Selenium API docs site (`https://www.selenium.dev/selenium/docs/api/py/`) as the source of introduction/version history, since it reflects the latest API shape. Instead, confirm feature availability by checking the official Python changelog (`py/CHANGES` in the Selenium repo) and/or inspecting the Selenium source (tags/commits corresponding to candidate versions). Only accept the stated minimum version after verifying that the referenced APIs exist in that Selenium version (e.g., Selenium 4.32.0 includes the BiDi APIs used by openwisp-utils’ BiDi-related PR `#701` as of that version).

Applied to files:

  • openwisp_utils/tests/selenium.py
  • tests/test_project/tests/test_selenium_mixin.py
🔇 Additional comments (3)
openwisp_utils/tests/selenium.py (2)

280-288: LGTM!


284-287: ChromeService args are supported here. service_args and log_output are valid in Selenium 4.32.0, so this code can stay as-is.

tests/test_project/tests/test_selenium_mixin.py (1)

2-6: LGTM!

Also applies to: 30-56

Comment on lines +284 to +287
if CHROMEDRIVER_LOG:
kwargs["service"] = webdriver.ChromeService(
service_args=["--verbose"], log_output="chromedriver.log"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Parallel test workers share a single chromedriver.log file.

When running with --parallel, each TestCase class calls get_chrome_webdriver() independently, but all write to the same hardcoded chromedriver.log. This can cause interleaved or corrupted log output. Consider incorporating a unique suffix (e.g., the free_port() already used for debugging ports) into the log filename when parallelism is detected. This is consistent with the existing geckodriver.log pattern, so it's a pre-existing concern, but the new code propagates it to Chrome.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openwisp_utils/tests/selenium.py` around lines 284 - 287, Update
get_chrome_webdriver so CHROMEDRIVER_LOG uses a worker-unique log filename when
tests run in parallel, incorporating the existing free_port() debugging-port
value or equivalent unique suffix; preserve the current filename for
non-parallel runs and keep the change consistent with the geckodriver.log
handling.

@coveralls

coveralls commented Jul 10, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 97.643% (+0.002%) from 97.641% — iamdhrv:issues/717-chromedriver-log into openwisp:master

Allow Selenium tests to write verbose ChromeDriver logs when CHROMEDRIVER_LOG is set.\n\nFixes openwisp#717
@iamdhrv iamdhrv changed the title [tests] Add ChromeDriver log output [feature] Add ChromeDriver log output #717 Jul 10, 2026
@iamdhrv
iamdhrv force-pushed the issues/717-chromedriver-log branch from 4a39370 to a18cf05 Compare July 10, 2026 14:52
@nemesifier

Copy link
Copy Markdown
Member

Do not open PRs for issues that haven't been discussed thorougly. See Anti AI spam policy and Contributing Guidelines.

@nemesifier nemesifier closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants