service.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. from selenium.webdriver.common import service
  18. class Service(service.Service):
  19. """
  20. Object that manages the starting and stopping of the IEDriver
  21. """
  22. def __init__(self, executable_path, port=0, host=None, log_level=None, log_file=None):
  23. """
  24. Creates a new instance of the Service
  25. :Args:
  26. - executable_path : Path to the IEDriver
  27. - port : Port the service is running on
  28. - host : IP address the service port is bound
  29. - log_level : Level of logging of service, may be "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE".
  30. Default is "FATAL".
  31. - log_file : Target of logging of service, may be "stdout", "stderr" or file path.
  32. Default is "stdout"."""
  33. self.service_args = []
  34. if host is not None:
  35. self.service_args.append("--host=%s" % host)
  36. if log_level is not None:
  37. self.service_args.append("--log-level=%s" % log_level)
  38. if log_file is not None:
  39. self.service_args.append("--log-file=%s" % log_file)
  40. service.Service.__init__(self, executable_path, port=port,
  41. start_error_message="Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver")
  42. def command_line_args(self):
  43. return ["--port=%d" % self.port] + self.service_args