So our application works in production with a CORS enabled.
I have a project that isn't CORS enabled locally. Is there a way to disable web security for protractor? Is there a way for me to add arguments to the selenium instance ?
We're looking for a configuration based solution. Our local development machines are pretty locked down on what we can install. So is this possible?
What i have tried is setting chrome options: https://github.com/angular/protractor/issues/175
But that appears to only be used for chrome extensions.
How do I disable CORS in Windows 10 chrome? Right click on desktop, add new shortcut. Add the target as "[PATH_TO_CHROME]\chrome.exe" –disable-web-security –disable-gpu –user-data-dir=~/chromeTemp. Click OK.
You can disable CORS checks in your browser completely. To disable CORS checks in Google Chrome, you need to close the browser and start it with the --disable-web-security and --user-data-dir flags. By doing that, Google Chrome will not send CORS preflight requests and will not validate CORS headers.
Right-click the Google Chrome desktop icon (or Start Menu link). Select Properties. At the end of the existing information in the Target field, add: " --allow-running-insecure-content" (There is a space before the first dash.) Click OK.
There is also args
inside chromeOptions
, where you can provide the --disable-web-security
and --user-data-dir
arguments.
If you are running the tests locally, make sure to supply a profile location for the --user-data-dir
, otherwise Chrome will use the default profile and load the page in the current browser session (running with all of your extensions and settings).
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['--disable-web-security', '--user-data-dir=~/.e2e-chrome-profile']
}
},
@alecxe's solution wasn't working for me. I eventually came up with the following after some cli trial and error; I'm sharing my solution here (it took some hair pulling to figure it out) in case there are other lost souls out there having the same problem:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--disable-web-security', '--user-data-dir']
}
}
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With