Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/wpewebkit/options.py
1864 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
"""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
if not isinstance(value, str):
44
raise TypeError(self.BINARY_LOCATION_ERROR)
45
self._binary_location = value
46
47
def to_capabilities(self):
48
"""Creates a capabilities with all the options that have been set and
49
returns a dictionary with everything."""
50
caps = self._caps
51
52
browser_options = {}
53
if self.binary_location:
54
browser_options["binary"] = self.binary_location
55
if self.arguments:
56
browser_options["args"] = self.arguments
57
58
caps[Options.KEY] = browser_options
59
60
return caps
61
62
@property
63
def default_capabilities(self) -> dict[str, str]:
64
return DesiredCapabilities.WPEWEBKIT.copy()
65
66