Skip to content

Commit 47f4ef3

Browse files
authored
chore: Remove Selenium 3 deprecations (#303)
1 parent 47fa838 commit 47f4ef3

File tree

9 files changed

+40
-119
lines changed

9 files changed

+40
-119
lines changed

Diff for: src/pytest_selenium/drivers/chrome.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
from packaging.version import Version
5-
64
import pytest
7-
from selenium import __version__ as SELENIUM_VERSION
85
from selenium.webdriver.chrome.options import Options
96

107

118
def driver_kwargs(
129
capabilities, driver_args, driver_log, driver_path, chrome_options, **kwargs
1310
):
14-
kwargs = {"desired_capabilities": capabilities, "service_log_path": driver_log}
15-
16-
# Selenium 3.8.0 deprecated chrome_options in favour of options
17-
if Version(SELENIUM_VERSION) < Version("3.8.0"):
18-
kwargs["chrome_options"] = chrome_options
19-
else:
20-
kwargs["options"] = chrome_options
11+
kwargs = {
12+
"desired_capabilities": capabilities,
13+
"service_log_path": driver_log,
14+
"options": chrome_options,
15+
}
2116

2217
if driver_args is not None:
2318
kwargs["service_args"] = driver_args

Diff for: src/pytest_selenium/drivers/edge.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
from packaging.version import Version
5-
64
import pytest
7-
from selenium import __version__ as SELENIUM_VERSION
85
from selenium.webdriver.edge.options import Options
96

107

118
def driver_kwargs(capabilities, driver_log, driver_path, edge_options, **kwargs):
129

13-
# Selenium 3.14.0 deprecated log_path in favour of service_log_path
14-
if Version(SELENIUM_VERSION) < Version("3.14.0"):
15-
kwargs = {"log_path": driver_log}
16-
else:
17-
kwargs = {"service_log_path": driver_log}
18-
19-
if Version(SELENIUM_VERSION) >= Version("4.0.0"):
20-
kwargs["options"] = edge_options
10+
kwargs = {
11+
"service_log_path": driver_log,
12+
"options": edge_options,
13+
}
2114

2215
if capabilities:
2316
kwargs["capabilities"] = capabilities

Diff for: src/pytest_selenium/drivers/internet_explorer.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4-
from packaging.version import Version
5-
from selenium import __version__ as SELENIUM_VERSION
64

75

86
def driver_kwargs(capabilities, driver_log, driver_path, **kwargs):
97

10-
# Selenium 3.14.0 deprecated log_file in favour of service_log_path
11-
if Version(SELENIUM_VERSION) < Version("3.14.0"):
12-
kwargs = {"log_file": driver_log}
13-
else:
14-
kwargs = {"service_log_path": driver_log}
8+
kwargs = {"service_log_path": driver_log}
159

1610
if capabilities:
1711
kwargs["capabilities"] = capabilities

Diff for: src/pytest_selenium/pytest_selenium.py

-32
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from .utils import CaseInsensitiveDict
1919
from . import drivers
2020

21-
import warnings
2221

2322
LOGGER = logging.getLogger(__name__)
2423

@@ -228,22 +227,6 @@ def selenium(driver):
228227

229228
@pytest.hookimpl(trylast=True)
230229
def pytest_configure(config):
231-
if config.getoption("host"):
232-
warnings.warn(
233-
"--host has been deprecated and will be removed in a "
234-
"future release. Please use --selenium-host instead.",
235-
DeprecationWarning,
236-
)
237-
config.option.selenium_host = config.getoption("host")
238-
239-
if config.getoption("port"):
240-
warnings.warn(
241-
"--port has been deprecated and will be removed in a "
242-
"future release. Please use --selenium-port instead.",
243-
DeprecationWarning,
244-
)
245-
config.option.selenium_port = config.getoption("port")
246-
247230
capabilities = config._variables.get("capabilities", {})
248231
capabilities.update({k: v for k, v in config.getoption("capabilities")})
249232
config.addinivalue_line(
@@ -479,21 +462,6 @@ def pytest_addoption(parser):
479462
help="selenium eventlistener class, e.g. "
480463
"package.module.EventListenerClassName.",
481464
)
482-
group._addoption(
483-
"--host",
484-
metavar="str",
485-
help="DEPRECATED host that the selenium server is listening on, "
486-
"which will default to the cloud provider default "
487-
"or localhost.",
488-
)
489-
group._addoption(
490-
"--port",
491-
type=int,
492-
metavar="num",
493-
help="DEPRECATED port that the selenium server is listening on, "
494-
"which will default to the cloud provider default "
495-
"or localhost.",
496-
)
497465
group._addoption(
498466
"--selenium-host",
499467
metavar="str",

Diff for: testing/test_driver.py

+12-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
from contextlib import ExitStack as does_not_raise
65
from functools import partial
76

87
import pytest_selenium
@@ -138,14 +137,7 @@ def test_pass(driver_kwargs):
138137
)
139138

140139

141-
@pytest.mark.parametrize(
142-
("host_arg_name", "port_arg_name", "context"),
143-
[
144-
("--selenium-host", "--selenium-port", does_not_raise()),
145-
("--host", "--port", pytest.warns(DeprecationWarning)),
146-
],
147-
)
148-
def test_arguments_order(testdir, host_arg_name, port_arg_name, context):
140+
def test_arguments_order(testdir):
149141
host = "notlocalhost"
150142
port = "4441"
151143
file_test = testdir.makepyfile(
@@ -158,17 +150,17 @@ def test_pass(driver_kwargs):
158150
host, port
159151
)
160152
)
161-
with context:
162-
testdir.quick_qa(
163-
"--driver",
164-
"Remote",
165-
host_arg_name,
166-
host,
167-
port_arg_name,
168-
port,
169-
file_test,
170-
passed=1,
171-
)
153+
154+
testdir.quick_qa(
155+
"--driver",
156+
"Remote",
157+
"--selenium-host",
158+
host,
159+
"--selenium-port",
160+
port,
161+
file_test,
162+
passed=1,
163+
)
172164

