Skip to content

[py] Feat/16741 improve sm test#17393

Open
iampopovich wants to merge 6 commits intoSeleniumHQ:trunkfrom
iampopovich:feat/16741-improve-sm-test-py
Open

[py] Feat/16741 improve sm test#17393
iampopovich wants to merge 6 commits intoSeleniumHQ:trunkfrom
iampopovich:feat/16741-improve-sm-test-py

Conversation

@iampopovich
Copy link
Copy Markdown
Contributor

🔗 Related Issues

python version of #16741

💥 What does this PR do?

This pull request introduces Selenium Manager integration tests for Chrome, Edge, and Firefox, ensuring that both the browser and driver are resolved and downloaded into the Selenium Manager cache as expected. The changes add new test suites and corresponding workflow jobs to run these tests across multiple operating systems. Additionally, new tests are implemented to verify the correct behavior of Selenium Manager's driver and browser resolution logic.

Selenium Manager Integration Testing:

  • Added new Selenium Manager integration test suites (test-<browser>-sm) for Chrome, Edge, and Firefox in py/BUILD.bazel. These tests run only when SE_FORCE_BROWSER_DOWNLOAD is set, and they verify browser and driver resolution via Selenium Manager. A combined test-sm suite aggregates these tests.
  • Implemented new tests in chrome_service_tests.py, edge_service_tests.py, and firefox_service_tests.py to verify that both the driver and browser are resolved to executable files within the Selenium Manager cache when using DriverFinder. These tests are conditionally run based on the SE_FORCE_BROWSER_DOWNLOAD environment variable. [1] [2] [3]

Continuous Integration Workflow Updates:

  • Added a new selenium-manager-tests job to .github/workflows/ci-python.yml to run the Selenium Manager integration tests on Ubuntu, Windows, and macOS, leveraging the new test suites and ensuring cross-platform validation.

Test File Imports and Setup:

  • Updated imports in the Chrome, Edge, and Firefox service test files to include Path and DriverFinder, supporting the new integration tests. [1] [2] [3]

🔧 Implementation Notes

🤖 AI assistance

  • No substantial AI assistance used
  • AI assisted (complete below)
    • Tool(s):
    • hermes-agent with deepseek-reasoner BYOK + gemini 3.1 for feature request discovery
    • What was generated:
    • tests + assistance in yml file changes
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

🔄 Types of changes

  • New feature (non-breaking change which adds functionality and tests!)

Copilot AI review requested due to automatic review settings April 25, 2026 15:33
@selenium-ci selenium-ci added C-py Python Bindings B-build Includes scripting, bazel and CI integrations labels Apr 25, 2026
@iampopovich iampopovich changed the title Feat/16741 improve sm test py [py] Feat/16741 improve sm test Apr 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Python integration coverage for Selenium Manager’s browser/driver resolution by introducing dedicated Bazel test suites (Chrome/Edge/Firefox) and a new CI job to run them across Ubuntu/Windows/macOS.

Changes:

  • Added new test-<browser>-sm Bazel test suites (plus aggregated test-sm) that run targeted SM resolution checks.
  • Added new service-level tests for Chrome/Edge/Firefox that use DriverFinder to assert resolved browser/driver paths are executable and located as expected.
  • Added a new selenium-manager-tests GitHub Actions job in the Python CI workflow to run these suites cross-platform with --pin_browsers=false.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
py/test/selenium/webdriver/chrome/chrome_service_tests.py Adds an SM-focused resolution test using DriverFinder and cache-path assertions.
py/test/selenium/webdriver/edge/edge_service_tests.py Adds an SM-focused resolution test using DriverFinder and cache-path assertions.
py/test/selenium/webdriver/firefox/firefox_service_tests.py Adds an SM-focused resolution test using DriverFinder and cache-path assertions.
py/BUILD.bazel Adds new Bazel test-*-sm targets and an aggregated test-sm suite.
.github/workflows/ci-python.yml Adds a new CI job to run the new SM suites on ubuntu/windows/macos with --pin_browsers=false.

Comment thread py/test/selenium/webdriver/chrome/chrome_service_tests.py Outdated
Comment thread py/test/selenium/webdriver/edge/edge_service_tests.py Outdated
Comment on lines +178 to +179
assert _is_within_cache(driver_path, cache_dir), f"Driver path outside cache: {driver_path}"
assert _is_within_cache(browser_path, cache_dir), f"Browser path outside cache: {browser_path}"
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

On Windows, Selenium Manager installs Microsoft Edge via MSI into the system location rather than the SM cache (see rust/src/lib.rs where Edge-on-Windows is explicitly noted as using system path, not cache). This test unconditionally asserts browser_path is within the cache directory, which will fail on win32 even when SM is working as designed. Adjust the assertion to allow the system install path for Edge on Windows (or skip the browser-in-cache check on that platform) while still asserting the driver is in cache.

Copilot uses AI. Check for mistakes.
Comment thread py/test/selenium/webdriver/firefox/firefox_service_tests.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 25, 2026 15:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment on lines +165 to +166
cache_dir = Path(os.environ.get("SE_CACHE_PATH", Path.home() / ".cache" / "selenium"))
service = Service()
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

The Selenium Manager cache path is configured via SE_CACHE_PATH (and defaults to ~/.cache/selenium). This test reads SE_CACHE, so if CI/users override the cache location via SE_CACHE_PATH, the _is_within_cache assertions can fail even when Selenium Manager behaves correctly. Use SE_CACHE_PATH here for consistency with the other service tests and Manager configuration.

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +117
cache_dir = Path(os.environ.get("SE_CACHE_PATH", Path.home() / ".cache" / "selenium"))
service = Service()
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

The Selenium Manager cache path env var is SE_CACHE_PATH (and defaults to ~/.cache/selenium). This test uses SE_CACHE, which can cause false failures when the cache is overridden via SE_CACHE_PATH. Update this to read SE_CACHE_PATH for consistency with Selenium Manager configuration.

Copilot uses AI. Check for mistakes.
Comment thread py/BUILD.bazel
Comment on lines +816 to +817
# These only run when SE_FORCE_BROWSER_DOWNLOAD=true is set and use
# --pin_browsers=false to test SM download resolution.
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

The comment says these suites "use --pin_browsers=false", but that flag is only applied in the GitHub Actions job and isn’t enforced by the Bazel targets themselves. Consider rewording to indicate the suites are intended to be run with --pin_browsers=false (e.g., in CI) to avoid confusing local runs.

Suggested change
# These only run when SE_FORCE_BROWSER_DOWNLOAD=true is set and use
# --pin_browsers=false to test SM download resolution.
# These only run when SE_FORCE_BROWSER_DOWNLOAD=true is set and are
# intended to be run with --pin_browsers=false (for example in CI) to
# test SM download resolution.

Copilot uses AI. Check for mistakes.
@iampopovich iampopovich marked this pull request as ready for review April 25, 2026 17:06
Copilot AI review requested due to automatic review settings April 25, 2026 17:06
@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add Selenium Manager integration tests for Python bindings

🧪 Tests ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add Selenium Manager integration tests for Chrome, Edge, Firefox
• Verify driver and browser resolution via DriverFinder into SM cache
• Implement conditional tests using SE_FORCE_BROWSER_DOWNLOAD environment variable
• Add CI workflow job for cross-platform SM test execution

Grey Divider

File Changes

1. py/test/selenium/webdriver/chrome/chrome_service_tests.py 🧪 Tests +37/-0

Add Selenium Manager integration test for Chrome

• Added imports for Path and DriverFinder
• Implemented _is_within_cache() helper function to verify paths are within cache directory
• Added test_selenium_manager_resolves_browser_and_driver() test that verifies driver and browser
 are resolved to executable files within SM cache
• Test is conditionally skipped unless SE_FORCE_BROWSER_DOWNLOAD environment variable is set

py/test/selenium/webdriver/chrome/chrome_service_tests.py


2. py/test/selenium/webdriver/edge/edge_service_tests.py 🧪 Tests +37/-0

Add Selenium Manager integration test for Edge

• Added imports for Path and DriverFinder
• Implemented _is_within_cache() helper function to verify paths are within cache directory
• Added test_selenium_manager_resolves_browser_and_driver() test that verifies driver and browser
 are resolved to executable files within SM cache
