Curb
Curb

Reputation: 11

webdrivermanager java browser in docker wsl2 how to configure

I'm trying to setup webdrivermanager java with a chrome browser in a docker container. I have a docker daemon running on my local Windows 10 machine on WSL2. The docker daemon url should be tcp://127.0.0.1:2375.

I have version 5.1.0 of webdrivermanager.

Some sample code

WebDriverManager
        .chromedriver()
        .browserInDocker()
        .dockerDaemonUrl("tcp://127.0.0.1:2375")
        .create();

I always get the following warning: WARN io.github.bonigarcia.wdm.docker.DockerService - Docker is not available in your machine... local browsers are used instead

What is the correct setup for webdrivermanager in this case?

Upvotes: 1

Views: 914

Answers (2)

Curb
Curb

Reputation: 11

The following attempt was successful. Adding avoidDockerLocalFallback did the trick. The DockerService of WebdriverManager always tries to resolve the docker daemon locally by default but is unsuccessful in case of a docker daemon running on WSL2.

WebDriverManager
    .chromedriver()
    .browserInDocker()
    .avoidDockerLocalFallback()
    .dockerDaemonUrl("tcp://127.0.0.1:2375")
    .create();

Upvotes: 0

Boni García
Boni García

Reputation: 4858

For a local Docker engine, the method dockerDaemonUrl() should not be necessary.

Upvotes: 0

Related Questions