我为我的应用程序设置了CodeceptJS框架,测试运行顺利。但是现在我希望他们使用无头铬。尝试了官方网站上提到的一些东西,但对我不起作用。
我尝试使用进行测试npx codeceptjs run --verbose
。
我的codecept.conf.js文件如下所示:
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']
}
}
}
实际:Chrome已启动且测试开始运行。
预期:我希望它可以在无头的chrome上运行。
chromeOptions
需要包装desiredCapabilities
,您的配置应如下所示:
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']
}
}
}
我已windowSize
从中删除,args
因为它已经设置windowSize
并添加了no-sandbox
它,因为它建议用于测试自动化。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句