【问题标题】:Protractor Behind a corporate proxy (angular-cli)公司代理背后的量角器 (angular-cli)
【发布时间】:2018-01-08 04:40:02
【问题描述】:

我在一个运行良好的 centos 虚拟机上运行了一个非常简单的 e2e 测试。我收到以下错误 -

webpack: Compiled successfully.
[15:22:42] I/launcher - Running 1 instances of WebDriver
[15:22:42] I/direct - Using ChromeDriver directly...
Jasmine started
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.

  my-app App
     ✗ Should default to login screen
      - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
      at ontimeout (timers.js:386:11)
      at tryOnTimeout (timers.js:250:5)
  - Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
      at ontimeout (timers.js:386:11)
      at tryOnTimeout (timers.js:250:5)

起初我认为这是由于 .waitForAngular() 的问题,但在退回提交后,似乎在添加自定义字体(在我们的公司网络之外拨打电话)后出现了问题 - @import url('https://fonts.googleapis.com/css?family=Raleway:400,500,700'); 并删除了这个一行确认问题

我可以在这个 github 问题之后为量角器配置代理 - https://github.com/angular/protractor/issues/124

然而,似乎每次调用都是通过代理进行的,包括到本地主机,现在它无法在本地主机上找到 Angular 应用程序。

如何告诉量角器通过代理获取外部资源,本地主机上的任何内容都应该忽略代理?

【问题讨论】:

    标签: angular proxy protractor angular-cli


    【解决方案1】:

    必须为运行测试的浏览器配置代理和代理绕过。就我而言,我使用的是 headless chrome,所以我的 protractor.conf.js 具有以下配置

    capabilities: {
        'browserName': 'chrome',
        chromeOptions: {
          args: [ "--headless", "--disable-gpu", "--window-size=800x600",
          "--proxy-server=http://proxy.example:80",
          "--proxy-bypass-list=http://localhost"]
        }
    }
    

    重要的补充是 --proxy-server 指向我的公司代理服务器和 --proxy-bypass-list 不包括代理中的本地主机

    【讨论】:

    • ..如果你需要在几个环境中运行它,你可以使用ng e2e --protractor-config=other-protractor.conf.js - 更多关于angular.io/cli/e2e
    猜你喜欢
    • 2019-03-24
    • 1970-01-01
    • 2019-08-29
    • 2015-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-20
    • 1970-01-01
    相关资源
    最近更新 更多