Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/edge/service.py
4012 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 collections.abc import Mapping, Sequence
19
from typing import IO, Any
20
21
from selenium.webdriver.chromium import service
22
23
24
class Service(service.ChromiumService):
25
"""Service class responsible for starting and stopping msedgedriver.
26
27
Args:
28
executable_path: Install path of the msedgedriver executable, defaults to `msedgedriver`.
29
port: Port for the service to run on, defaults to 0 where the operating system will decide.
30
log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
31
service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.
32
env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
33
driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.
34
"""
35
36
def __init__(
37
self,
38
executable_path: str | None = None,
39
port: int = 0,
40
log_output: int | str | IO[Any] | None = None,
41
service_args: Sequence[str] | None = None,
42
env: Mapping[str, str] | None = None,
43
driver_path_env_key: str | None = None,
44
**kwargs,
45
) -> None:
46
"""Initialize Edge service with the specified parameters."""
47
self._service_args = list(service_args or [])
48
driver_path_env_key = driver_path_env_key or "SE_EDGEDRIVER"
49
50
super().__init__(
51
executable_path=executable_path,
52
port=port,
53
service_args=service_args,
54
log_output=log_output,
55
env=env,
56
driver_path_env_key=driver_path_env_key,
57
**kwargs,
58
)
59
60
@property
61
def service_args(self) -> Sequence[str]:
62
"""Returns the sequence of service arguments."""
63
return self._service_args
64
65
@service_args.setter
66
def service_args(self, value: Sequence[str]):
67
"""Sets the service arguments for the Edge driver.
68
69
Args:
70
value: A sequence of strings representing service arguments.
71
72
Raises:
73
TypeError: If value is not a sequence or is a string.
74
"""
75
if isinstance(value, str) or not isinstance(value, Sequence):
76
raise TypeError("service_args must be a sequence")
77
self._service_args = list(value)
78
79