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] Remove unsupported safari parameters from Options #12454

Merged
merged 1 commit into from
Aug 1, 2023
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
56 changes: 0 additions & 56 deletions py/selenium/webdriver/safari/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,13 @@
from selenium.webdriver.common.options import ArgOptions


class Log:
def __init__(self) -> None:
self.level = None

def to_capabilities(self) -> dict:
if self.level:
return {"log": {"level": self.level}}
return {}


class Options(ArgOptions):
KEY = "safari.options"

# @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
AUTOMATIC_INSPECTION = "safari:automaticInspection"
AUTOMATIC_PROFILING = "safari:automaticProfiling"

SAFARI_TECH_PREVIEW = "Safari Technology Preview"

def __init__(self) -> None:
super().__init__()
self._binary_location = None
self._preferences: dict = {}
self.log = Log()

@property
def binary_location(self) -> str:
"""
:Returns: The location of the browser binary otherwise an empty string
"""
return self._binary_location

@binary_location.setter
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) -> dict:
"""Marshals the options to an desired capabilities object."""
# This intentionally looks at the internal properties
# so if a binary or profile has _not_ been set,
# it will defer to geckodriver to find the system Firefox
# and generate a fresh profile.
caps = self._caps
opts = {}

if self._arguments:
opts["args"] = self._arguments
if self._binary_location:
opts["binary"] = self._binary_location
opts.update(self.log.to_capabilities())

if opts:
caps[Options.KEY] = opts

return caps

@property
def default_capabilities(self) -> typing.Dict[str, str]:
return DesiredCapabilities.SAFARI.copy()
Expand Down
20 changes: 0 additions & 20 deletions py/test/unit/selenium/webdriver/safari/safari_options_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ def options():
return Options()


def test_set_binary_location(options):
options.binary_location = "/foo/bar"
assert options._binary_location == "/foo/bar"


def test_get_binary_location(options):
options._binary_location = "/foo/bar"
assert options.binary_location == "/foo/bar"


def test_creates_capabilities(options):
options._arguments = ["foo"]
options._binary_location = "/bar"
caps = options.to_capabilities()
opts = caps.get(Options.KEY)
assert opts
assert "foo" in opts["args"]
assert opts["binary"] == "/bar"


def test_starts_with_default_capabilities(options):
from selenium.webdriver import DesiredCapabilities

Expand Down
Loading