与代理运行AngularJS量角器到https [英] Running AngularJS Protractor with proxy to https

查看:106
本文介绍了与代理运行AngularJS量角器到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下错误在命令行中试图运行时量角器:


  

>
  致命错误:用量角器code退出:1


我要代理到HTTPS测试服务器。我如何做到这一点?我跟着从这个 Github的问题的意见,但我仍然得到上述错误。下面是我的配置文件:

  //参考配置文件。
exports.config = {
   // -----如何设置硒-----
   //
   //有三种方式来指定如何使用Selenium。指定之一
   //如下:
   //
   // 1. seleniumServerJar - 本地启动硒独立。
   // 2. seleniumAddress - 连接到它已经是一个Selenium服务器
   //运行。
   // 3. sauceUser / sauceKey - 通过SauceLabs使用远程服务器的硒。   //硒独立服务器的.jar文件的位置。
   seleniumServerJar:./selenium/selenium-server-standalone-2.35.0.jar',
   //端口上启动硒服务器或NULL,如果服务器应
   //找到自己的未使用的端口。
   seleniumPort:空,
   // Chromedriver位置是用来帮助硒独立服务器
   //找到chromedriver。这将被传递到所述硒罐作为
   //系统属性webdriver.chrome.driver。如果为null,将硒
   //试图寻找chromedriver使用路径。
   chromeDriver:./selenium/chromedriver',
   //附加命令行选项传递给硒。例如,
   //如果您需要更改浏览器超时,使用
   // seleniumArgs:['-browserTimeout = 60'],
   seleniumArgs:[],   //如果指定sauceUser和sauceKey,seleniumServerJar将被忽略。
   //测试将远程使用SauceLabs运行。
   sauceUser:空,
   sauceKey:空,   // -----哪些测试运行-----
   //
   //规格模式是相对于这个配置的位置。
   规格:
      ./e2e/*-spec.js
   ]   // -----能力要传递到的webdriver实例----
   //
   //有关可用功能的完整列表,请参阅
   // HTTPS://$c$c.google.com/p/selenium/wiki/DesiredCapabilities
   //和
   // HTTPS://$c$c.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
   功能:{
      browserName':'铬',
      '代理': {
         '的proxyType':'手动',
         HTTPPROXY':'https://localhost.com:8443/
      }
   },   //一个基本网址测试您的应用程序。调用protractor.get()
   //使用相对路径会与此ppended $ P $。
   的baseUrl:HTTP://本地主机:9999',   //选择的元件安放角应用程序 - 这默认为
   //身体,但必要的,如果NG-应用程序是针对&lt后裔;身体GT;
   rootElement的:身体,   // -----选项要传递给minijasminenode -----
   jasmineNodeOpts:{
      //的onComplete会叫司机退出之前。
      的onComplete:空,
      //如果为真,显示规范名称。
      isVerbose:真实,
      //如果为真,打印色彩到终端。
      showColors:真实,
      //如果为真,包括故障堆栈跟踪。
      includeStackTrace:真实,
      //默认时间以毫秒等待测试失败了。
      defaultTimeoutInterval:10000
   }
};


解决方案

据该的的webdriver功能文档,你应该使用主机名:端口作为格式 HTTPPROXY 。例如:

 功能:{
  browserName:'火狐',
  代理: {
     的proxyType:'手动',
     HTTPPROXY:的'localhost:8443',
     sslProxy:本地主机:8888'
  }
}

检查您的代理服务器软件为正确的端口。

这在Firefox为我工作。不知道浏览器。

I get the following error in the command line when trying to run Protractor:

> Fatal error: protractor exited with code: 1

I need to proxy to an https test server. How do I accomplish this? I followed the advice from this Github issue, but I am still getting the above error. Here is my config file:

// A reference configuration file.
exports.config = {
   // ----- How to setup Selenium -----
   //
   // There are three ways to specify how to use Selenium. Specify one of the
   // following:
   //
   // 1. seleniumServerJar - to start Selenium Standalone locally.
   // 2. seleniumAddress - to connect to a Selenium server which is already
   //    running.
   // 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs.

   // The location of the selenium standalone server .jar file.
   seleniumServerJar: './selenium/selenium-server-standalone-2.35.0.jar',
   // The port to start the selenium server on, or null if the server should
   // find its own unused port.
   seleniumPort: null,
   // Chromedriver location is used to help the selenium standalone server
   // find chromedriver. This will be passed to the selenium jar as
   // the system property webdriver.chrome.driver. If null, selenium will
   // attempt to find chromedriver using PATH.
   chromeDriver: './selenium/chromedriver',
   // Additional command line options to pass to selenium. For example,
   // if you need to change the browser timeout, use
   // seleniumArgs: ['-browserTimeout=60'],
   seleniumArgs: [],

   // If sauceUser and sauceKey are specified, seleniumServerJar will be ignored.
   // The tests will be run remotely using SauceLabs.
   sauceUser: null,
   sauceKey: null,

   // ----- What tests to run -----
   //
   // Spec patterns are relative to the location of this config.
   specs: [
      './e2e/*-spec.js'
   ],

   // ----- Capabilities to be passed to the webdriver instance ----
   //
   // For a full list of available capabilities, see
   // https://code.google.com/p/selenium/wiki/DesiredCapabilities
   // and
   // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
   capabilities: {
      'browserName': 'chrome',
      'proxy': {
         'proxyType': 'manual',
         'httpProxy': 'https://localhost.com:8443/'
      }
   },

   // A base URL for your application under test. Calls to protractor.get()
   // with relative paths will be prepended with this.
   baseUrl: 'http://localhost:9999',

   // Selector for the element housing the angular app - this defaults to
   // body, but is necessary if ng-app is on a descendant of <body>
   rootElement: 'body',

   // ----- Options to be passed to minijasminenode -----
   jasmineNodeOpts: {
      // onComplete will be called just before the driver quits.
      onComplete: null,
      // If true, display spec names.
      isVerbose: true,
      // If true, print colors to the terminal.
      showColors: true,
      // If true, include stack traces in failures.
      includeStackTrace: true,
      // Default time to wait in ms before a test fails.
      defaultTimeoutInterval: 10000
   }
};

解决方案

According to the WebDriver capabilities documentation, you should use 'hostname:port' as the format for the httpProxy. E.g.:

capabilities: {
  browserName: 'firefox',
  proxy: {
     proxyType: 'manual',
     httpProxy: 'localhost:8443',
     sslProxy: 'localhost:8888'
  }
}

Check your proxy software for the correct port.

This works for me in Firefox. Not sure about Chrome.

这篇关于与代理运行AngularJS量角器到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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