Service(executable, port, log_file, …) The abstract base class for all service objects.
class selenium.webdriver.common.service.Service(executable: str, port: int = 0, log_file: Union[int, IO[Any]] = -3, env: Optional[Mapping[Any, Any]] = None, start_error_message: Optional[str] = None, **kwargs)[source]

The abstract base class for all service objects. Services typically launch a child program in a new process as an interim process to communicate with a browser.

  • executable – install path of the executable.
  • port – Port for the service to run on, defaults to 0 where the operating system will decide.
  • log_file – (Optional) file descriptor (pos int) or file object with a valid file descriptor. subprocess.PIPE & subprocess.DEVNULL are also valid values.
  • env – (Optional) Mapping of environment variables for the new process, defaults to os.environ.
assert_process_still_running() → None[source]

Check if the underlying process is still running.

command_line_args() → List[str][source]

A List of program arguments (excluding the executable).

is_connectable() → bool[source]

Establishes a socket connection to determine if the service running on the port is accessible.

send_remote_shutdown_command() → None[source]

Dispatch an HTTP request to the shutdown endpoint for the service in an attempt to stop it.


Gets the url of the Service.

start() → None[source]

Starts the Service.

  • WebDriverException : Raised either when it can’t start the service or when it can’t connect to the service
stop() → None[source]

Stops the service.