我将--use-fake-device-for-media-stream
和--use-fake-ui-for-media-stream
添加到nightwatch.conf.js
中,它起作用了.
这允许测试期间在后台获得麦克风许可.
这是修改后的nightwatch.conf.js
.
module.exports = {
src_folders: ["tests"], // replace with your test folder
webdriver: {
start_process: true,
port: 4444,
server_path: require('chromedriver').path,
cli_args: []
},
test_settings: {
default: {
launch_url: 'https://nightwatchjs.org',
desiredCapabilities : {
browserName : 'chrome',
'goog:chromeOptions' : {
w3c: true,
args: [
...
'--use-fake-device-for-media-stream',
'--use-fake-ui-for-media-stream'
...
]
}
}
}
}
};