Skip to content

Fix silent failure in BrowserWebDriverContainer#getSeleniumAddress - #11958

Open
dev-xong wants to merge 1 commit into
testcontainers:mainfrom
dev-xong:fix/selenium-selenium-address-error-handling
Open

Fix silent failure in BrowserWebDriverContainer#getSeleniumAddress#11958
dev-xong wants to merge 1 commit into
testcontainers:mainfrom
dev-xong:fix/selenium-selenium-address-error-handling

Conversation

@dev-xong

@dev-xong dev-xong commented Aug 4, 2026

Copy link
Copy Markdown

Fix silent failure in BrowserWebDriverContainer#getSeleniumAddress

What does this PR do?

Fixed the // TODO left in BrowserWebDriverContainer#getSeleniumAddress().

The existing code caught MalformedURLException and only called e.printStackTrace(), returning null:

public URL getSeleniumAddress() {
    try {
        return new URL("http", getHost(), getMappedPort(SELENIUM_PORT), "/wd/hub");
    } catch (MalformedURLException e) {
        e.printStackTrace(); // TODO
        return null;
    }
}

This PR wraps the exception in ContainerLaunchException and throws it immediately, matching the existing error-handling pattern already used elsewhere in this class (e.g. for temp directory creation failures):

public URL getSeleniumAddress() {
    try {
        return new URL("http", getHost(), getMappedPort(SELENIUM_PORT), "/wd/hub");
    } catch (MalformedURLException e) {
        throw new ContainerLaunchException("Could not construct Selenium address", e);
    }
}

The identical duplicated code in org.testcontainers.selenium.BrowserWebDriverContainer is fixed the same way.

@dev-xong
dev-xong requested a review from a team as a code owner August 4, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant