This is an automated email from the ASF dual-hosted git repository.
justinpark pushed a commit to branch 6.2
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/6.2 by this push:
new a8a9ddf5d3f fix(webdriver): apply binary_location nested under options
(#44898)
a8a9ddf5d3f is described below
commit a8a9ddf5d3f8995e8382f01d6cf5c26b843ff241
Author: JUST.in DO IT <[email protected]>
AuthorDate: Fri Oct 2 09:42:04 2026 -0700
fix(webdriver): apply binary_location nested under options (#44898)
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
---
superset/utils/webdriver.py | 13 +++++-
tests/unit_tests/utils/webdriver_test.py | 70 ++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/superset/utils/webdriver.py b/superset/utils/webdriver.py
index f38c67fd64c..efb57fad9af 100644
--- a/superset/utils/webdriver.py
+++ b/superset/utils/webdriver.py
@@ -481,9 +481,18 @@ class WebDriverSelenium(WebDriverProxy):
webdriver_config = self._normalize_timeout_values(webdriver_config)
kwargs.update(webdriver_config)
- # Set the binary location if provided
+ # Set the binary location if provided, either at the top level or
nested
+ # under "options" (which is where the default config documents it).
# We need to pop it from the dict due to selenium_version < 4.10.0
- options.binary_location = webdriver_config.pop("binary_location", "")
+ nested_options = webdriver_config.get("options")
+ nested_binary_location = (
+ nested_options.get("binary_location")
+ if isinstance(nested_options, dict)
+ else None
+ )
+ options.binary_location = (
+ webdriver_config.pop("binary_location", "") or
nested_binary_location or ""
+ )
if version.parse(selenium_version) < version.parse("4.10.0"):
kwargs |= webdriver_config
diff --git a/tests/unit_tests/utils/webdriver_test.py
b/tests/unit_tests/utils/webdriver_test.py
index ad55f4b68e6..b0630031701 100644
--- a/tests/unit_tests/utils/webdriver_test.py
+++ b/tests/unit_tests/utils/webdriver_test.py
@@ -274,6 +274,76 @@ class TestWebDriverSelenium:
mock_driver_class.assert_called_once()
+class TestWebDriverSeleniumBinaryLocation:
+ """Test that WebDriverSelenium.create() applies the configured
binary_location."""
+
+ @staticmethod
+ def _create(mock_app_patch, mock_chrome, webdriver_configuration):
+ mock_app_patch.config = {
+ "WEBDRIVER_TYPE": "chrome",
+ "WEBDRIVER_OPTION_ARGS": [],
+ "SCREENSHOT_LOCATE_WAIT": 10,
+ "SCREENSHOT_LOAD_WAIT": 10,
+ "WEBDRIVER_WINDOW": {},
+ "WEBDRIVER_CONFIGURATION": webdriver_configuration,
+ }
+ mock_chrome.webdriver.WebDriver = MagicMock()
+ mock_chrome.service.Service = MagicMock()
+ mock_options = MagicMock()
+ mock_chrome.options.Options = MagicMock(return_value=mock_options)
+
+ WebDriverSelenium(driver_type="chrome").create()
+ return mock_options
+
+ @patch("superset.utils.webdriver.app")
+ @patch("superset.utils.webdriver.chrome")
+ def test_binary_location_nested_under_options(self, mock_chrome,
mock_app_patch):
+ """The value nested under "options", as in the default config, is
applied."""
+ options = self._create(
+ mock_app_patch,
+ mock_chrome,
+ {
+ "options": {
+ "capabilities": {},
+ "preferences": {},
+ "binary_location": "/usr/bin/firefox-esr",
+ },
+ "service": {"log_output": "/dev/null"},
+ },
+ )
+
+ assert options.binary_location == "/usr/bin/firefox-esr"
+
+ @patch("superset.utils.webdriver.app")
+ @patch("superset.utils.webdriver.chrome")
+ def test_binary_location_top_level_takes_precedence(
+ self, mock_chrome, mock_app_patch
+ ):
+ """A top-level value keeps working and wins over the nested one."""
+ options = self._create(
+ mock_app_patch,
+ mock_chrome,
+ {
+ "binary_location": "/opt/browser/top-level",
+ "options": {"binary_location": "/opt/browser/nested"},
+ },
+ )
+
+ assert options.binary_location == "/opt/browser/top-level"
+
+ @patch("superset.utils.webdriver.app")
+ @patch("superset.utils.webdriver.chrome")
+ def test_binary_location_defaults_to_empty(self, mock_chrome,
mock_app_patch):
+ """An empty or missing value leaves the browser to be auto-detected."""
+ for config in (
+ {},
+ {"options": {"binary_location": ""}},
+ {"options": {"capabilities": {}}},
+ ):
+ options = self._create(mock_app_patch, mock_chrome, config)
+ assert options.binary_location == ""
+
+
class TestPlaywrightAvailabilityCheck:
"""Test comprehensive Playwright availability checking."""