angularjs - Protractor 添加请求 header

标签 angularjs google-chrome header protractor e2e-testing

我正在使用 Protractor 来测试需要自定义 header 的应用程序。 我在 Chrome 中使用这个“修改标题”扩展。如何在 Protractor 中设置它们?

最佳答案

由于 Webdriver 的限制,实际上不可能添加自定义 header 。 Protractor 和 Selenium 出现了一个问题,请引用这个帖子:https://github.com/angular/protractor/issues/740 :

Protractor (and webdriver, which it is built on top of) are intended to test your application like a user interacting with your page, so the meaning of browser.get is something like 'do what would happen if a user opened up a new tab and entered this URL'. So, there's no way to interact with under the hood things like setting headers, except for in the way that it would normally get done for your user.

希望有帮助。

关于angularjs - Protractor 添加请求 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40628350/

相关文章:

谷歌浏览器扩展的 javascript 屏幕截图

javascript - 如何使用 Javascript 保存静态变量,即使在刷新页面时也是如此

javascript - 在 AngularJS 中从数组中删除元素时出错

javascript - 具有 Modernizr 值的 Angular 表达式?

jquery - 有没有办法强制显示 ag-grid 行,即使它不符合快速过滤条件?

javascript - 以编程方式检测 Chrome 中的混合内容阻止

php - Codeigniter 和 AngularJS 错误 : pagination does not work when the application is not in the root directory

html - CSS3 选择框单独正确对齐 Google Chrome

javascript - 当用链接标签包裹时,Logo 不会在 React 中显示

使用结构接口(interface)和附加 C 文件在 main 中调用 C 函数