diff --git a/src/pytest_selenium/drivers/chrome.py b/src/pytest_selenium/drivers/chrome.py index 26f057a..e198ab5 100644 --- a/src/pytest_selenium/drivers/chrome.py +++ b/src/pytest_selenium/drivers/chrome.py @@ -1,23 +1,18 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from packaging.version import Version - import pytest -from selenium import __version__ as SELENIUM_VERSION from selenium.webdriver.chrome.options import Options def driver_kwargs( capabilities, driver_args, driver_log, driver_path, chrome_options, **kwargs ): - kwargs = {"desired_capabilities": capabilities, "service_log_path": driver_log} - - # Selenium 3.8.0 deprecated chrome_options in favour of options - if Version(SELENIUM_VERSION) < Version("3.8.0"): - kwargs["chrome_options"] = chrome_options - else: - kwargs["options"] = chrome_options + kwargs = { + "desired_capabilities": capabilities, + "service_log_path": driver_log, + "options": chrome_options, + } if driver_args is not None: kwargs["service_args"] = driver_args diff --git a/src/pytest_selenium/drivers/edge.py b/src/pytest_selenium/drivers/edge.py index 1edaa9f..78a2b9f 100644 --- a/src/pytest_selenium/drivers/edge.py +++ b/src/pytest_selenium/drivers/edge.py @@ -1,23 +1,16 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from packaging.version import Version - import pytest -from selenium import __version__ as SELENIUM_VERSION from selenium.webdriver.edge.options import Options def driver_kwargs(capabilities, driver_log, driver_path, edge_options, **kwargs): - # Selenium 3.14.0 deprecated log_path in favour of service_log_path - if Version(SELENIUM_VERSION) < Version("3.14.0"): - kwargs = {"log_path": driver_log} - else: - kwargs = {"service_log_path": driver_log} - - if Version(SELENIUM_VERSION) >= Version("4.0.0"): - kwargs["options"] = edge_options + kwargs = { + "service_log_path": driver_log, + "options": edge_options, + } if capabilities: kwargs["capabilities"] = capabilities diff --git a/src/pytest_selenium/drivers/internet_explorer.py b/src/pytest_selenium/drivers/internet_explorer.py index 577f307..a3da787 100644 --- a/src/pytest_selenium/drivers/internet_explorer.py +++ b/src/pytest_selenium/drivers/internet_explorer.py @@ -1,17 +1,11 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from packaging.version import Version -from selenium import __version__ as SELENIUM_VERSION def driver_kwargs(capabilities, driver_log, driver_path, **kwargs): - # Selenium 3.14.0 deprecated log_file in favour of service_log_path - if Version(SELENIUM_VERSION) < Version("3.14.0"): - kwargs = {"log_file": driver_log} - else: - kwargs = {"service_log_path": driver_log} + kwargs = {"service_log_path": driver_log} if capabilities: kwargs["capabilities"] = capabilities diff --git a/src/pytest_selenium/pytest_selenium.py b/src/pytest_selenium/pytest_selenium.py index 19b37f4..d4568a4 100644 --- a/src/pytest_selenium/pytest_selenium.py +++ b/src/pytest_selenium/pytest_selenium.py @@ -18,7 +18,6 @@ from .utils import CaseInsensitiveDict from . import drivers -import warnings LOGGER = logging.getLogger(__name__) @@ -228,22 +227,6 @@ def selenium(driver): @pytest.hookimpl(trylast=True) def pytest_configure(config): - if config.getoption("host"): - warnings.warn( - "--host has been deprecated and will be removed in a " - "future release. Please use --selenium-host instead.", - DeprecationWarning, - ) - config.option.selenium_host = config.getoption("host") - - if config.getoption("port"): - warnings.warn( - "--port has been deprecated and will be removed in a " - "future release. Please use --selenium-port instead.", - DeprecationWarning, - ) - config.option.selenium_port = config.getoption("port") - capabilities = config._variables.get("capabilities", {}) capabilities.update({k: v for k, v in config.getoption("capabilities")}) config.addinivalue_line( @@ -479,21 +462,6 @@ def pytest_addoption(parser): help="selenium eventlistener class, e.g. " "package.module.EventListenerClassName.", ) - group._addoption( - "--host", - metavar="str", - help="DEPRECATED host that the selenium server is listening on, " - "which will default to the cloud provider default " - "or localhost.", - ) - group._addoption( - "--port", - type=int, - metavar="num", - help="DEPRECATED port that the selenium server is listening on, " - "which will default to the cloud provider default " - "or localhost.", - ) group._addoption( "--selenium-host", metavar="str", diff --git a/testing/test_driver.py b/testing/test_driver.py index c4a570b..07e0146 100644 --- a/testing/test_driver.py +++ b/testing/test_driver.py @@ -2,7 +2,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from contextlib import ExitStack as does_not_raise from functools import partial import pytest_selenium @@ -138,14 +137,7 @@ def test_pass(driver_kwargs): ) -@pytest.mark.parametrize( - ("host_arg_name", "port_arg_name", "context"), - [ - ("--selenium-host", "--selenium-port", does_not_raise()), - ("--host", "--port", pytest.warns(DeprecationWarning)), - ], -) -def test_arguments_order(testdir, host_arg_name, port_arg_name, context): +def test_arguments_order(testdir): host = "notlocalhost" port = "4441" file_test = testdir.makepyfile( @@ -158,17 +150,17 @@ def test_pass(driver_kwargs): host, port ) ) - with context: - testdir.quick_qa( - "--driver", - "Remote", - host_arg_name, - host, - port_arg_name, - port, - file_test, - passed=1, - ) + + testdir.quick_qa( + "--driver", + "Remote", + "--selenium-host", + host, + "--selenium-port", + port, + file_test, + passed=1, + ) def test_arguments_order_random(testdir): diff --git a/testing/test_edge.py b/testing/test_edge.py index da587aa..18a8fb2 100644 --- a/testing/test_edge.py +++ b/testing/test_edge.py @@ -4,8 +4,6 @@ import pytest import sys -from packaging.version import Version -from selenium import __version__ as SELENIUM_VERSION pytestmark = pytest.mark.nondestructive @@ -27,10 +25,6 @@ def test_pass(webtext): @pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows") -@pytest.mark.skipif( - Version(SELENIUM_VERSION) < Version("4.0.0"), - reason="Edge chromium only supported for selenium >= 4.0.0", -) @pytest.mark.edge @pytest.mark.parametrize("use_chromium", [True, False], ids=["chromium", "legacy"]) def test_launch(use_chromium, testdir, httpserver): diff --git a/testing/test_metadata.py b/testing/test_metadata.py index 9560b4a..460e1d1 100644 --- a/testing/test_metadata.py +++ b/testing/test_metadata.py @@ -2,8 +2,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from contextlib import ExitStack as does_not_raise - import pytest pytestmark = pytest.mark.nondestructive @@ -25,14 +23,7 @@ def test_pass(metadata): testdir.quick_qa("--driver", "Remote", file_test, passed=1) -@pytest.mark.parametrize( - ("host_arg_name", "port_arg_name", "context"), - [ - ("--selenium-host", "--selenium-port", does_not_raise()), - ("--host", "--port", pytest.warns(DeprecationWarning)), - ], -) -def test_metadata_host_port(testdir, host_arg_name, port_arg_name, context): +def test_metadata_host_port(testdir): host = "notlocalhost" port = "4441" file_test = testdir.makepyfile( @@ -45,14 +36,14 @@ def test_pass(metadata): host, port ) ) - with context: - testdir.quick_qa( - "--driver", - "Remote", - host_arg_name, - host, - port_arg_name, - port, - file_test, - passed=1, - ) + + testdir.quick_qa( + "--driver", + "Remote", + "--selenium-host", + host, + "--selenium-port", + port, + file_test, + passed=1, + ) diff --git a/testing/test_report.py b/testing/test_report.py index ce34f52..7630bd0 100644 --- a/testing/test_report.py +++ b/testing/test_report.py @@ -5,24 +5,17 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import re -from packaging.version import Version import pytest -from pytest_html import __version__ as PYTEST_HTML_VERSION + pytestmark = pytest.mark.nondestructive URL_LINK = 'URL' -if Version(PYTEST_HTML_VERSION) < Version("2.0.0"): - SCREENSHOT_LINK_REGEX = 'Screenshot' - SCREENSHOT_REGEX = '
' -else: - SCREENSHOT_LINK_REGEX = ( - '' - ) - SCREENSHOT_REGEX = '' +SCREENSHOT_LINK_REGEX = '' +SCREENSHOT_REGEX = '' LOGS_REGEX = '.* Log' HTML_REGEX = 'HTML' diff --git a/tox.ini b/tox.ini index 6ccc045..963138e 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,7 @@ deps = pytest-localserver pytest-xdist pytest-mock -commands = pytest -n auto -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs} +commands = pytest -n auto -v -r a --color=yes --strict-config --strict-markers --html={envlogdir}/report.html --self-contained-html {posargs} [testenv:docs] basepython = python3 @@ -39,6 +39,7 @@ exclude = .eggs,.tox,docs testpaths = testing # Register markers used by tests markers = + firefox edge safari chrome