webdriverio / webdriverio

Next-gen browser and mobile automation test framework for Node.js
http://webdriver.io
MIT License
9.08k stars 2.51k forks source link

Cannot set Chrome extension using localStorage #2023

Closed MeetMartin closed 7 years ago

MeetMartin commented 7 years ago

The problem

I am loading chrome extension modHeader successfully as base64 in node.js. I am not using wdio.

to setMod header I found online that you need to execute this:

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

but the extension does not seem to pick that up. No error is thrown.

I also tried using localStorage directly from Webdriver.io

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

Is there a different method in Webdriver.io that I should be using?

christian-bromann commented 7 years ago

Is there a different method in Webdriver.io that I should be using?

@MartinGentleman no. These are correct. However it seems that chromedriver can't set local storage for some reasons. I don't think this is a bug in WebdriverIO but more one in the Chromedriver project.