From: Antoine Musso Date: Thu, 12 Apr 2018 12:02:40 +0000 (+0200) Subject: Selenium: pass -no-sandbox to Chrome under Docker X-Git-Tag: 1.31.0-rc.0~90^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=4ff5652501b6cd1467072290b61241a559a48844 Selenium: pass -no-sandbox to Chrome under Docker When running webdriver.io in a Jessie Docker container, the sandboxing fails: Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted Detect whether we are in a Docker container by checking /.dockerenv and if present append --no-sandbox to Chrome options. Change-Id: Ie5c276d12553e4473c01b3407e0f7622e0a678e0 --- diff --git a/tests/selenium/wdio.conf.js b/tests/selenium/wdio.conf.js index 7b74328080..0b374c848a 100644 --- a/tests/selenium/wdio.conf.js +++ b/tests/selenium/wdio.conf.js @@ -1,6 +1,7 @@ 'use strict'; const password = 'vagrant', + fs = require( 'fs' ), path = require( 'path' ), username = 'Admin'; @@ -83,7 +84,12 @@ exports.config = { chromeOptions: { // Run headless when there is no DISPLAY // --headless: since Chrome 59 https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md - args: process.env.DISPLAY ? [] : [ '--headless' ] + args: ( + process.env.DISPLAY ? [] : [ '--headless' ] + ).concat( + // Disable Chrome sandbox when running in Docker + fs.existsSync( '/.dockerenv' ) ? [ '--no-sandbox' ] : [] + ) } } ], //