Home > other >  webdrivermanager java browser in docker wsl2 how to configure
webdrivermanager java browser in docker wsl2 how to configure

Time:03-29

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?

CodePudding user response:

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

CodePudding user response:

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();
  • Related