Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] Deprecate CDP methods on Firefox #14787

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ jobs:
fail-fast: false
matrix:
include:
- browser: safari
os: macos
- browser: chrome
os: ubuntu
- browser: edge
Expand All @@ -116,3 +114,21 @@ jobs:
run: |
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:common-${{ matrix.browser }}-bidi
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}

safari-tests:
name: Browser Tests
needs: build
uses: ./.github/workflows/bazel.yml
strategy:
fail-fast: false
matrix:
include:
- browser: safari
os: macos
with:
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
browser: ${{ matrix.browser }}
os: ${{ matrix.os }}
cache-key: py-browser-${{ matrix.browser }}
run: |
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
1 change: 1 addition & 0 deletions py/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ attrs==23.2.0
certifi==2023.11.17
cffi==1.16.0
cryptography==42.0.8
secretstorage==3.3.3
debugpy==1.8.7
filetype==1.2.0
h11==0.14.0
Expand Down
9 changes: 9 additions & 0 deletions py/requirements_lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ cryptography==42.0.8 \
# via
# -r py/requirements.txt
# pyopenssl
# secretstorage
debugpy==1.8.7 \
--hash=sha256:11ad72eb9ddb436afb8337891a986302e14944f0f755fd94e90d0d71e9100bba \
--hash=sha256:171899588bcd412151e593bd40d9907133a7622cd6ecdbdb75f89d1551df13c2 \
Expand Down Expand Up @@ -288,6 +289,10 @@ jaraco-classes==3.3.0 \
--hash=sha256:10afa92b6743f25c0cf5f37c6bb6e18e2c5bb84a16527ccfc0040ea377e7aaeb \
--hash=sha256:c063dd08e89217cee02c8d5e5ec560f2c8ce6cdc2fcdc2e68f7b2e5547ed3621
# via keyring
jeepney==0.8.0 \
--hash=sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806 \
--hash=sha256:c0a454ad016ca575060802ee4d590dd912e35c122fa04e70306de3d076cce755
# via secretstorage
keyring==24.3.0 \
--hash=sha256:4446d35d636e6a10b8bce7caa66913dd9eca5fd222ca03a3d42c38608ac30836 \
--hash=sha256:e730ecffd309658a08ee82535a3b5ec4b4c8669a9be11efb66249d8e0aeb9a25
Expand Down Expand Up @@ -512,6 +517,10 @@ rich==13.7.0 \
--hash=sha256:5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa \
--hash=sha256:6da14c108c4866ee9520bbffa71f6fe3962e193b7da68720583850cd4548e235
# via twine
secretstorage==3.3.3 \
--hash=sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77 \
--hash=sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99
# via -r py/requirements.txt
sniffio==1.3.1 \
--hash=sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2 \
--hash=sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc
Expand Down
6 changes: 6 additions & 0 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,12 @@
raise WebDriverException("Unable to find url to connect to from capabilities")

devtools = cdp.import_devtools(version)
if self.caps["browserName"].lower() == "firefox":
warnings.warn(
"CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi.",

Check warning on line 1062 in py/selenium/webdriver/remote/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/remote/webdriver.py#L1060-L1062

Added lines #L1060 - L1062 were not covered by tests
DeprecationWarning,
stacklevel=2,

Check warning on line 1064 in py/selenium/webdriver/remote/webdriver.py

View check run for this annotation

Codecov / codecov/patch

py/selenium/webdriver/remote/webdriver.py#L1064

Added line #L1064 was not covered by tests
)
self._websocket_connection = WebSocketConnection(ws_url)
targets = self._websocket_connection.execute(devtools.target.get_targets())
target_id = targets[0].target_id
Expand Down
11 changes: 10 additions & 1 deletion py/test/selenium/webdriver/common/devtools_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@

@pytest.mark.xfail_safari
def test_check_console_messages(driver, pages):
devtools, connection = driver.start_devtools()
with pytest.warns(None) as record:
devtools, connection = driver.start_devtools()
console_api_calls = []

if driver.caps["browserName"].lower() == "firefox":
assert (
record[0].message.args[0]
== "CDP support for Firefox is deprecated and will be removed in future versions. Please switch to WebDriver BiDi."
)
else:
assert len(record) == 0

connection.execute(devtools.runtime.enable())
connection.on(devtools.runtime.ConsoleAPICalled, console_api_calls.append)
driver.execute_script("console.log('I love cheese')")
Expand Down
4 changes: 3 additions & 1 deletion py/test/selenium/webdriver/firefox/firefox_service_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def test_log_output_as_filename() -> None:
log_file = "geckodriver.log"
service = Service(log_output=log_file)
try:
driver = Firefox(service=service)
with pytest.warns(None) as record:
driver = Firefox(service=service)
assert len(record) == 0
with open(log_file) as fp:
assert "geckodriver\tINFO\tListening" in fp.readline()
finally:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

@pytest.fixture
def driver(options):
driver = webdriver.Remote(options=options)
with pytest.warns(None) as record:
driver = webdriver.Remote(options=options)
assert len(record) == 0
yield driver
driver.quit()

Expand Down
Loading