Skip to content

Commit

Permalink
[py] Force free ports for cdp in geckodriver
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Sep 28, 2021
1 parent 9e8c7b3 commit 68cd181
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions py/selenium/webdriver/firefox/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from typing import List

from selenium.webdriver.common import service
from selenium.webdriver.common import (service, utils)


class Service(service.Service):
Expand Down Expand Up @@ -48,9 +48,15 @@ def __init__(self, executable_path: str, port: int = 0, service_args: List[str]
service.Service.__init__(
self, executable_path, port=port, log_file=log_file, env=env)
self.service_args = service_args or []
# Set a port for CDP
self.service_args.append("--websocket-port")
self.service_args.append("%d" % utils.free_port())
# Set the webdriver port
self.service_args.append("--port")
self.service_args.append("%d" % self.port)

def command_line_args(self) -> List[str]:
return ["--port", "%d" % self.port] + self.service_args
return self.service_args

def send_remote_shutdown_command(self):
pass

0 comments on commit 68cd181

Please sign in to comment.