I need to add custom headers to all requests in order to access the web app which is normally hidden behind corporate proxy and vpn and be able to run E2E tests. As an automation tool we user WebdriverIO. So far I tried to set up custom header in wdio.conf.js file following official wdio documentation (https://webdriver.io/docs/options/) and added headers option inside capabilities in my config file. Unfortunately, this is not working and I still can't connect to our web app. Has anyone tried to add custom headers in wdio.config.js file and run E2E tests? Contents of my wdio.config.js file are following:
exports.config = {
runner: 'local',
specs: [
'./src/specs/**/login.spec.ts',
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
maxInstances: 10,
capabilities: [
{
maxInstances: 5,
browserName: 'chrome',
acceptInsecureCerts: true,
headers: {
'REQUIRED-HEADER-KEY': 'HEADER-VALUE'
},
'goog:chromeOptions': {
'excludeSwitches': [
'enable-automation'
],
prefs: {
'profile.managed_default_content_settings.notifications': 1,
'plugins.always_open_pdf_externally': true,
'download': {
'prompt_for_download': false,
'default_directory': process.cwd() + '/tmp'
}
},
args: [
'--disable-gpu',
'--window-size=1920,1080',
'--no-sandbox',
'--disable-dev-shm-usage',
'--start-maximized',
],
},
},
],
}
There's no way doing this at this time, see webdriverio/issues/6361
But you can do it with modheader_selenium:
npm install chrome-modheader