Skip to content

Conversation

cgoldberg
Copy link
Contributor

@cgoldberg cgoldberg commented Jul 18, 2025

User description

💥 What does this PR do?

This PR updates the chromium_driver fixture used in the tests in bidi_webextension_tests.py so they use the --browser-binary and --driver-binary args passed by bazel. This will allow these tests to use pinned browsers when running in RBE.

🔄 Types of changes

  • Build/Test

PR Type

Tests


Description

  • Update chromium driver fixture to use pinned browsers

  • Add support for browser binary and driver executable paths

  • Enable RBE compatibility for BiDi webextension tests


Diagram Walkthrough

flowchart LR
  A["Test Configuration"] --> B["Browser Binary Path"]
  A --> C["Driver Executable Path"]
  B --> D["Chromium Options"]
  C --> E["Browser Service"]
  D --> F["Chromium Driver"]
  E --> F
Loading

File Walkthrough

Relevant files
Tests
bidi_webextension_tests.py
Configure pinned browser support for chromium driver         

py/test/selenium/webdriver/common/bidi_webextension_tests.py

  • Added browser service class selection for Chrome/Edge
  • Implemented binary location configuration from test options
  • Added executable path support for driver service
  • Updated temp directory prefix to be more generic
+14/-2   

@selenium-ci selenium-ci added the C-py Python Bindings label Jul 18, 2025
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Cleanup

The temporary directory created with tempfile.mkdtemp() is not being cleaned up after the test completes. This could lead to disk space issues over time as temporary directories accumulate.

temp_dir = tempfile.mkdtemp(prefix="chromium-profile-")

chromium_options.enable_bidi = True
chromium_options.enable_webextensions = True
chromium_options.add_argument(f"--user-data-dir={temp_dir}")
Undefined Variable

The variable temp_dir is used on line 144 but is only defined within the conditional block on line 140. This will cause a NameError if the code path doesn't execute the assignment.

temp_dir = tempfile.mkdtemp(prefix="chromium-profile-")

chromium_options.enable_bidi = True
chromium_options.enable_webextensions = True
chromium_options.add_argument(f"--user-data-dir={temp_dir}")

Copy link
Contributor

qodo-merge-pro bot commented Jul 18, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle unsupported driver options

Add an else clause to handle unsupported driver options. Without this,
browser_service could be undefined if an unexpected driver option is passed,
leading to a NameError when creating the service.

py/test/selenium/webdriver/common/bidi_webextension_tests.py [133-138]

 if driver_option == "chrome":
     browser_class = webdriver.Chrome
     browser_service = webdriver.ChromeService
 elif driver_option == "edge":
     browser_class = webdriver.Edge
     browser_service = webdriver.EdgeService
+else:
+    raise ValueError(f"Unsupported driver option: {driver_option}")
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly points out that if driver_option is not 'chrome' or 'edge', browser_service will be unassigned, leading to a NameError. Adding an else clause to handle this case improves the code's robustness.

Medium
  • Update

@cgoldberg
Copy link
Contributor Author

The 3 CI failures are unrelated to this change.

@cgoldberg cgoldberg merged commit c896d2d into SeleniumHQ:trunk Jul 18, 2025
14 of 16 checks passed
@cgoldberg cgoldberg deleted the py-webextension-tests-pinned-rbe branch July 18, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants