| 21 | |
| 22 | |
| 23 | class Options(ArgOptions): |
| 24 | KEY = "wpe:browserOptions" |
| 25 | |
| 26 | def __init__(self) -> None: |
| 27 | super().__init__() |
| 28 | self._binary_location = "" |
| 29 | |
| 30 | @property |
| 31 | def binary_location(self) -> str: |
| 32 | """Return the location of the browser binary or an empty string.""" |
| 33 | return self._binary_location |
| 34 | |
| 35 | @binary_location.setter |
| 36 | def binary_location(self, value: str) -> None: |
| 37 | """Allows you to set the browser binary to launch. |
| 38 | |
| 39 | Args: |
| 40 | value: path to the browser binary |
| 41 | """ |
| 42 | if not isinstance(value, str): |
| 43 | raise TypeError(self.BINARY_LOCATION_ERROR) |
| 44 | self._binary_location = value |
| 45 | |
| 46 | def to_capabilities(self) -> dict: |
| 47 | """Create a capabilities dictionary with all set options.""" |
| 48 | caps = self._caps |
| 49 | |
| 50 | browser_options = {} |
| 51 | if self.binary_location: |
| 52 | browser_options["binary"] = self.binary_location |
| 53 | if self.arguments: |
| 54 | browser_options["args"] = self.arguments |
| 55 | |
| 56 | caps[Options.KEY] = browser_options |
| 57 | |
| 58 | return caps |
| 59 | |
| 60 | @property |
| 61 | def default_capabilities(self) -> dict[str, str]: |
| 62 | return DesiredCapabilities.WPEWEBKIT.copy() |