|
20 | 20 | from selenium.webdriver.common.options import ArgOptions
|
21 | 21 |
|
22 | 22 |
|
23 |
| -class Log: |
24 |
| - def __init__(self) -> None: |
25 |
| - self.level = None |
26 |
| - |
27 |
| - def to_capabilities(self) -> dict: |
28 |
| - if self.level: |
29 |
| - return {"log": {"level": self.level}} |
30 |
| - return {} |
31 |
| - |
32 |
| - |
33 | 23 | class Options(ArgOptions):
|
34 |
| - KEY = "safari.options" |
35 |
| - |
36 | 24 | # @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
|
37 | 25 | AUTOMATIC_INSPECTION = "safari:automaticInspection"
|
38 | 26 | AUTOMATIC_PROFILING = "safari:automaticProfiling"
|
39 | 27 |
|
40 | 28 | SAFARI_TECH_PREVIEW = "Safari Technology Preview"
|
41 | 29 |
|
42 |
| - def __init__(self) -> None: |
43 |
| - super().__init__() |
44 |
| - self._binary_location = None |
45 |
| - self._preferences: dict = {} |
46 |
| - self.log = Log() |
47 |
| - |
48 |
| - @property |
49 |
| - def binary_location(self) -> str: |
50 |
| - """ |
51 |
| - :Returns: The location of the browser binary otherwise an empty string |
52 |
| - """ |
53 |
| - return self._binary_location |
54 |
| - |
55 |
| - @binary_location.setter |
56 |
| - def binary_location(self, value: str) -> None: |
57 |
| - """Allows you to set the browser binary to launch. |
58 |
| -
|
59 |
| - :Args: |
60 |
| - - value : path to the browser binary |
61 |
| - """ |
62 |
| - if not isinstance(value, str): |
63 |
| - raise TypeError(self.BINARY_LOCATION_ERROR) |
64 |
| - self._binary_location = value |
65 |
| - |
66 |
| - def to_capabilities(self) -> dict: |
67 |
| - """Marshals the options to an desired capabilities object.""" |
68 |
| - # This intentionally looks at the internal properties |
69 |
| - # so if a binary or profile has _not_ been set, |
70 |
| - # it will defer to geckodriver to find the system Firefox |
71 |
| - # and generate a fresh profile. |
72 |
| - caps = self._caps |
73 |
| - opts = {} |
74 |
| - |
75 |
| - if self._arguments: |
76 |
| - opts["args"] = self._arguments |
77 |
| - if self._binary_location: |
78 |
| - opts["binary"] = self._binary_location |
79 |
| - opts.update(self.log.to_capabilities()) |
80 |
| - |
81 |
| - if opts: |
82 |
| - caps[Options.KEY] = opts |
83 |
| - |
84 |
| - return caps |
85 |
| - |
86 | 30 | @property
|
87 | 31 | def default_capabilities(self) -> typing.Dict[str, str]:
|
88 | 32 | return DesiredCapabilities.SAFARI.copy()
|
|
0 commit comments