• Test is conditionally skipped unless SE_FORCE_BROWSER_DOWNLOAD environment variable is set

py/test/selenium/webdriver/edge/edge_service_tests.py


3. py/test/selenium/webdriver/firefox/firefox_service_tests.py 🧪 Tests +37/-0

Add Selenium Manager integration test for Firefox

• Added imports for Path and DriverFinder
• Implemented _is_within_cache() helper function to verify paths are within cache directory
• Added test_selenium_manager_resolves_browser_and_driver() test that verifies driver and browser
 are resolved to executable files within SM cache
• Test is conditionally skipped unless SE_FORCE_BROWSER_DOWNLOAD environment variable is set

py/test/selenium/webdriver/firefox/firefox_service_tests.py


View more (2)
4. py/BUILD.bazel ⚙️ Configuration changes +45/-0

Add Bazel test targets for Selenium Manager tests

• Added test-<browser>-sm test suite targets for Chrome, Edge, and Firefox
• Configured tests to run only with SE_FORCE_BROWSER_DOWNLOAD=true and --pin_browsers=false
• Tests filter for selenium_manager keyword and include manager tag
• Created aggregated test-sm test suite combining all three browser SM tests

py/BUILD.bazel


5. .github/workflows/ci-python.yml ⚙️ Configuration changes +22/-0

Add CI workflow for cross-platform Selenium Manager tests

• Added new selenium-manager-tests CI job with OS matrix (ubuntu, windows, macos)
• Job runs Bazel tests with SM-specific flags including --pin_browsers=false and
 --test_tag_filters="manager,-ie,-safari"
• Configured to run //py:test-sm target across all three operating systems
• Job depends on build job and uses bazel.yml workflow

.github/workflows/ci-python.yml


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Apr 25, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (1)

Grey Divider


Action required

1. test-*-sm missing skip-rbe tag 📎 Requirement gap ☼ Reliability
Description
The new Selenium Manager Bazel test suites are not tagged with skip-rbe, so they can execute under
Bazel RBE even though they require network/browser downloads. This violates the requirement to
ensure Selenium Manager-specific tests run on GitHub Actions but are skipped/disabled on RBE.
Code

py/BUILD.bazel[R829-837]

+        env = {
+            "SE_FORCE_BROWSER_DOWNLOAD": "true",
+            "SE_SKIP_DRIVER_IN_PATH": "true",
+        },
+        tags = [
+            "manager",
+            "no-sandbox",
+            "requires-network",
+        ],
Evidence
PR Compliance ID 2 requires Selenium Manager tests be skipped on RBE. The new test-*-sm targets
add network-dependent tags/env but do not include skip-rbe, and the repository’s RBE test
configuration only filters out tests tagged skip-rbe, meaning these new targets remain eligible to
run on RBE if selected.

