Wednesday, 26 April 2017

Webdriver.IO setup for Chrome extension ModHeader

I am using Webdriver.io in node.js without wdio.

const Base64File = require('js-base64-file');
const getBase64 = file => {
  const reader = new Base64File;
  return reader.loadSync('./app/lib/',file);
};
const webdriverio = require('webdriverio');
const options = { desiredCapabilities: { browserName: 'chrome', chromeOptions: {
  extensions: [getBase64('modheader_2_1_2.crx')]
} } };
const driver = webdriverio.remote(options);
const myInit => async () => {
 const client = driver.init();
 await client.url('myurl');
 await client.execute(() =>
  localStorage.setItem('profiles', JSON.stringify([{
    title: 'Selenium', hideComment: true, appendMode: '',
    headers: [
      {enabled: true, name: 'MyHeader', value: 'true', comment: ''}
    ],
    respHeaders: [],
    filters: []
  }])));
};
myInit();

Extension shows in chrome but it does not pick up the setting for mod header. Is there a different way that I should be using to setup the modheader extension using Webdriver.io?

I also tried this code

await client.localStorage('POST', {key: 'profiles', value: JSON.stringify([{
    title: 'Selenium', hideComment: true, appendMode: '',
    headers: [
      {enabled: true, name: 'MyHeader', value: 'true', comment: ''}
    ],
    respHeaders: [],
    filters: []
  }])});



via Ragnar

No comments:

Post a Comment