使用代理到 https 运行 AngularJS Protractor [英] Running AngularJS Protractor with proxy to https
问题描述
尝试运行 Protractor 时,我在命令行中收到以下错误:
I get the following error in the command line when trying to run Protractor:
>致命错误:量角器退出,代码:1
> Fatal error: protractor exited with code: 1
我需要代理到 https 测试服务器.我该如何做到这一点?我遵循了这个 Github 问题 的建议,但我仍然收到上述错误.这是我的配置文件:
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
}
};
推荐答案
根据WebDriver 功能文档,您应该使用 'hostname:port' 作为 httpProxy
的格式.例如:
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.
这适用于 Firefox 和 Chrome.
This works in Firefox and Chrome.
这篇关于使用代理到 https 运行 AngularJS Protractor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!