[chores] Made SeleniumTestMixin to use its own find_element method#719
Conversation
Instead of using driver.find_element, the public methods of SeleniumTestMixin shall use `self.find_element` and pass the driver instance.
📝 WalkthroughWalkthrough
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (3 errors, 2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 370-378: Update the find_element calls in the login flow to ensure
the supplied driver is forwarded through the wait_for_visibility path, including
the username, password, and submit-element lookups. Keep the final element
lookup and visibility wait operating on the same driver instance rather than
falling back to self.web_driver.
- Around line 370-378: Add an in-process regression test alongside the existing
Selenium tests that performs login and logout with a distinct custom driver,
covering the username, password, submit, and logout interactions. Verify the
helper’s waits and element lookups use the supplied driver rather than the
default driver, while preserving the existing default-driver coverage.
🪄 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: be3ec4e2-96ab-491b-9227-b8bf329b0a0a
📒 Files selected for processing (2)
openwisp_utils/tests/selenium.pyrequirements-test.txt
📜 Review details
⏰ Context from checks skipped due to timeout. (19)
- GitHub Check: CodeQL
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=5.0.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.0.0
- GitHub Check: Python==3.11 | django~=5.0.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (actions)
- GitHub Check: Analyze (python)
- GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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:
requirements-test.txtopenwisp_utils/tests/selenium.py
**/*.{md,rst,txt}
📄 CodeRabbit inference engine (AGENTS.md)
Update documentation when behavior, settings, public APIs, setup steps, QA rules, or supported versions change
Files:
requirements-test.txt
**/*.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
Runopenwisp-qa-formatafter editing
Prefer in-process tests so coverage tools can measure changed code
When checking coverage for a changed module, usepython -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/**/*.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
🧠 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
🪛 LanguageTool
requirements-test.txt
[grammar] ~2-~2: Ensure spelling is correct
Context: ...roller/archive/refs/heads/master.tar.gz freezegun pytest pytest-mock
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (1)
requirements-test.txt (1)
2-2: LGTM!
Code Review SummaryStatus: No Issues Found | Recommendation: Merge This incremental update forwards the supplied Files Reviewed (1 file)
Previous Review Summary (commit 64cd554)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 64cd554)Status: No Issues Found | Recommendation: Merge This is a clean refactor. Files Reviewed (2 files)
Reviewed by claude-opus-4.8 · Input: 20 · Output: 3.3K · Cached: 245.6K |
|
@coderabbitai resolve |
✅ Action performedComments resolved and changes approved. |
Checklist
Description of Changes
Instead of using driver.find_element, the public methods of SeleniumTestMixin shall use
self.find_elementand pass the driver instance.