| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities |
| 19 |
from selenium.webdriver.common.options import ArgOptions |
| 20 |
|
| 21 |
|
| 22 |
class Options(ArgOptions): |
| 23 |
KEY = "webkitgtk:browserOptions" |
| 24 |
|
| 25 |
def __init__(self) -> None: |
| 26 |
super().__init__() |
| 27 |
self._binary_location = "" |
| 28 |
self._overlay_scrollbars_enabled = True |
| 29 |
|
| 30 |
@property |
| 31 |
def binary_location(self) -> str: |
| 32 |
""":Returns: The location of the browser binary otherwise an empty |
| 33 |
string.""" |
| 34 |
return self._binary_location |
| 35 |
|
| 36 |
@binary_location.setter |
| 37 |
def binary_location(self, value: str) -> None: |
| 38 |
"""Allows you to set the browser binary to launch. |
| 39 |
|
| 40 |
:Args: |
| 41 |
- value : path to the browser binary |
| 42 |
""" |
| 43 |
self._binary_location = value |
| 44 |
|
| 45 |
@property |
| 46 |
def overlay_scrollbars_enabled(self): |
| 47 |
""":Returns: Whether overlay scrollbars should be enabled.""" |
| 48 |
return self._overlay_scrollbars_enabled |
| 49 |
|
| 50 |
@overlay_scrollbars_enabled.setter |
| 51 |
def overlay_scrollbars_enabled(self, value) -> None: |
| 52 |
"""Allows you to enable or disable overlay scrollbars. |
| 53 |
|
| 54 |
:Args: |
| 55 |
- value : True or False |
| 56 |
""" |
| 57 |
self._overlay_scrollbars_enabled = value |
| 58 |
|
| 59 |
def to_capabilities(self): |
| 60 |
"""Creates a capabilities with all the options that have been set and |
| 61 |
returns a dictionary with everything.""" |
| 62 |
caps = self._caps |
| 63 |
|
| 64 |
browser_options = {} |
| 65 |
if self.binary_location: |
| 66 |
browser_options["binary"] = self.binary_location |
| 67 |
if self.arguments: |
| 68 |
browser_options["args"] = self.arguments |
| 69 |
browser_options["useOverlayScrollbars"] = self.overlay_scrollbars_enabled |
| 70 |
|
| 71 |
caps[Options.KEY] = browser_options |
| 72 |
|
| 73 |
return caps |
| 74 |
|
| 75 |
@property |
| 76 |
def default_capabilities(self): |
| 77 |
return DesiredCapabilities.WEBKITGTK.copy() |