diff --git a/py/selenium/webdriver/chromium/options.py b/py/selenium/webdriver/chromium/options.py index 11cd6e65ee3bc..06c936a6eeec5 100644 --- a/py/selenium/webdriver/chromium/options.py +++ b/py/selenium/webdriver/chromium/options.py @@ -51,6 +51,8 @@ def binary_location(self, value: str) -> None: :Args: - value: path to the Chromium binary """ + if not isinstance(value, str): + raise TypeError(self.BINARY_LOCATION_ERROR) self._binary_location = value @property @@ -69,6 +71,8 @@ def debugger_address(self, value: str) -> None: :Args: - value: address of remote devtools instance if any (hostname[:port]) """ + if not isinstance(value, str): + raise TypeError("Debugger Address must be a string") self._debugger_address = value @property @@ -162,6 +166,10 @@ def headless(self, value: bool) -> None: stacklevel=2, ) args = {"--headless"} + + if not isinstance(value, bool): + raise TypeError("value must be a boolean") + if value: self._arguments.extend(args) else: diff --git a/py/selenium/webdriver/common/options.py b/py/selenium/webdriver/common/options.py index ea267e499a084..bcdfe095b9977 100644 --- a/py/selenium/webdriver/common/options.py +++ b/py/selenium/webdriver/common/options.py @@ -372,6 +372,8 @@ def default_capabilities(self): class ArgOptions(BaseOptions): + BINARY_LOCATION_ERROR = "Binary Location Must be a String" + def __init__(self) -> None: super().__init__() self._arguments = [] diff --git a/py/selenium/webdriver/firefox/options.py b/py/selenium/webdriver/firefox/options.py index ea5f688c18974..5d312d0d0c73c 100644 --- a/py/selenium/webdriver/firefox/options.py +++ b/py/selenium/webdriver/firefox/options.py @@ -67,6 +67,8 @@ def binary_location(self) -> str: @binary_location.setter # noqa def binary_location(self, value: str) -> None: """Sets the location of the browser binary by string.""" + if not isinstance(value, str): + raise TypeError(self.BINARY_LOCATION_ERROR) self.binary = value @property @@ -122,6 +124,8 @@ def headless(self, value: bool) -> None: 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: self._arguments.append("-headless") elif "-headless" in self._arguments: diff --git a/py/selenium/webdriver/safari/options.py b/py/selenium/webdriver/safari/options.py index 633a7fc19ed63..86a1d01ee56dd 100644 --- a/py/selenium/webdriver/safari/options.py +++ b/py/selenium/webdriver/safari/options.py @@ -59,6 +59,8 @@ def binary_location(self, value: str) -> None: :Args: - value : path to the browser binary """ + if not isinstance(value, str): + raise TypeError(self.BINARY_LOCATION_ERROR) self._binary_location = value def to_capabilities(self) -> dict: @@ -97,6 +99,8 @@ def automatic_inspection(self, value: bool) -> None: :Args: - value: boolean value """ + if not isinstance(value, bool): + raise TypeError("Automatic Inspection must be a boolean") self.set_capability(self.AUTOMATIC_INSPECTION, value) @property @@ -111,6 +115,8 @@ def automatic_profiling(self, value: bool) -> None: :Args: - value: boolean value """ + if not isinstance(value, bool): + raise TypeError("Automatic Profiling must be a boolean") self.set_capability(self.AUTOMATIC_PROFILING, value) @property @@ -126,4 +132,6 @@ def use_technology_preview(self, value: bool) -> None: :Args: - value: boolean value """ + if not isinstance(value, bool): + raise TypeError("Use Technology Preview must be a boolean") self.set_capability("browserName", self.SAFARI_TECH_PREVIEW if value else "safari") diff --git a/py/selenium/webdriver/safari/service.py b/py/selenium/webdriver/safari/service.py index 4051a8d63ad7f..be6427960f37e 100644 --- a/py/selenium/webdriver/safari/service.py +++ b/py/selenium/webdriver/safari/service.py @@ -68,4 +68,6 @@ def reuse_service(self) -> bool: @reuse_service.setter def reuse_service(self, reuse: bool) -> None: + if not isinstance(reuse, bool): + raise TypeError("reuse must be a boolean") self._reuse_service = reuse diff --git a/py/selenium/webdriver/wpewebkit/options.py b/py/selenium/webdriver/wpewebkit/options.py index 6ad8261360bb5..3b4f3d8680dc1 100644 --- a/py/selenium/webdriver/wpewebkit/options.py +++ b/py/selenium/webdriver/wpewebkit/options.py @@ -34,12 +34,14 @@ def binary_location(self) -> str: return self._binary_location @binary_location.setter - def binary_location(self, value) -> None: + def binary_location(self, value: str) -> None: """Allows you to set the browser binary to launch. :Args: - value : path to the browser binary """ + if not isinstance(value, str): + raise TypeError(self.BINARY_LOCATION_ERROR) self._binary_location = value def to_capabilities(self):