service.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. """Object that manages the starting and stopping of the
  20. GeckoDriver."""
  21. def __init__(self, executable_path, port=0, service_args=None,
  22. log_path="geckodriver.log", env=None):
  23. """Creates a new instance of the GeckoDriver remote service proxy.
  24. GeckoDriver provides a HTTP interface speaking the W3C WebDriver
  25. protocol to Marionette.
  26. :param executable_path: Path to the GeckoDriver binary.
  27. :param port: Run the remote service on a specified port.
  28. Defaults to 0, which binds to a random open port of the
  29. system's choosing.
  30. :param service_args: Optional list of arguments to pass to the
  31. GeckoDriver binary.
  32. :param log_path: Optional path for the GeckoDriver to log to.
  33. Defaults to _geckodriver.log_ in the current working directory.
  34. :param env: Optional dictionary of output variables to expose
  35. in the services' environment.
  36. """
  37. log_file = open(log_path, "a+") if log_path is not None and log_path != "" else None
  38. service.Service.__init__(
  39. self, executable_path, port=port, log_file=log_file, env=env)
  40. self.service_args = service_args or []
  41. def command_line_args(self):
  42. return ["--port", "%d" % self.port]
  43. def send_remote_shutdown_command(self):
  44. pass