diff --git a/py/BUILD.bazel b/py/BUILD.bazel index ea7b0dd374692..322ae35d51c70 100644 --- a/py/BUILD.bazel +++ b/py/BUILD.bazel @@ -363,7 +363,6 @@ py_library( "test/selenium/webdriver/common/network.py", "test/selenium/webdriver/common/webserver.py", "test/selenium/webdriver/firefox/__init__.py", - "test/selenium/webdriver/firefox/conftest.py", "test/selenium/webdriver/marionette/__init__.py", "test/selenium/webdriver/marionette/conftest.py", "test/selenium/webdriver/safari/conftest.py", diff --git a/py/conftest.py b/py/conftest.py index 555ec7b0f0505..5f21cac98e955 100644 --- a/py/conftest.py +++ b/py/conftest.py @@ -467,6 +467,7 @@ def clean_driver(request): pytest.xfail(**marker.kwargs) yield driver_reference + if request.node.get_closest_marker("no_driver_after_test"): driver_reference = None diff --git a/py/pyproject.toml b/py/pyproject.toml index 3b8bd059d6337..c2d5eeeed37a2 100644 --- a/py/pyproject.toml +++ b/py/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", - ] +] dependencies = [ "urllib3[socks]>=2.5.0,<3.0", "trio>=0.31.0,<1.0", @@ -32,7 +32,7 @@ dependencies = [ "certifi>=2025.10.5", "typing_extensions>=4.15.0,<5.0", "websocket-client>=1.8.0,<2.0", - ] +] [project.urls] homepage = "https://www.selenium.dev" diff --git a/py/test/selenium/webdriver/firefox/conftest.py b/py/test/selenium/webdriver/firefox/conftest.py deleted file mode 100644 index 8590135a0bc62..0000000000000 --- a/py/test/selenium/webdriver/firefox/conftest.py +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import pytest - -from selenium.webdriver import Firefox - - -@pytest.fixture -def driver(): - driver = Firefox() - yield driver - driver.quit() diff --git a/py/test/selenium/webdriver/firefox/ff_installs_addons_tests.py b/py/test/selenium/webdriver/firefox/ff_installs_addons_tests.py index c7cb6797cd066..42cafa858cf6e 100644 --- a/py/test/selenium/webdriver/firefox/ff_installs_addons_tests.py +++ b/py/test/selenium/webdriver/firefox/ff_installs_addons_tests.py @@ -18,12 +18,21 @@ import os import zipfile +import pytest + from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait -extensions = os.path.abspath("../../../../../../test/extensions/") +for extensions_dir in ( + os.path.abspath("../../../../../../test/extensions/"), + os.path.abspath("../common/extensions/"), +): + extensions = extensions_dir + if os.path.exists(extensions_dir): + break +@pytest.mark.no_driver_after_test def test_install_uninstall_signed_addon_xpi(driver, pages): extension = os.path.join(extensions, "webextensions-selenium-example.xpi") @@ -41,6 +50,7 @@ def test_install_uninstall_signed_addon_xpi(driver, pages): assert len(driver.find_elements(By.ID, "webextensions-selenium-example")) == 0 +@pytest.mark.no_driver_after_test def test_install_uninstall_signed_addon_zip(driver, pages): extension = os.path.join(extensions, "webextensions-selenium-example.zip") @@ -58,6 +68,7 @@ def test_install_uninstall_signed_addon_zip(driver, pages): assert len(driver.find_elements(By.ID, "webextensions-selenium-example")) == 0 +@pytest.mark.no_driver_after_test def test_install_uninstall_unsigned_addon_zip(driver, pages): extension = os.path.join(extensions, "webextensions-selenium-example-unsigned.zip") @@ -75,6 +86,7 @@ def test_install_uninstall_unsigned_addon_zip(driver, pages): assert len(driver.find_elements(By.ID, "webextensions-selenium-example")) == 0 +@pytest.mark.no_driver_after_test def test_install_uninstall_signed_addon_dir(driver, pages): zip = os.path.join(extensions, "webextensions-selenium-example.zip") @@ -96,6 +108,7 @@ def test_install_uninstall_signed_addon_dir(driver, pages): assert len(driver.find_elements(By.ID, "webextensions-selenium-example")) == 0 +@pytest.mark.no_driver_after_test def test_install_uninstall_unsigned_addon_dir(driver, pages): zip = os.path.join(extensions, "webextensions-selenium-example-unsigned.zip") target = os.path.join(extensions, "webextensions-selenium-example-unsigned-unzip")