Skip to content

Commit 6dc9b8d

Browse files
committed
Expose port configuration for selenium.
1 parent 0a1b372 commit 6dc9b8d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

selenium/testcontainers/selenium/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ class BrowserWebDriverContainer(DockerContainer):
4545
You can easily change browser by passing :code:`DesiredCapabilities.FIREFOX` instead.
4646
"""
4747

48-
def __init__(self, capabilities: str, image: Optional[str] = None, **kwargs) -> None:
48+
def __init__(self, capabilities: str, image: Optional[str] = None, port: int = 4444,
49+
vnc_port: int = 5900, **kwargs) -> None:
4950
self.capabilities = capabilities
5051
self.image = image or get_image_name(capabilities)
51-
self.port_to_expose = 4444
52-
self.vnc_port_to_expose = 5900
52+
self.port = port
53+
self.vnc_port = vnc_port
5354
super(BrowserWebDriverContainer, self).__init__(image=self.image, **kwargs)
54-
self.with_exposed_ports(self.port_to_expose, self.vnc_port_to_expose)
55+
self.with_exposed_ports(self.port, self.vnc_port)
5556

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

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

0 commit comments

Comments
 (0)