| 20 | |
| 21 | |
| 22 | class Options(ChromiumOptions): |
| 23 | KEY = "ms:edgeOptions" |
| 24 | |
| 25 | def __init__(self) -> None: |
| 26 | """Initialize EdgeOptions with default settings.""" |
| 27 | super().__init__() |
| 28 | self._use_webview = False |
| 29 | |
| 30 | @property |
| 31 | def use_webview(self) -> bool: |
| 32 | """Returns Whether WebView2 is enabled for Edge browser.""" |
| 33 | return self._use_webview |
| 34 | |
| 35 | @use_webview.setter |
| 36 | def use_webview(self, value: bool) -> None: |
| 37 | """Enables or disables WebView2 support for Edge browser. |
| 38 | |
| 39 | Args: |
| 40 | value: True to enable WebView2 support, False to disable. |
| 41 | """ |
| 42 | self._use_webview = bool(value) |
| 43 | |
| 44 | def to_capabilities(self) -> dict: |
| 45 | """Creates a capabilities with all the options that have been set. |
| 46 | |
| 47 | Returns: |
| 48 | A dictionary with all set options for Edge browser. |
| 49 | """ |
| 50 | caps = super().to_capabilities() |
| 51 | if self._use_webview: |
| 52 | caps["browserName"] = "webview2" |
| 53 | |
| 54 | return caps |
| 55 | |
| 56 | @property |
| 57 | def default_capabilities(self) -> dict: |
| 58 | """Returns the default capabilities for Edge browser.""" |
| 59 | return DesiredCapabilities.EDGE.copy() |