protractor - 启动 chrome 以禁用 cors 的网络安全
所以我们的应用程序在启用 CORS 的情况下在生产环境中工作.
So our application works in production with a CORS enabled.
我有一个未在本地启用 CORS 的项目.有没有办法禁用量角器的网络安全?有没有办法给 selenium 实例添加参数?
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?
我尝试的是设置 chrome 选项:https://github.com/angular/protractor/issues/175
What i have tried is setting chrome options: https://github.com/angular/protractor/issues/175
但这似乎只用于 chrome 扩展.
But that appears to only be used for chrome extensions.
推荐答案
还有args
在 chromeOptions
中,您可以在其中提供 --disable-web-security
和 --user-data-dir
参数.
There is also args
inside chromeOptions
, where you can provide the --disable-web-security
and --user-data-dir
arguments.
如果您在本地运行测试,请确保提供配置文件位置 用于 --user-data-dir
,否则 Chrome 将使用默认配置文件并在当前浏览器会话中加载页面(与所有扩展程序和设置一起运行).
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']
}
},
相关文章