karma-chrome-launcher
karma-chrome-launcher copied to clipboard
Ubuntu: Cannot start ChromeHeadless
I'm having some trouble getting ChromeHeadless to start. The error message doesn't give much information:
22 03 2018 18:05:33.296:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9877/
22 03 2018 18:05:33.296:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
22 03 2018 18:05:33.320:INFO [launcher]: Starting browser ChromeHeadless
22 03 2018 18:05:33.404:ERROR [launcher]: Cannot start ChromeHeadless
22 03 2018 18:05:33.409:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
22 03 2018 18:05:33.631:ERROR [launcher]: Cannot start ChromeHeadless
22 03 2018 18:05:33.634:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
22 03 2018 18:05:34.008:ERROR [launcher]: Cannot start ChromeHeadless
22 03 2018 18:05:34.009:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.
Here is my karma config:
process.env.CHROME_BIN = require('puppeteer').executablePath() //for using ChromeHeadless
module.exports = function(config) {
config.set({
plugins: [
require("karma-jasmine"),
require("karma-typescript"),
require("karma-chrome-launcher"),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter')
],
frameworks: ["jasmine", "karma-typescript"],
basePath: './',
files: [
'node_modules/es6-shim/es6-shim.js',
'node_modules/babel-polyfill/dist/polyfill.js',
'node_modules/reflect-metadata/Reflect.js',
// zone.js
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
'node_modules/resumablejs/resumable.js',
'node_modules/hls.js/dist/hls.min.js',
'src/assets/third-party/three.js',
'src/assets/third-party/obj-loader.js',
'src/assets/third-party/OrbitControls.js',
'src/assets/third-party/THREEx.Fullscreen.js',
{ pattern: "src/app/**/*.html" },
{ pattern: "src/**/*.ts" }
],
preprocessors: {
"src/**/*.ts": ["karma-typescript"],
"!node_modules": ["karma-typescript"]
},
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
reporters: ['progress', 'kjhtml', 'coverage-istanbul'],
browsers: ["ChromeHeadless"],
coverageIstanbulReporter: {
reports: ['html', 'text-summary'],
dir: 'coverage',
skipFilesWithNoCoverage: false
},
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
transforms: [
require("karma-typescript-angular2-transform"),
require("karma-typescript-es6-transform")({ presets: ['es2015'] })
]
},
compilerOptions: {
emitDecoratorMetadata: true,
experimentalDecorators: true,
module: "commonjs"
},
coverageOptions: {
exclude: [
/\.(d|spec|test)\.ts$/i,
/main.ts$/i,
/polyfills.ts$/i,
/app.component.ts$/i,
/app.routes.ts$/i,
/module.ts$/i,
/Service.ts$/i
],
},
tsconfig: "./tsconfig.json"
}
});
};
Any suggestions?
I'm on Ubuntu 16.04 and Chrome 62.
I've been having similar issues on Windows 7. This fixed it for me: https://github.com/Codeception/CodeceptJS/issues/561#issuecomment-373666779
@shaunOclcl can you please elaborate a bit further? Where in the karma.config did you placed those two options?
Thanks!
@raveneyex I've defined a custom launcher based on ChromiumHeadless. The custom launcher allows flags to be passed to the Chrome (or Chromium) instance.
process.env.CHROMIUM_BIN = require('puppeteer').executablePath();
module.exports = function(config) {
config.set({
....*other karma config settings*....
browsers: ['HeadlessChromium'],
customLaunchers: {
HeadlessChromium: {
base: 'ChromiumHeadless',
flags: [
'--no-sandbox',
'--remote-debugging-port=9222',
'--enable-logging',
'--user-data-dir=./karma-chrome',
'--v=1',
'--disable-background-timer-throttling',
'--disable-renderer-backgrounding',
'--proxy-bypass-list=*',
'--proxy-server=\'direct://\''
]
}
}
});
};
@shaunOclcl thank you for the reply! I'm going to check how that stuff works out for me.
Peace!
To make this run successfully, Please follow the procedure
Method 1: Most of the issues will be fixed and we can run ChromeHeadless if we download chromium version(debian) in wsl and install
step 1: install necessary packages
sudo apt-get update
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4
step 2: install chromium
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
If still problem persists, please follow the method 2
method 2: To run a basic Selenium UI test on any environment we need a browser and a driver to control the browser. So we've to make Windows’s Chrome browser and the chromedriver accessible from WSL.
step 1: Link Chrome browser on Windows
sudo ln -sf '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe' /usr/bin/google-chrome
step 2: Link chromedriver on Windows
sudo ln -s /mnt/c/Users/username/node_modules/chromedriver/lib/chromedriver/chromedriver.exe /usr/bin/chromedriver
step 3: Change CHROME_BIN (environmental variable's default value)
export CHROME_BIN='/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
If still problem persists, please follow the method 3
Method 3: This will help run puppetteer on Ubuntu, so let's install necessary packages:
sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
browsers: ['Chrome'],
browsers: ['Chrome'],
does using Chrome instead of ChromeHeadless helped you?, It's much slower, isn't it?
To make this run successfully, Please follow the procedure
Method 1: Most of the issues will be fixed and we can run ChromeHeadless if we download chromium version(debian) in wsl and install
step 1: install necessary packages
sudo apt-get update
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4
step 2: install chromium
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
If still problem persists, please follow the method 2
method 2: To run a basic Selenium UI test on any environment we need a browser and a driver to control the browser. So we've to make Windows’s Chrome browser and the chromedriver accessible from WSL.
step 1: Link Chrome browser on Windows
sudo ln -sf '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe' /usr/bin/google-chrome
step 2: Link chromedriver on Windows
sudo ln -s /mnt/c/Users/username/node_modules/chromedriver/lib/chromedriver/chromedriver.exe /usr/bin/chromedriver
step 3: Change CHROME_BIN (environmental variable's default value)
export CHROME_BIN='/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
If still problem persists, please follow the method 3
Method 3: This will help run puppetteer on Ubuntu, so let's install necessary packages:
sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
for me it says, [INFO] [0518/130005.862638:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
I've done everything also provided different flags from issues but still couldn't launch chrome headless on Ubuntu 22.04