Skip to content

Commit

Permalink
[py] safari does not support any of this
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jul 31, 2023
1 parent a54e88d commit 4b351be
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
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

0 comments on commit 4b351be

Please sign in to comment.