Skip to content

Commit

Permalink
Expose port configuration for selenium.
Browse files Browse the repository at this point in the history
  • Loading branch information
tillahoffmann committed Feb 18, 2023
1 parent 0a1b372 commit 6dc9b8d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions selenium/testcontainers/selenium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ class BrowserWebDriverContainer(DockerContainer):
You can easily change browser by passing :code:`DesiredCapabilities.FIREFOX` instead.
"""

def __init__(self, capabilities: str, image: Optional[str] = None, **kwargs) -> None:
def __init__(self, capabilities: str, image: Optional[str] = None, port: int = 4444,
vnc_port: int = 5900, **kwargs) -> None:
self.capabilities = capabilities
self.image = image or get_image_name(capabilities)
self.port_to_expose = 4444
self.vnc_port_to_expose = 5900
self.port = port
self.vnc_port = vnc_port
super(BrowserWebDriverContainer, self).__init__(image=self.image, **kwargs)
self.with_exposed_ports(self.port_to_expose, self.vnc_port_to_expose)
self.with_exposed_ports(self.port, self.vnc_port)

def _configure(self) -> None:
self.with_env("no_proxy", "localhost")
Expand All @@ -68,5 +69,5 @@ def get_driver(self) -> webdriver.Remote:

def get_connection_url(self) -> str:
ip = self.get_container_host_ip()
port = self.get_exposed_port(self.port_to_expose)
port = self.get_exposed_port(self.port)
return f'http://{ip}:{port}/wd/hub'

0 comments on commit 6dc9b8d

Please sign in to comment.