Path: blob/trunk/py/selenium/webdriver/edge/service.py
4012 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from collections.abc import Mapping, Sequence18from typing import IO, Any1920from selenium.webdriver.chromium import service212223class Service(service.ChromiumService):24"""Service class responsible for starting and stopping msedgedriver.2526Args:27executable_path: Install path of the msedgedriver executable, defaults to `msedgedriver`.28port: Port for the service to run on, defaults to 0 where the operating system will decide.29log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.30service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.31env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.32driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.33"""3435def __init__(36self,37executable_path: str | None = None,38port: int = 0,39log_output: int | str | IO[Any] | None = None,40service_args: Sequence[str] | None = None,41env: Mapping[str, str] | None = None,42driver_path_env_key: str | None = None,43**kwargs,44) -> None:45"""Initialize Edge service with the specified parameters."""46self._service_args = list(service_args or [])47driver_path_env_key = driver_path_env_key or "SE_EDGEDRIVER"4849super().__init__(50executable_path=executable_path,51port=port,52service_args=service_args,53log_output=log_output,54env=env,55driver_path_env_key=driver_path_env_key,56**kwargs,57)5859@property60def service_args(self) -> Sequence[str]:61"""Returns the sequence of service arguments."""62return self._service_args6364@service_args.setter65def service_args(self, value: Sequence[str]):66"""Sets the service arguments for the Edge driver.6768Args:69value: A sequence of strings representing service arguments.7071Raises:72TypeError: If value is not a sequence or is a string.73"""74if isinstance(value, str) or not isinstance(value, Sequence):75raise TypeError("service_args must be a sequence")76self._service_args = list(value)777879