I have CodeceptJS framework setup for my application & tests are runnning smooth. But now I want them to run headless chrome. Tried few things mentioned on official site ,but its not working for me.
I try to run my tests with npx codeceptjs run --verbose
.
My codecept.conf.js file looks like this:
exports.config = {
tests: './tests/features/**/*_test.js',
output: './tests/output',
helpers: {
WebDriver: {
smartwait: 10000,
waitForTimeout: 10000,
url: 'https://affinity.sourcefuse.com',
browser: 'chrome',
windowSize: 'maximize',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800,600"]
}
}
},
include: {
I: './steps_file.js',
createDatasetPage: 'tests/pages/createDataset.js',
},
bootstrap: null,
mocha: {},
name: 'dashboard',
plugins: {
"allure": {
"enabled": true
},
wdio: {
enabled: true,
services: ['selenium-standalone']
}
}
}
Actual: Chrome is launched & test starts to run.
Expected: I want it to be running on headless chrome.
chromeOptions
need to be wrapped in desiredCapabilities
, your config should look like this:
exports.config = {
tests: './tests/features/**/*_test.js',
output: './tests/output',
helpers: {
WebDriver: {
smartwait: 10000,
waitForTimeout: 10000,
url: 'https://affinity.sourcefuse.com',
browser: 'chrome',
windowSize: 'maximize',
desiredCapabilities: {
chromeOptions: {
args: ["--headless", "--disable-gpu", "--no-sandbox"]
}
}
}
},
include: {
I: './steps_file.js',
createDatasetPage: 'tests/pages/createDataset.js',
},
bootstrap: null,
mocha: {},
name: 'dashboard',
plugins: {
"allure": {
"enabled": true
},
wdio: {
enabled: true,
services: ['selenium-standalone']
}
}
}
I removed windowSize
from args
as it is already set with windowSize
and added no-sandbox
instead, as it is recommended for test automation.