What happened?
I am developing a Django application, and I want to test how it behaves in Safari. I treat all deprecation warnings as errors during development so I am alerted when something becomes deprecated and can update my code accordingly.
When I try to create a Safari WebDriver instance, the Safari WebDriver.__init__ passes desired_capabilities=DEFAULT_SAFARI_CAPS to its superclass's __init__, which will then raise a DeprecationWarning stating that desired_capabilities shouldn't be used. If I try to set desired_capabilities to None, the Safari __init__ raises a DeprecationWarning stating that I should use the options argument instead of changing the desired_capabilities value.
Below is the output I got when trying to start a Safari instance using selenium:
(venv) /tmp % python -Werror
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium.webdriver import Safari
>>> driver = Safari()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/private/tmp/venv/lib/python3.9/site-packages/selenium/webdriver/safari/webdriver.py", line 110, in __init__
super().__init__(command_executor=executor, options=options, desired_capabilities=desired_capabilities)
File "/private/tmp/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 231, in __init__
warnings.warn(
DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
>>> from selenium.webdriver.safari.options import Options
>>> options = Options()
>>> driver = Safari(options=options)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/private/tmp/venv/lib/python3.9/site-packages/selenium/webdriver/safari/webdriver.py", line 110, in __init__
super().__init__(command_executor=executor, options=options, desired_capabilities=desired_capabilities)
File "/private/tmp/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 231, in __init__
warnings.warn(
DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
>>> driver = Safari(options=options, desired_capabilities=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/private/tmp/venv/lib/python3.9/site-packages/selenium/webdriver/safari/webdriver.py", line 80, in __init__
warnings.warn(
DeprecationWarning: desired_capabilities has been deprecated, please use the Options class to set it
How can we reproduce the issue?
python3.9 -m venv venv
. venv/bin/activate
pip install -U pip setuptools wheel
pip install selenium
python -Werror -c '
from selenium.webdriver import Safari
try:
driver = Safari() # This will cause an error
except BaseException as e:
print("Bare init:", e)
from selenium.webdriver.safari.options import Options
options = Options()
try:
driver = Safari(options=options) # This will cause an error
except BaseException as e:
print("Init with options:", e)
try:
driver = Safari(options=options, desired_capabilities=None) # This will cause an error
except BaseException as e:
print("Init with options and no desired_capabilities:", e)'
Relevant log output
Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (22.0.4)
Collecting pip
Using cached pip-23.0.1-py3-none-any.whl (2.1 MB)
Requirement already satisfied: setuptools in ./venv/lib/python3.9/site-packages (58.1.0)
Collecting setuptools
Using cached setuptools-67.6.1-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached wheel-0.40.0-py3-none-any.whl (64 kB)
Installing collected packages: wheel, setuptools, pip
Attempting uninstall: setuptools
Found existing installation: setuptools 58.1.0
Uninstalling setuptools-58.1.0:
Successfully uninstalled setuptools-58.1.0
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-23.0.1 setuptools-67.6.1 wheel-0.40.0
Collecting selenium
Using cached selenium-4.8.3-py3-none-any.whl (6.5 MB)
Collecting trio-websocket~=0.9
Using cached trio_websocket-0.10.2-py3-none-any.whl (17 kB)
Collecting certifi>=2021.10.8
Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Collecting urllib3[socks]~=1.26
Using cached urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
Collecting trio~=0.17
Using cached trio-0.22.0-py3-none-any.whl (384 kB)
Collecting sortedcontainers
Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Collecting attrs>=19.2.0
Using cached attrs-22.2.0-py3-none-any.whl (60 kB)
Collecting sniffio
Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting outcome
Using cached outcome-1.2.0-py2.py3-none-any.whl (9.7 kB)
Collecting idna
Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting async-generator>=1.9
Using cached async_generator-1.10-py3-none-any.whl (18 kB)
Collecting exceptiongroup>=1.0.0rc9
Using cached exceptiongroup-1.1.1-py3-none-any.whl (14 kB)
Collecting wsproto>=0.14
Using cached wsproto-1.2.0-py3-none-any.whl (24 kB)
Collecting PySocks!=1.5.7,<2.0,>=1.5.6
Using cached PySocks-1.7.1-py3-none-any.whl (16 kB)
Collecting h11<1,>=0.9.0
Using cached h11-0.14.0-py3-none-any.whl (58 kB)
Installing collected packages: sortedcontainers, urllib3, sniffio, PySocks, idna, h11, exceptiongroup, certifi, attrs, async-generator, wsproto, outcome, trio, trio-websocket, selenium
Successfully installed PySocks-1.7.1 async-generator-1.10 attrs-22.2.0 certifi-2022.12.7 exceptiongroup-1.1.1 h11-0.14.0 idna-3.4 outcome-1.2.0 selenium-4.8.3 sniffio-1.3.0 sortedcontainers-2.4.0 trio-0.22.0 trio-websocket-0.10.2 urllib3-1.26.15 wsproto-1.2.0
Bare init: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
Init with options: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
Init with options and no desired_capabilities: desired_capabilities has been deprecated, please use the Options class to set it
Operating System
macOS Ventura 13.3
Selenium version
Python 4.8.3
What are the browser(s) and version(s) where you see this issue?
N / A, issue is in selenium itself
What are the browser driver(s) and version(s) where you see this issue?
N / A, issue is in selenium itself
Are you using Selenium Grid?
No response
What happened?
I am developing a Django application, and I want to test how it behaves in Safari. I treat all deprecation warnings as errors during development so I am alerted when something becomes deprecated and can update my code accordingly.
When I try to create a Safari WebDriver instance, the Safari
WebDriver.__init__passesdesired_capabilities=DEFAULT_SAFARI_CAPSto its superclass's__init__, which will then raise aDeprecationWarningstating thatdesired_capabilitiesshouldn't be used. If I try to setdesired_capabilitiestoNone, the Safari__init__raises aDeprecationWarningstating that I should use theoptionsargument instead of changing thedesired_capabilitiesvalue.Below is the output I got when trying to start a Safari instance using selenium:
How can we reproduce the issue?
Relevant log output
Operating System
macOS Ventura 13.3
Selenium version
Python 4.8.3
What are the browser(s) and version(s) where you see this issue?
N / A, issue is in selenium itself
What are the browser driver(s) and version(s) where you see this issue?
N / A, issue is in selenium itself
Are you using Selenium Grid?
No response