"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/py/selenium/webdriver/ie/service.py" (17 Feb 2023, 2433 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "service.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 4.7.0_vs_4.8.0.

    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 import typing
   18 from typing import List
   19 
   20 from selenium.webdriver.common import service
   21 
   22 DEFAULT_EXECUTABLE_PATH = "IEDriverServer.exe"
   23 
   24 
   25 class Service(service.Service):
   26     """Object that manages the starting and stopping of the IEDriver."""
   27 
   28     def __init__(
   29         self,
   30         executable_path: str = DEFAULT_EXECUTABLE_PATH,
   31         port: int = 0,
   32         host: typing.Optional[str] = None,
   33         log_level: typing.Optional[str] = None,
   34         log_file: typing.Optional[str] = None,
   35     ) -> None:
   36         """Creates a new instance of the Service.
   37 
   38         :Args:
   39          - executable_path : Path to the IEDriver
   40          - port : Port the service is running on
   41          - host : IP address the service port is bound
   42          - log_level : Level of logging of service, may be "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE".
   43            Default is "FATAL".
   44          - log_file : Target of logging of service, may be "stdout", "stderr" or file path.
   45            Default is "stdout".
   46         """
   47         self.service_args = []
   48         if host:
   49             self.service_args.append(f"--host={host}")
   50         if log_level:
   51             self.service_args.append(f"--log-level={log_level}")
   52         if log_file:
   53             self.service_args.append(f"--log-file={log_file}")
   54 
   55         super().__init__(
   56             executable_path,
   57             port=port,
   58             start_error_message="Please download from https://www.selenium.dev/downloads/ and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver",
   59         )
   60 
   61     def command_line_args(self) -> List[str]:
   62         return [f"--port={self.port}"] + self.service_args