Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/webkitgtk/options.py
3985 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
from typing import Any
19
20
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
21
from selenium.webdriver.common.options import ArgOptions
22
23
24
class Options(ArgOptions):
25
KEY = "webkitgtk:browserOptions"
26
27
def __init__(self) -> None:
28
super().__init__()
29
self._binary_location = ""
30
self._overlay_scrollbars_enabled = True
31
32
@property
33
def binary_location(self) -> str:
34
"""Return the location of the browser binary or an empty string."""
35
return self._binary_location
36
37
@binary_location.setter
38
def binary_location(self, value: str) -> None:
39
"""Allows you to set the browser binary to launch.
40
41
Args:
42
value: path to the browser binary
43
"""
44
self._binary_location = value
45
46
@property
47
def overlay_scrollbars_enabled(self) -> bool:
48
"""Return whether overlay scrollbars should be enabled."""
49
return self._overlay_scrollbars_enabled
50
51
@overlay_scrollbars_enabled.setter
52
def overlay_scrollbars_enabled(self, value) -> None:
53
"""Allows you to enable or disable overlay scrollbars.
54
55
Args:
56
value: True or False
57
"""
58
self._overlay_scrollbars_enabled = value
59
60
def to_capabilities(self) -> dict:
61
"""Create a capabilities dictionary with all set options."""
62
caps = self._caps
63
64
browser_options: dict[str, Any] = {}
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()
78
79