Path: blob/trunk/py/selenium/webdriver/ie/service.py
1864 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 Sequence18from typing import Optional1920from selenium.types import SubprocessStdAlias21from selenium.webdriver.common import service222324class Service(service.Service):25"""Object that manages the starting and stopping of the IEDriver."""2627def __init__(28self,29executable_path: Optional[str] = None,30port: int = 0,31host: Optional[str] = None,32service_args: Optional[Sequence[str]] = None,33log_level: Optional[str] = None,34log_output: Optional[SubprocessStdAlias] = None,35driver_path_env_key: Optional[str] = None,36**kwargs,37) -> None:38"""Creates a new instance of the Service.3940:Args:41- executable_path : Path to the IEDriver42- port : Port the service is running on43- host : (Optional) IP address the service port is bound44- service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.45- log_level : (Optional) Level of logging of service, may be "FATAL", "ERROR", "WARN", "INFO", "DEBUG",46"TRACE". Default is "FATAL".47- log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.48Default is "stdout".49- driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.50"""51self._service_args = list(service_args or [])52driver_path_env_key = driver_path_env_key or "SE_IEDRIVER"5354if host:55self._service_args.append(f"--host={host}")56if log_level:57self._service_args.append(f"--log-level={log_level}")5859super().__init__(60executable_path=executable_path,61port=port,62log_output=log_output,63driver_path_env_key=driver_path_env_key,64**kwargs,65)6667def command_line_args(self) -> list[str]:68return [f"--port={self.port}"] + self._service_args6970@property71def service_args(self) -> Sequence[str]:72return self._service_args7374@service_args.setter75def service_args(self, value: Sequence[str]):76if isinstance(value, str) or not isinstance(value, Sequence):77raise TypeError("service_args must be a sequence")78self._service_args = list(value)798081