Run Selenium Manager-specific tests only on GitHub Actions (not on RBE)
py/BUILD.bazel[829-837]
.bazelrc.remote[36-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new Selenium Manager Bazel test suites (`test-*-sm`) are eligible to run under RBE because they are missing the `skip-rbe` tag. These tests require network/browser downloads and should be restricted to GitHub Actions, not RBE.

## Issue Context
RBE runs tests with `--test_tag_filters=-skip-rbe` (so only targets explicitly tagged `skip-rbe` are excluded). The new suites currently have tags like `requires-network` but not `skip-rbe`.

## Fix Focus Areas
- py/BUILD.bazel[829-837]
- .bazelrc.remote[36-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Bazel filter skips SM suites 🐞 Bug ≡ Correctness
Description
The new CI job filters by --test_tag_filters="manager,...", but py_test_suite generates
native.test_suite(name="test-*-sm") targets without propagating tags, so these suite targets don’t
have the manager tag and can be filtered out (preventing the underlying SM pytest targets from
running). This can make the new CI job pass while executing none of the intended Selenium Manager
tests.
Code

.github/workflows/ci-python.yml[R64-72]

+        bazel test \
+          --keep_going \
+          --build_tests_only \
+          --flaky_test_attempts 3 \
+          --local_test_jobs 1 \
+          --pin_browsers=false \
+          --test_size_filters medium \
+          --test_tag_filters="manager,-ie,-safari" \
+          //py:test-sm
Evidence
The workflow explicitly applies a positive tag filter manager when running //py:test-sm. In
py_test_suite, tags are forwarded to the generated pytest_test(...) rules, but the macro creates
the aggregating native.test_suite(...) without tags; py/BUILD.bazel then builds //py:test-sm
out of these untagged :test-*-sm suite targets. With Bazel tag filtering enabled, these
intermediate suite targets can be excluded because they do not match manager.

.github/workflows/ci-python.yml[52-72]
py/private/suite.bzl[18-50]
py/BUILD.bazel[815-858]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The CI job runs `bazel test` with `--test_tag_filters=manager`, but the intermediate `test-%s-sm` targets are `native.test_suite` rules created by `py_test_suite` without inheriting tags. This can cause Bazel’s tag filtering to drop those suite targets, so the job may run none of the intended Selenium Manager tests.

### Issue Context
- The job already targets `//py:test-sm`, so the positive tag filter is redundant.
- `py_test_suite` forwards `tags` to the underlying `pytest_test(...)` rules, but not to the `native.test_suite(...)` wrapper.

### Fix Focus Areas
Choose one:
- Simplest: remove the positive tag/size filters in the CI job and rely on explicit target selection.
- More robust: update `py/private/suite.bzl` so `native.test_suite(...)` receives `tags` (and any other relevant attrs) when `py_test_suite` is called.

- .github/workflows/ci-python.yml[64-72]
- py/private/suite.bzl[18-50]
- py/BUILD.bazel[815-858]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. SE_CACHE_PATH tilde not expanded 🐞 Bug ≡ Correctness
Description
The new Selenium Manager tests build cache_dir from SE_CACHE_PATH using Path(...) but do not
expand ~, so SE_CACHE_PATH=~/.cache/selenium makes the “within cache” assertions fail even when
the resolved paths are correct. This causes false-negative test failures for a common cache-path
configuration style.
Code

py/test/selenium/webdriver/chrome/chrome_service_tests.py[R165-179]

+    cache_dir = Path(os.environ.get("SE_CACHE_PATH", Path.home() / ".cache" / "selenium"))
+    service = Service()
+    driver_finder = DriverFinder(service, clean_options)
+
+    driver_path = Path(driver_finder.get_driver_path())
+    browser_path = Path(driver_finder.get_browser_path())
+
+    assert driver_path.is_file(), f"Driver not found: {driver_path}"
+    assert browser_path.is_file(), f"Browser not found: {browser_path}"
+
+    assert os.access(str(driver_path), os.X_OK), f"Driver not executable: {driver_path}"
+    assert os.access(str(browser_path), os.X_OK), f"Browser not executable: {browser_path}"
+
+    assert _is_within_cache(driver_path, cache_dir), f"Driver path outside cache: {driver_path}"
+    assert _is_within_cache(browser_path, cache_dir), f"Browser path outside cache: {browser_path}"
Evidence
All three new tests compute cache_dir with Path(os.environ.get("SE_CACHE_PATH", ...)) and then
use relative_to(cache_dir) to assert containment; Path does not expand ~ automatically. The
repo itself documents/uses ~/.cache/selenium as a default cache path representation (Java binding
constant), implying ~ is an expected form, so these tests should expand it before comparing.

py/test/selenium/webdriver/chrome/chrome_service_tests.py[147-179]
py/test/selenium/webdriver/edge/edge_service_tests.py[147-179]
py/test/selenium/webdriver/firefox/firefox_service_tests.py[98-130]
java/src/org/openqa/selenium/manager/SeleniumManager.java[61-70]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new SM integration tests treat `SE_CACHE_PATH` as a literal filesystem path and do not expand `~`. If a user/CI sets `SE_CACHE_PATH=~/.cache/selenium`, the cache containment assertions will fail because `Path("~/.cache/selenium")` won’t match the actual absolute paths returned by Selenium Manager.

### Issue Context
This affects Chrome, Edge, and Firefox SM tests since they share the same cache_dir computation and containment logic.

### Fix Focus Areas
Update cache path computation to expand `~` (and optionally normalize/resolve):
- Use `Path(...).expanduser()` (and consider `.resolve()` for normalization).

- py/test/selenium/webdriver/chrome/chrome_service_tests.py[165-179]
- py/test/selenium/webdriver/edge/edge_service_tests.py[165-179]
- py/test/selenium/webdriver/firefox/firefox_service_tests.py[116-130]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread py/BUILD.bazel
Comment on lines +829 to +837
env = {
"SE_FORCE_BROWSER_DOWNLOAD": "true",
"SE_SKIP_DRIVER_IN_PATH": "true",
},
tags = [
"manager",
"no-sandbox",
"requires-network",
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. test-*-sm missing skip-rbe tag 📎 Requirement gap ☼ Reliability

The new Selenium Manager Bazel test suites are not tagged with skip-rbe, so they can execute under
Bazel RBE even though they require network/browser downloads. This violates the requirement to
ensure Selenium Manager-specific tests run on GitHub Actions but are skipped/disabled on RBE.
Agent Prompt
## Issue description
The new Selenium Manager Bazel test suites (`test-*-sm`) are eligible to run under RBE because they are missing the `skip-rbe` tag. These tests require network/browser downloads and should be restricted to GitHub Actions, not RBE.

## Issue Context
RBE runs tests with `--test_tag_filters=-skip-rbe` (so only targets explicitly tagged `skip-rbe` are excluded). The new suites currently have tags like `requires-network` but not `skip-rbe`.

## Fix Focus Areas
- py/BUILD.bazel[829-837]
- .bazelrc.remote[36-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +64 to +72
bazel test \
--keep_going \
--build_tests_only \
--flaky_test_attempts 3 \
--local_test_jobs 1 \
--pin_browsers=false \
--test_size_filters medium \
--test_tag_filters="manager,-ie,-safari" \
//py:test-sm
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

2. Bazel filter skips sm suites 🐞 Bug ≡ Correctness

The new CI job filters by --test_tag_filters="manager,...", but py_test_suite generates
native.test_suite(name="test-*-sm") targets without propagating tags, so these suite targets don’t
have the manager tag and can be filtered out (preventing the underlying SM pytest targets from
running). This can make the new CI job pass while executing none of the intended Selenium Manager
tests.
Agent Prompt
### Issue description
The CI job runs `bazel test` with `--test_tag_filters=manager`, but the intermediate `test-%s-sm` targets are `native.test_suite` rules created by `py_test_suite` without inheriting tags. This can cause Bazel’s tag filtering to drop those suite targets, so the job may run none of the intended Selenium Manager tests.

### Issue Context
- The job already targets `//py:test-sm`, so the positive tag filter is redundant.
- `py_test_suite` forwards `tags` to the underlying `pytest_test(...)` rules, but not to the `native.test_suite(...)` wrapper.

### Fix Focus Areas
Choose one:
- Simplest: remove the positive tag/size filters in the CI job and rely on explicit target selection.
- More robust: update `py/private/suite.bzl` so `native.test_suite(...)` receives `tags` (and any other relevant attrs) when `py_test_suite` is called.

- .github/workflows/ci-python.yml[64-72]
- py/private/suite.bzl[18-50]
- py/BUILD.bazel[815-858]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Comment on lines +157 to +158
not os.environ.get("SE_FORCE_BROWSER_DOWNLOAD"),
reason="Only runs when SE_FORCE_BROWSER_DOWNLOAD is set",
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

SE_FORCE_BROWSER_DOWNLOAD is a boolean config key in Selenium Manager (parsed from env as "true"/"false"). The skip condition currently only checks for the variable being present, so SE_FORCE_BROWSER_DOWNLOAD=false would still run this test even though SM won't force downloads, making the cache assertions unreliable. Update the skipif condition to check the value (e.g., normalize and compare to "true").

Suggested change
not os.environ.get("SE_FORCE_BROWSER_DOWNLOAD"),
reason="Only runs when SE_FORCE_BROWSER_DOWNLOAD is set",
os.environ.get("SE_FORCE_BROWSER_DOWNLOAD", "").strip().lower() != "true",
reason='Only runs when SE_FORCE_BROWSER_DOWNLOAD is set to "true"',

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +153
try:
path.relative_to(cache_dir)
return True
except ValueError:
return False
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

Cache path checks will be more robust if you normalize paths first (e.g., handle SE_CACHE_PATH values containing ~ and avoid ../symlink issues). Consider expanduser()/resolve() before doing the “within cache” assertion. Also, since Python >=3.10 is required, Path.is_relative_to() can replace this custom _is_within_cache helper and avoid the try/except.

Suggested change
try:
path.relative_to(cache_dir)
return True
except ValueError:
return False
normalized_path = path.expanduser().resolve()
normalized_cache_dir = cache_dir.expanduser().resolve()
return normalized_path.is_relative_to(normalized_cache_dir)

Copilot uses AI. Check for mistakes.


@pytest.mark.skipif(
not os.environ.get("SE_FORCE_BROWSER_DOWNLOAD"),
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

SE_FORCE_BROWSER_DOWNLOAD is parsed by Selenium Manager as a boolean ("true"/"false"). This skipif only checks whether the env var exists, so SE_FORCE_BROWSER_DOWNLOAD=false would still run the test even though SM won't force downloads. Update the condition to check the value (case-insensitive) instead of mere presence.

Suggested change
not os.environ.get("SE_FORCE_BROWSER_DOWNLOAD"),
os.environ.get("SE_FORCE_BROWSER_DOWNLOAD", "").lower() != "true",

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +153
try:
path.relative_to(cache_dir)
return True
except ValueError:
return False
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

Consider normalizing paths (expanduser()/resolve()) before checking they’re under the cache directory; this avoids failures when SE_CACHE_PATH uses ~ or when SM returns paths containing ../symlinks. Since Python >=3.10 is required, Path.is_relative_to() can replace _is_within_cache and remove the try/except.

Suggested change
try:
path.relative_to(cache_dir)
return True
except ValueError:
return False
normalized_path = path.expanduser().resolve()
normalized_cache_dir = cache_dir.expanduser().resolve()
return normalized_path.is_relative_to(normalized_cache_dir)

Copilot uses AI. Check for mistakes.
Comment on lines +108 to +109
not os.environ.get("SE_FORCE_BROWSER_DOWNLOAD"),
reason="Only runs when SE_FORCE_BROWSER_DOWNLOAD is set",
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

SE_FORCE_BROWSER_DOWNLOAD is a boolean Selenium Manager config env var (parsed as "true"/"false"). This skipif only checks for presence, so the test would still run with SE_FORCE_BROWSER_DOWNLOAD=false even though SM won’t force browser downloads, making the cache assertions unreliable. Update the condition to validate the value instead of just existence.

Suggested change
not os.environ.get("SE_FORCE_BROWSER_DOWNLOAD"),
reason="Only runs when SE_FORCE_BROWSER_DOWNLOAD is set",
os.environ.get("SE_FORCE_BROWSER_DOWNLOAD", "").lower() != "true",
reason="Only runs when SE_FORCE_BROWSER_DOWNLOAD is set to true",

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +104
def _is_within_cache(path: Path, cache_dir: Path) -> bool:
"""Check if a path is within a given cache directory."""
try:
path.relative_to(cache_dir)
return True
except ValueError:
return False
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

To make the cache containment assertion more robust, normalize paths first (e.g., expanduser()/resolve()), especially if SE_CACHE_PATH contains ~ or SM returns non-normalized paths. Since Python >=3.10 is required, Path.is_relative_to() can replace _is_within_cache and avoid the try/except.

Copilot uses AI. Check for mistakes.
Comment thread py/BUILD.bazel
tags = [
"manager",
"no-sandbox",
"requires-network",
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

These Selenium Manager integration tests rely on network access and on running with --pin_browsers=false, but the repo’s remote Bazel config forces --//common:pin_browsers and only filters out tests tagged skip-rbe. Without a skip-rbe tag here, running this suite under --config=rbe is likely to fail (and may attempt unwanted downloads). Add skip-rbe to the tags for these test-*-sm targets to prevent accidental RBE execution.

Suggested change
"requires-network",
"requires-network",
"skip-rbe",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations C-py Python Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants