Skip to content

Unable to provide a custom URL for selenium standalone image #122

@shikhar08

Description

@shikhar08

Hi,

I was attempting to subclass testcontainers.selenium.BrowserWebDriverContainer and ran into an issue.

def __init__(self, capabilities, image=None):
        self.capabilities = capabilities
        if not image:
            self.image = get_image_name(capabilities)
        self.port_to_expose = 4444
        self.vnc_port_to_expose = 5900
        super(BrowserWebDriverContainer, self).__init__(image=self.image)
        self.with_exposed_ports(self.port_to_expose, self.vnc_port_to_expose)

This __init__ does not account for when a user specifies the input image . As shown above, there needs to be an else statement for image so that we don't hit a NameError because self.image does not get declared if the user provides a custom URL for the image.

I am using an image from my company's Docker registry as I cannot download outside images.

I'd like to submit a PR that can solve this.
The change I'd make is

def __init__(self, capabilities, image=None):
        self.capabilities = capabilities
        if  image is None:
            self.image = get_image_name(capabilities)
        else:
            self.image = image
        self.port_to_expose = 4444
        self.vnc_port_to_expose = 5900
        super(BrowserWebDriverContainer, self).__init__(image=self.image)
        self.with_exposed_ports(self.port_to_expose, self.vnc_port_to_expose)

For reference see testcontainers.redis.RedisContainer; in particular: super(RedisContainer, self).__init__(image) where a user-supplied image will be passed to the underlying class DockerContainer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions