Expose an api or a config to bypass csp headers for a page.
CDP api reference: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-setBypassCSP
Can this done using await client().send('Page.setBypassCSP', {enabled: true});?
yes, we should be able to do it as await client().Page.setBypassCSP({enabled:true})
Pinging to bring this back into scope
@marktamis as mentioned above this can be achieved by taiko's client api ... do you think having a separate api would add more value ?
I stand corrected, I confirm that we have it working as you described. I think you can mark this as closed!
`
const { openBrowser, goto, write, below, textBox, focus, click, client, evaluate, press, closeBrowser } = require('taiko');
(async () => {
try {
await openBrowser();
await goto("https://xxx.my.salesforce.com");
await write("[email protected]");
await focus(textBox(below("Password")));
await write("Password");
await click("Login");
await client().send('Page.setBypassCSP', {enabled: true});
await goto("https://xxx.lightning.force.com/lightning/page/home");
await evaluate(function(){var script= document.createElement('script'); script.type = 'text/javascript'; script.async = true; script.src = 'https://eu-cdn.xxx.com/users/xxxxx/test/xxx_yyy_https.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(script, s); window._scriptConfig = {smartLoad:true}; });
await click("HelpMe");
await focus(textBox({title:"Search..."}));
await write("Burlington");
await press("Enter");
....
} catch (error) {
console.error(error);
} finally {
await closeBrowser();
}
})();`
No CSP errors, and the script loads correctly
Most helpful comment
I stand corrected, I confirm that we have it working as you described. I think you can mark this as closed!
`
const { openBrowser, goto, write, below, textBox, focus, click, client, evaluate, press, closeBrowser } = require('taiko');
(async () => {
....
} catch (error) {
})();`
No CSP errors, and the script loads correctly