Path: blob/trunk/py/selenium/webdriver/chrome/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.161718from collections.abc import Mapping, Sequence19from typing import Optional2021from selenium.types import SubprocessStdAlias22from selenium.webdriver.chromium import service232425class Service(service.ChromiumService):26"""A Service class that is responsible for the starting and stopping of27`chromedriver`.2829:param executable_path: install path of the chromedriver executable, defaults to `chromedriver`.30:param port: Port for the service to run on, defaults to 0 where the operating system will decide.31:param service_args: (Optional) Sequence of args to be passed to the subprocess when launching the executable.32:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.33:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.34"""3536def __init__(37self,38executable_path: Optional[str] = None,39port: int = 0,40service_args: Optional[Sequence[str]] = None,41log_output: Optional[SubprocessStdAlias] = None,42env: Optional[Mapping[str, str]] = None,43**kwargs,44) -> None:45self._service_args = service_args or []4647super().__init__(48executable_path=executable_path,49port=port,50service_args=service_args,51log_output=log_output,52env=env,53**kwargs,54)5556@property57def service_args(self) -> Sequence[str]:58return self._service_args5960@service_args.setter61def service_args(self, value: Sequence[str]):62if isinstance(value, str) or not isinstance(value, Sequence):63raise TypeError("service_args must be a sequence")64self._service_args = list(value)656667