量角器 - 启动chrome以禁用cors的网络安全 [英] protractor - launch chrome with to disable web security for cors

查看:312
本文介绍了量角器 - 启动chrome以禁用cors的网络安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个不是本地启用CORS的项目。有没有办法来禁用量角器的网络安全?有没有办法让我向selenium实例添加参数?



我们正在寻找基于配置的解决方案。我们的本地开发机器锁定在我们可以安装的东西上。这可能吗?



我试过的是设置chrome选项: https://github.com/angular/protractor/issues/175



但是这似乎只用于Chrome扩展。

解决方案

还有 args chromeOptions ,您可以在其中提供 - disable-web-security - user-data-dir 参数。



如果您在本地运行测试,确保 su为 - user-data-dir 提供配置文件位置,否则Chrome将使用默认配置文件并在当前浏览器会话中加载页面所有的扩展和设置)。

 功能:{
'browserName':'chrome',
'chromeOptions':{
'args':['--disable-web-security','--user-data-dir =〜/ .e2e-chrome-profile']
}
},


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.

解决方案

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']
  }
},

这篇关于量角器 - 启动chrome以禁用cors的网络安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