Search code examples
selenium-webdrivergoogle-cloud-platformdocker-volumewebdriver-managerwebdrivermanager-java

.dockerVolume() of WebdriverManager causes (Connection reset) error on Linux-VM


I run my tests in docker by using webdrivermanager. I need to upload some files into the running docker. So, I will be able to use those files in my tests. I used .dockerVolume() like:

WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker().enableVnc().enableRecording().dockerVolumes("/home/GitHub/e2e-test:/home/selenium");
driver = wdm.create();

It is working well on my local well. But I need to run the tests on a GCP VM instance: Debian GNU/Linux 11

It was working well on the VM without using .dockerVolume() like:

WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker().enableVnc().enableRecording();
driver = wdm.create();

So, briefly, It is working on my local with and without .dockerVolume(). However, it is not working on the VM with .dockerVolume().

I keep getting the error below:

io.github.bonigarcia.wdm.config.WebDriverManagerException: There was an error creating WebDriver object for Chrome at io.github.bonigarcia.wdm.WebDriverManager.instantiateDriver(WebDriverManager.java:1775) at io.github.bonigarcia.wdm.WebDriverManager.create(WebDriverManager.java:425) at e2e.toolset.WebDriverTool.setDriver(WebDriverTool.java:13)

How can I solve this issue?

Logs in details:

[INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running e2e.TestRunner

@regression Scenario: DataScout Login # src/test/resources/features/DataScout.feature:4 2023-02-16 11:49:29 [main] DEBUG i.g.b.wdm.cache.ResolutionCache.checkValidity(156) - Removing resolution chrome-container-latest=106.0 from cache (expired on Thu Oct 20 09:53:59 UTC 2022) 2023-02-16 11:49:29 [main] DEBUG i.g.b.wdm.docker.DockerHubService.listTags(60) - Getting browser image list from Docker Hub 2023-02-16 11:49:29 [main] TRACE i.g.b.wdm.docker.DockerHubService.listTags(73) - Sending request to https://hub.docker.com/v2/repositories/selenoid/vnc/tags?page=1&page_size=1024 2023-02-16 11:49:30 [main] TRACE i.g.b.wdm.docker.DockerHubService.listTags(73) - Sending request to https://hub.docker.com/v2/repositories/selenoid/vnc/tags?page=2&page_size=1024 2023-02-16 11:49:30 [main] TRACE i.g.b.wdm.docker.DockerHubService.listTags(73) - Sending request to https://hub.docker.com/v2/repositories/selenoid/vnc/tags?page=3&page_size=1024 2023-02-16 11:49:31 [main] DEBUG i.g.b.wdm.docker.DockerService.getImageVersionFromDockerHub(471) - The latest version of Chrome in Docker Hub is 110.0 2023-02-16 11:49:31 [main] TRACE i.g.b.wdm.docker.DockerService.getDockerImage(517) - Docker image: selenoid/vnc:chrome_110.0 2023-02-16 11:49:31 [main] INFO i.g.b.wdm.docker.DockerService.pullImageIfNecessary(330) - Pulling Docker image selenoid/vnc:chrome_110.0 (this might take some time, but only the first time) 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.pullImageIfNecessary(336) - Docker image selenoid/vnc:chrome_110.0 pulled 2023-02-16 11:49:32 [main] DEBUG i.g.b.wdm.cache.ResolutionCache.putValueInResolutionCacheIfEmpty(119)

  • Storing resolution chrome-container-latest=110.0 in cache (valid until 12:49:32 16/02/2023 UTC) 2023-02-16 11:49:32 [main] TRACE i.g.bonigarcia.wdm.config.Config.getDockerMemSizeBytes(1142) - The memory size 256m is equivalent to 268435456 bytes) 2023-02-16 11:49:32 [main] TRACE i.g.bonigarcia.wdm.config.Config.getDockerMemSizeBytes(1142) - The memory size 128m is equivalent to 134217728 bytes) 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startBrowserContainer(638)
  • Using custom volumes: [/home/furkan_yavuz/e2e-tests/src/test/resources/testData:/home/selenium] 2023-02-16 11:49:32 [main] INFO i.g.b.wdm.docker.DockerService.startContainer(177) - Starting Docker container selenoid/vnc:chrome_110.0 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(190) - Adding sysadmin capability 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(196) - Using shm size: 268435456 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(202) - Using network: bridge 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(207) - Using exposed ports: [4444, 5900] 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(216) - Using binds: [/home/furkan_yavuz/e2e-tests/src/test/resources/testData:/home/selenium:rw] 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(222) - Using mounts: [Mount(type=TMPFS, source=null, target=/tmp, readOnly=null, bindOptions=null, volumeOptions=null, tmpfsOptions=TmpfsOptions(sizeBytes=134217728, mode=null))] 2023-02-16 11:49:32 [main] TRACE i.g.b.wdm.docker.DockerService.startContainer(228) - Using envs: [TZ=Etc/UTC, LANG=EN, SCREEN_RESOLUTION=1280x1080x24, ENABLE_VNC=true, DRIVER_ARGS=--whitelisted-ips= --allowed-origins=*] 2023-02-16 11:49:33 [main] TRACE i.g.b.wdm.docker.DockerService.getBindPort(294)
  • Port list {5900/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@217bf99e, 4444/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@6807a356} -- Exposed port 4444/tcp = [0.0.0.0:49197, :::49197] 2023-02-16 11:49:33 [main] TRACE i.g.b.wdm.docker.DockerService.startBrowserContainer(693)
  • Browser remote URL http://localhost:49197/ 2023-02-16 11:49:33 [main] TRACE i.g.b.wdm.docker.DockerService.getBindPort(294) - Port list {5900/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@d675f9f, 4444/tcp=[Lcom.github.dockerjava.api.model.Ports$Binding;@58af5076} -- Exposed port 5900/tcp = [0.0.0.0:49196, :::49196] 2023-02-16 11:49:33 [main] DEBUG i.g.b.wdm.docker.DockerService.startBrowserContainer(700)
  • VNC server URL: vnc://localhost:49196/ 2023-02-16 11:49:33 [main] TRACE i.g.bonigarcia.wdm.WebDriverManager.createDockerWebDriver(1893)
  • The Selenium Serverl URL is http://localhost:49197/ 2023-02-16 11:49:33 [main] DEBUG i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(77) - Creating WebDriver object for chrome at http://localhost:49197/ with Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}} 2023-02-16 11:49:34 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(92) - SocketException creating WebDriver object (Connection reset) 2023-02-16 11:49:35 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(86) - Requesting http://localhost:49197/ (the response code is 404) Feb 16, 2023 11:49:35 AM org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer createTracer INFO: Using OpenTelemetry for tracing 2023-02-16 11:49:36 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(92) - SessionNotCreatedException creating WebDriver object (Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Host info: host: 'selenium-tests', ip: '10.156.0.4' Build info: version: '4.6.0', revision: '79f1c02ae20' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-18-cloud-amd64', java.version: '17.0.6' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}}] Capabilities {}) 2023-02-16 11:49:37 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(86) - Requesting http://localhost:49197/ (the response code is 404) 2023-02-16 11:49:37 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(92) - SessionNotCreatedException creating WebDriver object (Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Host info: host: 'selenium-tests', ip: '10.156.0.4' Build info: version: '4.6.0', revision: '79f1c02ae20' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-18-cloud-amd64', java.version: '17.0.6' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}}] Capabilities {}) 2023-02-16 11:49:38 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(86) - Requesting http://localhost:49197/ (the response code is 404) 2023-02-16 11:49:38 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(92) - SessionNotCreatedException creating WebDriver object (Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Host info: host: 'selenium-tests', ip: '10.156.0.4' Build info: version: '4.6.0', revision: '79f1c02ae20' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-18-cloud-amd64', java.version: '17.0.6' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}}] Capabilities {}) 2023-02-16 11:49:39 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(86) - Requesting http://localhost:49197/ (the response code is 404) 2023-02-16 11:49:39 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(92) - SessionNotCreatedException creating WebDriver object (Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Host info: host: 'selenium-tests', ip: '10.156.0.4' Build info: version: '4.6.0', revision: '79f1c02ae20' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-18-cloud-amd64', java.version: '17.0.6' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}}] Capabilities {}) 2023-02-16 11:49:40 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(86) - Requesting http://localhost:49197/ (the response code is 404) 2023-02-16 11:49:41 [main] TRACE i.g.b.wdm.webdriver.WebDriverCreator.createRemoteWebDriver(92) - SessionNotCreatedException creating WebDriver object (Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Host info: host: 'selenium-tests', ip: '10.156.0.4' Build info: version: '4.6.0', revision: '79f1c02ae20' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-18-cloud-amd64', java.version: '17.0.6' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-gpu], extensions: []}}}]

Related Github issue link: https://github.com/bonigarcia/webdrivermanager/issues/996


Solution

  • I could not find the reason for this issue. But I have a solution to overcome.

    I read the container ID and used command line executions to copy files to the newly created container.

        String contaionerID = wdm.getDockerBrowserContainerId().toLowerCase().substring(0, 12); // get chrome container ID
        String commandForCopyTheCSV = "docker cp {file_directory} " + contaionerID + ":/home/selenium";
        Runtime.getRuntime().exec(commandForCopyTheCSV).waitFor(); // copy the file