2
votes

I am trying to containerize the automation tests to run in docker environment. When the build runs on the automation code, it creates an docker image and updates in DTR. I have a separate jenkins pipeline which runs the automation commands in the docker image and uploads the results in the workspace. All of this setup working in fine in non-docker environment (ie., on local mac terminal), but the same tests are failing in docker environment. I am trying to figure out a solution, but it doesn't seem to work.

I get below errors when running the protractor tests in docker environment

After # test/cucumber/stepDefinitions/hooks.ts:31 WebDriverError: invalid session id (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.125-linuxkit x86_64)

I built my docker image FROM circleci/node (https://hub.docker.com/r/circleci/node/) and this image has required libraries installed (node, npm,yarn, chrome and chrome drivers).

Before running the tests I made sure the protractor, cucumber and webdriver modules are installed.

Even then, i am trying to install chrome and chrome driver while building the image using apt-get package manager.

The docker env is on Debian GNU/Linux 9 \n \l The chrome driver version is 73.0.3683.75-1~deb9u1 Google Chrome version is 73.0.3683.103 I am running headless

Making sure the webdriver manager is updated before starting it
Web driver version 13.0

Running below:
webdriver-manager update --ignore_ssl --versions.chrome 73.0.3683.75-1~deb9u1
webdriver-manager start --detach
protractor test/cucumber/config/cucumberConfig.ts

I expect all the tests to run in docker environment in the same way it ran in mac terminal, but getting below errors:

  • And Log out application # test/cucumber/stepDefinitions/common-step-def.ts:64 ✖ After # test/cucumber/stepDefinitions/hooks.ts:31 WebDriverError: invalid session id (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.125-linuxkit x86_64) at Object.checkLegacyResponse (/node_modules/selenium-webdriver/lib/error.js:546:15) at parseHttpResponse (/node_modules/selenium-webdriver/lib/http.js:509:13) at doSend.then.response (/node_modules/selenium-webdriver/lib/http.js:441:30) at at process._tickCallback (internal/process/next_tick.js:189:7) From: Task: WebDriver.takeScreenshot() at thenableWebDriverProxy.schedule (/node_modules/selenium-webdriver/lib/webdriver.js:807:17) at thenableWebDriverProxy.takeScreenshot (/node_modules/selenium-webdriver/lib/webdriver.js:1085:17) at run (/node_modules/protractor/built/browser.js:59:33) at ProtractorBrowser.to.(anonymous function) [as takeScreenshot] (/node_modules/protractor/built/browser.js:67:16) at World. (/test/cucumber/stepDefinitions/hooks.ts:36:17)

Any thoughts?

2
WebDriverError: unknown error: session deleted because of page crash from tab crashed (Session info: headless chrome=73.0.3683.103) (Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Linux 4.9.125-linuxkit x86_64) - javageek

2 Answers

2
votes

I run into the same problem recently. It looks like browser instance can't start due to some reason. In my case adding --disable-dev-shm-usage to chrome-options solved the issue.

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-dev-shm-usage");
ChromeDriver driver = new ChromeDriver(options);

Why this helps:

By default, Docker runs a container with a /dev/shm shared memory space 64MB. This is typically too small for Chrome and will cause Chrome to crash when rendering large pages. To fix, run the container with docker run --shm-size=1gb to increase the size of /dev/shm. Since Chrome 65, this is no longer necessary. Instead, launch the browser with the --disable-dev-shm-usage flag:

~ Google troubleshooting guide

According to that, another idea would be to try using --shm-size=1gb when running the container if you really want to use /dev/shm.

1
votes

May be check the Chrome version compatible with the OS version you are using in the Docker. From the logs it seems the page is not even loaded or crashed on loading. Either it requires more memory to load the page or the chromes extensions might have been enabled.

try adding these options to config

chromeOptions: {
                args: [
                    'incognito',
                    'disable-extensions',
                    'disable-infobars',
                ]
            }