Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/wpewebkit/options.py
4020 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
19
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
20
from selenium.webdriver.common.options import ArgOptions
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()
63
64