173165

174166
def test_arguments_order_random(testdir):

Diff for: testing/test_edge.py

-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import pytest
66
import sys
7-
from packaging.version import Version
8-
from selenium import __version__ as SELENIUM_VERSION
97

108

119
pytestmark = pytest.mark.nondestructive
@@ -27,10 +25,6 @@ def test_pass(webtext):
2725

2826

2927
@pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
30-
@pytest.mark.skipif(
31-
Version(SELENIUM_VERSION) < Version("4.0.0"),
32-
reason="Edge chromium only supported for selenium >= 4.0.0",
33-
)
3428
@pytest.mark.edge
3529
@pytest.mark.parametrize("use_chromium", [True, False], ids=["chromium", "legacy"])
3630
def test_launch(use_chromium, testdir, httpserver):

Diff for: testing/test_metadata.py

+12-21
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
from contextlib import ExitStack as does_not_raise
6-
75
import pytest
86

97
pytestmark = pytest.mark.nondestructive
@@ -25,14 +23,7 @@ def test_pass(metadata):
2523
testdir.quick_qa("--driver", "Remote", file_test, passed=1)
2624

2725

28-
@pytest.mark.parametrize(
29-
("host_arg_name", "port_arg_name", "context"),
30-
[
31-
("--selenium-host", "--selenium-port", does_not_raise()),
32-
("--host", "--port", pytest.warns(DeprecationWarning)),
33-
],
34-
)
35-
def test_metadata_host_port(testdir, host_arg_name, port_arg_name, context):
26+
def test_metadata_host_port(testdir):
3627
host = "notlocalhost"
3728
port = "4441"
3829
file_test = testdir.makepyfile(
@@ -45,14 +36,14 @@ def test_pass(metadata):
4536
host, port
4637
)
4738
)
48-
with context:
49-
testdir.quick_qa(
50-
"--driver",
51-
"Remote",
52-
host_arg_name,
53-
host,
54-
port_arg_name,
55-
port,
56-
file_test,
57-
passed=1,
58-
)
39+
40+
testdir.quick_qa(
41+
"--driver",
42+
"Remote",
43+
"--selenium-host",
44+
host,
45+
"--selenium-port",
46+
port,
47+
file_test,
48+
passed=1,
49+
)

Diff for: testing/test_report.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,17 @@
55
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
66

77
import re
8-
from packaging.version import Version
98

109
import pytest
11-
from pytest_html import __version__ as PYTEST_HTML_VERSION
10+
1211

1312
pytestmark = pytest.mark.nondestructive
1413

1514
URL_LINK = '<a class="url" href="{0}/" target="_blank">URL</a>'
1615

17-
if Version(PYTEST_HTML_VERSION) < Version("2.0.0"):
18-
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank">Screenshot</a>'
19-
SCREENSHOT_REGEX = '<div class="image"><a href=".*"><img src=".*"/></a></div>'
20-
else:
21-
SCREENSHOT_LINK_REGEX = (
22-
'<a class="image" href=".*" target="_blank"><img src=".*"/></a>'
23-
)
24-
SCREENSHOT_REGEX = '<div class="image"><a class="image" href=".*" target="_blank">'
25-
'<img src=".*"/></a></div>'
16+
SCREENSHOT_LINK_REGEX = '<a class="image" href=".*" target="_blank"><img src=".*"/></a>'
17+
SCREENSHOT_REGEX = '<div class="image"><a class="image" href=".*" target="_blank">'
18+
'<img src=".*"/></a></div>'
2619

2720
LOGS_REGEX = '<a class="text" href=".*" target="_blank">.* Log</a>'
2821
HTML_REGEX = '<a class="text" href=".*" target="_blank">HTML</a>'

Diff for: tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ deps =
1616
pytest-localserver
1717
pytest-xdist
1818
pytest-mock
19-
commands = pytest -n auto -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs}
19+
commands = pytest -n auto -v -r a --color=yes --strict-config --strict-markers --html={envlogdir}/report.html --self-contained-html {posargs}
2020

2121
[testenv:docs]
2222
basepython = python3
@@ -39,6 +39,7 @@ exclude = .eggs,.tox,docs
3939
testpaths = testing
4040
# Register markers used by tests
4141
markers =
42+
firefox
4243
edge
4344
safari
4445
chrome

0 commit comments

Comments
 (0)