protractor - launch chrome with to disable web security for cors(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']
}
},
这篇关于protractor - 启动 chrome 以禁用 cors 的网络安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:protractor - 启动 chrome 以禁用 cors 的网络安全


基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01