From 6619056bfd8e7f92779698b5feb0851eda0a4036 Mon Sep 17 00:00:00 2001 From: sandeepsuryaprasad Date: Fri, 28 Jul 2023 00:17:02 +0530 Subject: [PATCH 1/4] [py] added decorators for handling deprecations --- py/selenium/deprecated.py | 31 +++++++++++++++++++ py/selenium/webdriver/chromium/options.py | 16 +++------- py/selenium/webdriver/chromium/service.py | 7 ++--- py/selenium/webdriver/edge/service.py | 11 +++---- .../webdriver/firefox/firefox_profile.py | 5 ++- py/selenium/webdriver/firefox/options.py | 23 +++++--------- py/selenium/webdriver/firefox/service.py | 5 +-- py/selenium/webdriver/ie/service.py | 4 +-- py/selenium/webdriver/remote/webdriver.py | 3 +- py/selenium/webdriver/safari/service.py | 6 ++-- py/selenium/webdriver/safari/webdriver.py | 12 +++---- 11 files changed, 65 insertions(+), 58 deletions(-) create mode 100644 py/selenium/deprecated.py diff --git a/py/selenium/deprecated.py b/py/selenium/deprecated.py new file mode 100644 index 0000000000000..4fac4b8ee9c28 --- /dev/null +++ b/py/selenium/deprecated.py @@ -0,0 +1,31 @@ +from warnings import warn + +removed_from_version = "4.12" + + +def deprecated_function(message): + """decorator to log deprecation warning messgaes for deprecated methods.""" + + def _deprecated_function(func): + def wrapper(*args, **kwargs): + warn(f"{message}: will be removed from {removed_from_version}", DeprecationWarning, stacklevel=2) + return func(*args, **kwargs) + + return wrapper + + return _deprecated_function + + +def deprecated_attributes(*attrs, message): + def _deprecated_attributes(func): + def wrapper(*args, **kwargs): + result = func(*args, **kwargs) + for attr in attrs: + _attr = getattr(args[0], attr, None) + if _attr: + warn(f"'{message}': will be removed from {removed_from_version}", DeprecationWarning, stacklevel=2) + return result + + return wrapper + + return _deprecated_attributes diff --git a/py/selenium/webdriver/chromium/options.py b/py/selenium/webdriver/chromium/options.py index 06c936a6eeec5..7988dd7b38fc5 100644 --- a/py/selenium/webdriver/chromium/options.py +++ b/py/selenium/webdriver/chromium/options.py @@ -17,11 +17,11 @@ import base64 import os -import warnings from typing import BinaryIO from typing import List from typing import Union +from selenium.deprecated import deprecated_function from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.options import ArgOptions @@ -139,18 +139,17 @@ def add_experimental_option(self, name: str, value: Union[str, int, dict, List[s self._experimental_options[name] = value @property + @deprecated_function("headless property is deprecated, instead check for '--headless' in arguments") def headless(self) -> bool: """ :Returns: True if the headless argument is set, else False """ - warnings.warn( - "headless property is deprecated, instead check for '--headless' in arguments", - DeprecationWarning, - stacklevel=2, - ) return "--headless" in self._arguments @headless.setter + @deprecated_function( + "headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new')" + ) def headless(self, value: bool) -> None: """Sets the headless argument Old headless uses a non-production browser and is set with `--headless` @@ -160,11 +159,6 @@ def headless(self, value: bool) -> None: :Args: value: boolean value indicating to set the headless option """ - warnings.warn( - "headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new')", - DeprecationWarning, - stacklevel=2, - ) args = {"--headless"} if not isinstance(value, bool): diff --git a/py/selenium/webdriver/chromium/service.py b/py/selenium/webdriver/chromium/service.py index 3e8d43c9ecd20..d61dd5d729616 100644 --- a/py/selenium/webdriver/chromium/service.py +++ b/py/selenium/webdriver/chromium/service.py @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. import typing -import warnings from selenium.common import InvalidArgumentException +from selenium.deprecated import deprecated_attributes from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service @@ -33,6 +33,7 @@ class ChromiumService(service.Service): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ + @deprecated_attributes("log_path", message="log_path has been deprecated, please use log_output") def __init__( self, executable_path: str = None, @@ -45,9 +46,7 @@ def __init__( ) -> None: self.service_args = service_args or [] self.log_output = log_output - if log_path is not None: - warnings.warn("log_path has been deprecated, please use log_output", DeprecationWarning, stacklevel=2) - self.log_output = log_path + self.log_output = log_path if "--append-log" in self.service_args or "--readable-timestamp" in self.service_args: if isinstance(self.log_output, str): diff --git a/py/selenium/webdriver/edge/service.py b/py/selenium/webdriver/edge/service.py index 1d07fad8caf32..f7491a2a54377 100644 --- a/py/selenium/webdriver/edge/service.py +++ b/py/selenium/webdriver/edge/service.py @@ -15,8 +15,8 @@ # specific language governing permissions and limitations # under the License. import typing -import warnings +from selenium.deprecated import deprecated_attributes from selenium.types import SubprocessStdAlias from selenium.webdriver.chromium import service @@ -34,6 +34,9 @@ class Service(service.ChromiumService): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ + @deprecated_attributes( + "verbose", message="verbose=True is deprecated. Use `service_args=['--verbose', ...]` instead." + ) def __init__( self, executable_path: str = None, @@ -46,13 +49,7 @@ def __init__( **kwargs, ) -> None: self.service_args = service_args or [] - if verbose: - warnings.warn( - "verbose=True is deprecated. Use `service_args=['--verbose', ...]` instead.", - DeprecationWarning, - stacklevel=2, - ) self.service_args.append("--verbose") super().__init__( diff --git a/py/selenium/webdriver/firefox/firefox_profile.py b/py/selenium/webdriver/firefox/firefox_profile.py index 570b03a06d116..40e12ca9a7d12 100644 --- a/py/selenium/webdriver/firefox/firefox_profile.py +++ b/py/selenium/webdriver/firefox/firefox_profile.py @@ -29,6 +29,7 @@ from xml.dom import minidom from selenium.common.exceptions import WebDriverException +from selenium.deprecated import deprecated_function WEBDRIVER_EXT = "webdriver.xpi" WEBDRIVER_PREFERENCES = "webdriver_prefs.json" @@ -43,6 +44,7 @@ class FirefoxProfile: ANONYMOUS_PROFILE_NAME = "WEBDRIVER_ANONYMOUS_PROFILE" DEFAULT_PREFERENCES = None + @deprecated_function("firefox_profile has been deprecated, please use an Options object") def __init__(self, profile_directory=None): """Initialises a new instance of a Firefox Profile. @@ -53,9 +55,6 @@ def __init__(self, profile_directory=None): This defaults to None and will create a new directory when object is created. """ - warnings.warn( - "firefox_profile has been deprecated, please use an Options object", DeprecationWarning, stacklevel=2 - ) if not FirefoxProfile.DEFAULT_PREFERENCES: with open( os.path.join(os.path.dirname(__file__), WEBDRIVER_PREFERENCES), encoding="utf-8" diff --git a/py/selenium/webdriver/firefox/options.py b/py/selenium/webdriver/firefox/options.py index 5d312d0d0c73c..d3fcb0c35a78e 100644 --- a/py/selenium/webdriver/firefox/options.py +++ b/py/selenium/webdriver/firefox/options.py @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. import typing -import warnings from typing import Union +from selenium.deprecated import deprecated_function from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.options import ArgOptions from selenium.webdriver.firefox.firefox_binary import FirefoxBinary @@ -81,49 +81,40 @@ def set_preference(self, name: str, value: Union[str, int, bool]): self._preferences[name] = value @property + @deprecated_function("Getting a profile has been deprecated.") def profile(self) -> FirefoxProfile: """ :Returns: The Firefox profile to use. """ - if self._profile: - warnings.warn("Getting a profile has been deprecated.", DeprecationWarning, stacklevel=2) return self._profile @profile.setter + @deprecated_function( + "Setting a profile has been deprecated. Please use the set_preference and install_addons methods" + ) def profile(self, new_profile: Union[str, FirefoxProfile]) -> None: """Sets location of the browser profile to use, either by string or ``FirefoxProfile``.""" - warnings.warn( - "Setting a profile has been deprecated. Please use the set_preference and install_addons methods", - DeprecationWarning, - stacklevel=2, - ) if not isinstance(new_profile, FirefoxProfile): new_profile = FirefoxProfile(new_profile) self._profile = new_profile @property + @deprecated_function("headless property is deprecated, instead check for '-headless' in arguments") def headless(self) -> bool: """ :Returns: True if the headless argument is set, else False """ - warnings.warn( - "headless property is deprecated, instead check for '-headless' in arguments", - DeprecationWarning, - stacklevel=2, - ) return "-headless" in self._arguments @headless.setter + @deprecated_function("headless property is deprecated, instead use add_argument('-headless')") def headless(self, value: bool) -> None: """Sets the headless argument. Args: value: boolean value indicating to set the headless option """ - warnings.warn( - "headless property is deprecated, instead use add_argument('-headless')", DeprecationWarning, stacklevel=2 - ) if not isinstance(value, bool): raise TypeError("value must be a boolean") if value: diff --git a/py/selenium/webdriver/firefox/service.py b/py/selenium/webdriver/firefox/service.py index a6fd13e254d63..d82504b240b79 100644 --- a/py/selenium/webdriver/firefox/service.py +++ b/py/selenium/webdriver/firefox/service.py @@ -18,6 +18,7 @@ import warnings from typing import List +from selenium.deprecated import deprecated_attributes from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service from selenium.webdriver.common import utils @@ -35,6 +36,7 @@ class Service(service.Service): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ + @deprecated_attributes("log_path", message="log_path has been deprecated, please use log_output") def __init__( self, executable_path: str = None, @@ -46,8 +48,7 @@ def __init__( **kwargs, ) -> None: self.service_args = service_args or [] - if log_path is not None: - warnings.warn("log_path has been deprecated, please use log_output", DeprecationWarning, stacklevel=2) + if log_path: log_output = open(log_path, "a+", encoding="utf-8") if log_path is None and log_output is None: diff --git a/py/selenium/webdriver/ie/service.py b/py/selenium/webdriver/ie/service.py index 06e58c2948410..52d743806390f 100644 --- a/py/selenium/webdriver/ie/service.py +++ b/py/selenium/webdriver/ie/service.py @@ -15,9 +15,9 @@ # specific language governing permissions and limitations # under the License. import typing -import warnings from typing import List +from selenium.deprecated import deprecated_attributes from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service @@ -25,6 +25,7 @@ class Service(service.Service): """Object that manages the starting and stopping of the IEDriver.""" + @deprecated_attributes("log_path", message="log_file has been deprecated, please use log_output") def __init__( self, executable_path: str = None, @@ -53,7 +54,6 @@ def __init__( if log_level: self.service_args.append(f"--log-level={log_level}") if log_file: - warnings.warn("log_file has been deprecated, please use log_output", DeprecationWarning, stacklevel=2) self.service_args.append(f"--log-file={log_file}") super().__init__( diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index dbf40a91868a3..d9a8185439090 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -38,6 +38,7 @@ from selenium.common.exceptions import NoSuchCookieException from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import WebDriverException +from selenium.deprecated import deprecated_function from selenium.webdriver.common.by import By from selenium.webdriver.common.html5.application_cache import ApplicationCache from selenium.webdriver.common.options import BaseOptions @@ -769,9 +770,9 @@ def find_elements(self, by=By.ID, value: Optional[str] = None) -> List[WebElemen return self.execute(Command.FIND_ELEMENTS, {"using": by, "value": value})["value"] or [] @property + @deprecated_function("desired_capabilities is deprecated. Please call capabilities.") def desired_capabilities(self) -> dict: """returns the drivers current desired capabilities being used.""" - warnings.warn("desired_capabilities is deprecated. Please call capabilities.", DeprecationWarning, stacklevel=2) return self.caps @property diff --git a/py/selenium/webdriver/safari/service.py b/py/selenium/webdriver/safari/service.py index be6427960f37e..aafb5aecbd9f0 100644 --- a/py/selenium/webdriver/safari/service.py +++ b/py/selenium/webdriver/safari/service.py @@ -16,8 +16,8 @@ # under the License. import typing -import warnings +from selenium.deprecated import deprecated_attributes from selenium.webdriver.common import service @@ -32,6 +32,7 @@ class Service(service.Service): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ + @deprecated_attributes("quiet", message="quiet is no longer needed to supress output") def __init__( self, executable_path: str = None, @@ -43,9 +44,6 @@ def __init__( **kwargs, ) -> None: self.service_args = service_args or [] - if quiet is not None: - warnings.warn("quiet is no longer needed to supress output", DeprecationWarning, stacklevel=2) - self._reuse_service = reuse_service super().__init__( executable=executable_path, diff --git a/py/selenium/webdriver/safari/webdriver.py b/py/selenium/webdriver/safari/webdriver.py index 90fd755ba47ec..5aa1e109b6daa 100644 --- a/py/selenium/webdriver/safari/webdriver.py +++ b/py/selenium/webdriver/safari/webdriver.py @@ -16,9 +16,9 @@ # under the License. import http.client as http_client -import warnings from selenium.common.exceptions import WebDriverException +from selenium.deprecated import deprecated_attributes from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver from ..common.driver_finder import DriverFinder @@ -30,6 +30,9 @@ class WebDriver(RemoteWebDriver): """Controls the SafariDriver and allows you to drive the browser.""" + @deprecated_attributes( + "reuse_service", message="reuse_service has been deprecated, please use the Service class to set it" + ) def __init__( self, reuse_service=False, @@ -47,13 +50,6 @@ def __init__( - options - Instance of ``options.Options``. - service - Service object for handling the browser driver if you need to pass extra details """ - if reuse_service: - warnings.warn( - "reuse_service has been deprecated, please use the Service class to set it", - DeprecationWarning, - stacklevel=2, - ) - self.service = service if service else Service() options = options if options else Options() From e1107486b3c690ac694577e4747e7aed6ca44e8d Mon Sep 17 00:00:00 2001 From: sandeepsuryaprasad Date: Fri, 28 Jul 2023 01:17:32 +0530 Subject: [PATCH 2/4] [py] added decorator for handling deprecations --- py/selenium/deprecated.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/deprecated.py b/py/selenium/deprecated.py index 4fac4b8ee9c28..2111eb769ff8f 100644 --- a/py/selenium/deprecated.py +++ b/py/selenium/deprecated.py @@ -24,7 +24,7 @@ def wrapper(*args, **kwargs): _attr = getattr(args[0], attr, None) if _attr: warn(f"'{message}': will be removed from {removed_from_version}", DeprecationWarning, stacklevel=2) - return result + return result return wrapper From 5e7b404f9e32fca28cca279f5c80cedcd4b6467d Mon Sep 17 00:00:00 2001 From: sandeepsuryaprasad Date: Fri, 28 Jul 2023 15:48:25 +0530 Subject: [PATCH 3/4] [py] incorporated review comments --- py/selenium/deprecated.py | 44 ++++++++++++++++++----- py/selenium/webdriver/chromium/service.py | 4 +-- py/selenium/webdriver/edge/service.py | 6 ++-- py/selenium/webdriver/firefox/service.py | 14 ++++---- py/selenium/webdriver/ie/service.py | 4 +-- py/selenium/webdriver/safari/service.py | 4 +-- py/selenium/webdriver/safari/webdriver.py | 7 ++-- 7 files changed, 53 insertions(+), 30 deletions(-) diff --git a/py/selenium/deprecated.py b/py/selenium/deprecated.py index 2111eb769ff8f..00cff38997023 100644 --- a/py/selenium/deprecated.py +++ b/py/selenium/deprecated.py @@ -1,14 +1,33 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from functools import wraps from warnings import warn -removed_from_version = "4.12" +version = "4.12" def deprecated_function(message): """decorator to log deprecation warning messgaes for deprecated methods.""" + @wraps def _deprecated_function(func): def wrapper(*args, **kwargs): - warn(f"{message}: will be removed from {removed_from_version}", DeprecationWarning, stacklevel=2) + warn(f"{message}: will be removed from {version}", DeprecationWarning, stacklevel=2) return func(*args, **kwargs) return wrapper @@ -16,15 +35,22 @@ def wrapper(*args, **kwargs): return _deprecated_function -def deprecated_attributes(*attrs, message): +def deprecated_attribute(message, **dep_attr): + @wraps def _deprecated_attributes(func): def wrapper(*args, **kwargs): - result = func(*args, **kwargs) - for attr in attrs: - _attr = getattr(args[0], attr, None) - if _attr: - warn(f"'{message}': will be removed from {removed_from_version}", DeprecationWarning, stacklevel=2) - return result + func(*args, **kwargs) + dep_attr_name = list(dep_attr.keys())[0] # getting the name of deprecated attr + dep_attr_type = list(dep_attr.values())[0] # getting should the value be truthy or falsy? + # get the value of the deprecated attributes + dep_attr_value = getattr(args[0], dep_attr_name) # getting actual value passed to depattr + # check the truthiness of the deprecated attribute + if bool(dep_attr_value) is dep_attr_type: + warn( + f"'{dep_attr_name}': will be removed from {version}: {message}", + DeprecationWarning, + stacklevel=2, + ) return wrapper diff --git a/py/selenium/webdriver/chromium/service.py b/py/selenium/webdriver/chromium/service.py index d61dd5d729616..3e892655a12d0 100644 --- a/py/selenium/webdriver/chromium/service.py +++ b/py/selenium/webdriver/chromium/service.py @@ -17,7 +17,7 @@ import typing from selenium.common import InvalidArgumentException -from selenium.deprecated import deprecated_attributes +from selenium.deprecated import deprecated_attribute from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service @@ -33,7 +33,7 @@ class ChromiumService(service.Service): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ - @deprecated_attributes("log_path", message="log_path has been deprecated, please use log_output") + @deprecated_attribute("log_path has been deprecated, please use log_output", log_path=True) def __init__( self, executable_path: str = None, diff --git a/py/selenium/webdriver/edge/service.py b/py/selenium/webdriver/edge/service.py index f7491a2a54377..11a386c25f81c 100644 --- a/py/selenium/webdriver/edge/service.py +++ b/py/selenium/webdriver/edge/service.py @@ -16,7 +16,7 @@ # under the License. import typing -from selenium.deprecated import deprecated_attributes +from selenium.deprecated import deprecated_attribute from selenium.types import SubprocessStdAlias from selenium.webdriver.chromium import service @@ -34,9 +34,7 @@ class Service(service.ChromiumService): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ - @deprecated_attributes( - "verbose", message="verbose=True is deprecated. Use `service_args=['--verbose', ...]` instead." - ) + @deprecated_attribute("verbose=True is deprecated. Use `service_args=['--verbose', ...]` instead.", verbose=True) def __init__( self, executable_path: str = None, diff --git a/py/selenium/webdriver/firefox/service.py b/py/selenium/webdriver/firefox/service.py index d82504b240b79..2e823d81b9da7 100644 --- a/py/selenium/webdriver/firefox/service.py +++ b/py/selenium/webdriver/firefox/service.py @@ -15,10 +15,9 @@ # specific language governing permissions and limitations # under the License. import typing -import warnings from typing import List -from selenium.deprecated import deprecated_attributes +from selenium.deprecated import deprecated_attribute from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service from selenium.webdriver.common import utils @@ -36,7 +35,11 @@ class Service(service.Service): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ - @deprecated_attributes("log_path", message="log_path has been deprecated, please use log_output") + @deprecated_attribute("log_path has been deprecated, please use log_output", log_path=True) + @deprecated_attribute( + "Firefox will soon stop logging to geckodriver.log by default; Specify desired logs with log_output", + log_output=False, + ) def __init__( self, executable_path: str = None, @@ -52,11 +55,6 @@ def __init__( log_output = open(log_path, "a+", encoding="utf-8") if log_path is None and log_output is None: - warnings.warn( - "Firefox will soon stop logging to geckodriver.log by default; Specify desired logs with log_output", - DeprecationWarning, - stacklevel=2, - ) log_output = open("geckodriver.log", "a+", encoding="utf-8") super().__init__( diff --git a/py/selenium/webdriver/ie/service.py b/py/selenium/webdriver/ie/service.py index 52d743806390f..2f253987b91f5 100644 --- a/py/selenium/webdriver/ie/service.py +++ b/py/selenium/webdriver/ie/service.py @@ -17,7 +17,7 @@ import typing from typing import List -from selenium.deprecated import deprecated_attributes +from selenium.deprecated import deprecated_attribute from selenium.types import SubprocessStdAlias from selenium.webdriver.common import service @@ -25,7 +25,7 @@ class Service(service.Service): """Object that manages the starting and stopping of the IEDriver.""" - @deprecated_attributes("log_path", message="log_file has been deprecated, please use log_output") + @deprecated_attribute("log_file has been deprecated, please use log_output", log_file=True) def __init__( self, executable_path: str = None, diff --git a/py/selenium/webdriver/safari/service.py b/py/selenium/webdriver/safari/service.py index aafb5aecbd9f0..31945d9fd04f2 100644 --- a/py/selenium/webdriver/safari/service.py +++ b/py/selenium/webdriver/safari/service.py @@ -17,7 +17,7 @@ import typing -from selenium.deprecated import deprecated_attributes +from selenium.deprecated import deprecated_attribute from selenium.webdriver.common import service @@ -32,7 +32,7 @@ class Service(service.Service): :param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`. """ - @deprecated_attributes("quiet", message="quiet is no longer needed to supress output") + @deprecated_attribute(message="quiet is no longer needed to supress output", quiet=True) def __init__( self, executable_path: str = None, diff --git a/py/selenium/webdriver/safari/webdriver.py b/py/selenium/webdriver/safari/webdriver.py index 5aa1e109b6daa..ab1eeb11ee4fe 100644 --- a/py/selenium/webdriver/safari/webdriver.py +++ b/py/selenium/webdriver/safari/webdriver.py @@ -18,7 +18,7 @@ import http.client as http_client from selenium.common.exceptions import WebDriverException -from selenium.deprecated import deprecated_attributes +from selenium.deprecated import deprecated_attribute from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver from ..common.driver_finder import DriverFinder @@ -30,8 +30,9 @@ class WebDriver(RemoteWebDriver): """Controls the SafariDriver and allows you to drive the browser.""" - @deprecated_attributes( - "reuse_service", message="reuse_service has been deprecated, please use the Service class to set it" + @deprecated_attribute( + "reuse_service has been deprecated, please use the Service class to set it", + reuse_service=True, ) def __init__( self, From bb9bd4f23f4bade4f5d5c3e65fada2590f74e8a6 Mon Sep 17 00:00:00 2001 From: sandeepsuryaprasad Date: Fri, 28 Jul 2023 20:09:35 +0530 Subject: [PATCH 4/4] [py] fixed typo --- py/selenium/deprecated.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/deprecated.py b/py/selenium/deprecated.py index 00cff38997023..8fdfdd9ca8201 100644 --- a/py/selenium/deprecated.py +++ b/py/selenium/deprecated.py @@ -41,7 +41,7 @@ def _deprecated_attributes(func): def wrapper(*args, **kwargs): func(*args, **kwargs) dep_attr_name = list(dep_attr.keys())[0] # getting the name of deprecated attr - dep_attr_type = list(dep_attr.values())[0] # getting should the value be truthy or falsy? + dep_attr_type = list(dep_attr.values())[0] # should the value be truthy or falsy? # get the value of the deprecated attributes dep_attr_value = getattr(args[0], dep_attr_name) # getting actual value passed to depattr # check the truthiness of the deprecated attribute