Actually, I need to open pages with extension installed in any browser (not specifically chrome). So it can be firefox, or phantomjs(not sure if it is possible at all).
So, is there any way to run chrome/firefox/phantom via webdriverio with preinstalled extension , and if there is - how can I do it?
Thanks in advance!
Yes there is! You can have chromeOptions
property in your desiredCapability. This object has a property called extensions
that takes the base64 string of your crx
file. You will find more information https://sites.google.com/a/chromium.org/chromedriver/capabilities
yep, that works
var data = await fs.readFileSync('./ext.zip');
options.desiredCapabilities.chromeOptions.extensions = [data.toString('base64')];
Hello! Thanks for sharing your approach!
@d668 Maybe you had some similar problem while working on adding an extension to your tests??
I tried to add an extension, and after the running a test,
I got an error:
ERROR webdriver: Request failed due to unknown error: unknown error: cannot process extension #1 from unknown error: cannot read manifest
maxInstances: 5,
"goog:chromeOptions": {
extensions: [(function () {
try {
const webExt = fs.readFileSync('./extension.zip').toString('base64');
return webExt;
} catch (e) {
console.log(e, 'An error occurred while to parse extension zip file!');
}
})()],
args: ['--headless', '--disable-gpu']
},
@Madebyspeedster you need to pack extension. Open chrome://extensions and click Pack extension. It will generate .crx pack and .pem key. After that you can use .pem key to generate packs for you own. You can use this library for that https://github.com/Constellation/crxmake
Most helpful comment
yep, that works