Skip to content

Commit e2e9ac5

Browse files
authoredNov 22, 2024··
[py] Deprecate CDP methods on Firefox (#14787)
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 99ee404 commit e2e9ac5

File tree

7 files changed

+50
-5
lines changed

7 files changed

+50
-5
lines changed
 

‎.github/workflows/ci-python.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ jobs:
100100
fail-fast: false
101101
matrix:
102102
include:
103-
- browser: safari
104-
os: macos
105103
- browser: chrome
106104
os: ubuntu
107105
- browser: edge
@@ -116,3 +114,21 @@ jobs:
116114
run: |
117115
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:common-${{ matrix.browser }}-bidi
118116
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
117+
118+
safari-tests:
119+
name: Browser Tests
120+
needs: build
121+
uses: ./.github/workflows/bazel.yml
122+
strategy:
123+
fail-fast: false
124+
matrix:
125+
include:
126+
- browser: safari
127+
os: macos
128+
with:
129+
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
130+
browser: ${{ matrix.browser }}
131+
os: ${{ matrix.os }}
132+
cache-key: py-browser-${{ matrix.browser }}
133+
run: |
134+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}

‎py/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ attrs==23.2.0
33
certifi==2023.11.17
44
cffi==1.16.0
55
cryptography==42.0.8
6+
secretstorage==3.3.3
67
debugpy==1.8.7
78
filetype==1.2.0
89
h11==0.14.0

‎py/requirements_lock.txt

+9
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ cryptography==42.0.8 \
208208
# via
209209
# -r py/requirements.txt
210210
# pyopenssl
211+
# secretstorage
211212
debugpy==1.8.7 \
212213
--hash=sha256:11ad72eb9ddb436afb8337891a986302e14944f0f755fd94e90d0d71e9100bba \
213214
--hash=sha256:171899588bcd412151e593bd40d9907133a7622cd6ecdbdb75f89d1551df13c2 \
@@ -288,6 +289,10 @@ jaraco-classes==3.3.0 \
288289
--hash=sha256:10afa92b6743f25c0cf5f37c6bb6e18e2c5bb84a16527ccfc0040ea377e7aaeb \
289290
--hash=sha256:c063dd08e89217cee02c8d5e5ec560f2c8ce6cdc2fcdc2e68f7b2e5547ed3621
290291
# via keyring
292+
jeepney==0.8.0 \
293+
--hash=sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806 \
294+
--hash=sha256:c0a454ad016ca575060802ee4d590dd912e35c122fa04e70306de3d076cce755
295+
# via secretstorage
291296
keyring==24.3.0 \
292297
--hash=sha256:4446d35d636e6a10b8bce7caa66913dd9eca5fd222ca03a3d42c38608ac30836 \
293298
--hash=sha256:e730ecffd309658a08ee82535a3b5ec4b4c8669a9be11efb66249d8e0aeb9a25
@@ -512,6 +517,10 @@ rich==13.7.0 \
512517
--hash=sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa \
513518
--hash=sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235
514519
# via twine
520+
secretstorage==3.3.3 \
521+
--hash=sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77 \
522+
--hash=sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99
523+
# via -r py/requirements.txt
515524
sniffio==1.3.1 \
516525
--hash=sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2 \
517526
--hash=sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc

‎py/selenium/webdriver/remote/webdriver.py

+6
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,12 @@ def start_devtools(self):
10571057
raise WebDriverException("Unable to find url to connect to from capabilities")
10581058

10591059
devtools = cdp.import_devtools(version)
1060+
if self.caps["browserName"].lower() == "firefox":
1061+
warnings.warn(
1062+
"CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.",
1063+
DeprecationWarning,
1064+
stacklevel=2,
1065+
)
10601066
self._websocket_connection = WebSocketConnection(ws_url)
10611067
targets = self._websocket_connection.execute(devtools.target.get_targets())
10621068
target_id = targets[0].target_id

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

+10-1
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.caps["browserName"].lower() == "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

+3-1
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

+3-1
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)
Please sign in to comment.