Skip to content

Commit b8eeda7

Browse files
committed
[py] Deprecate CDP methods on Firefox
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent b1828bf commit b8eeda7

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

py/selenium/webdriver/remote/webdriver.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,11 @@ def _get_cdp_details(self):
11271127
if _firefox:
11281128
# Mozilla Automation Team asked to only support 85
11291129
# until WebDriver Bidi is available.
1130+
warnings.warn(
1131+
"CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.",
1132+
DeprecationWarning,
1133+
stacklevel=2,
1134+
)
11301135
version = 85
11311136
else:
11321137
version = re.search(r".*/(\d+)\.", browser_version).group(1)

py/test/selenium/webdriver/common/devtools_tests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@
2121

2222
@pytest.mark.xfail_safari
2323
def test_check_console_messages(driver, pages):
24-
devtools, connection = driver.start_devtools()
24+
with pytest.warns(None) as record:
25+
devtools, connection = driver.start_devtools()
2526
console_api_calls = []
2627

28+
if driver.capabilities["browserName"] == "firefox":
29+
assert (
30+
record[0].message.args[0]
31+
== "CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi."
32+
)
33+
else:
34+
assert len(record) == 0
35+
2736
connection.execute(devtools.runtime.enable())
2837
connection.on(devtools.runtime.ConsoleAPICalled, console_api_calls.append)
2938
driver.execute_script("console.log('I love cheese')")

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def test_log_output_as_filename() -> None:
2727
log_file = "geckodriver.log"
2828
service = Service(log_output=log_file)
2929
try:
30-
driver = Firefox(service=service)
30+
with pytest.warns(None) as record:
31+
driver = Firefox(service=service)
32+
assert len(record) == 0
3133
with open(log_file) as fp:
3234
assert "geckodriver\tINFO\tListening" in fp.readline()
3335
finally:

py/test/selenium/webdriver/remote/remote_firefox_profile_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
@pytest.fixture
2424
def driver(options):
25-
driver = webdriver.Remote(options=options)
25+
with pytest.warns(None) as record:
26+
driver = webdriver.Remote(options=options)
27+
assert len(record) == 0
2628
yield driver
2729
driver.quit()
2830

0 commit comments

Comments
 (0)