你能举个例子吗?
您需要在配置的capabilities
部分中指定它。 查阅此文档以获取有关如何为Webdriver代理创建JSON配置的信息: https :
尝试了一下,对我来说真的没有用。 这可能是我的经验不足。 您或任何人都有一个可以展示的快速示例吗? 这会走很长一段路。
capabilities: {
'proxy': {
'proxyType': 'manual',
'httpProxy': 'hostname.com:1234'
}
}
此解决方案不适用于我们的设置。 有什么想法我做错了吗? 尝试运行量角器时,在命令行中出现以下错误:
> Fatal error: protractor exited with code: 1
这是我的配置文件:
// 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
}
};
我尝试了您的功能,它对我有用。 当我输入虚假的httpProxy时,在浏览器中看到“无法连接到代理”错误,但是测试仍然尝试运行。 没有代理,您的测试是否可以正常运行? 在这种情况下如何失败?
好的,我发现确实可行,只是将baseurl设置为https测试站点,如下所示:
exports.config = {
seleniumServerJar: './selenium/selenium-server-standalone-2.35.0.jar',
seleniumPort: null,
chromeDriver: './selenium/chromedriver',
seleniumArgs: [],
sauceUser: null,
sauceKey: null,
specs: [
'./e2e/*-spec.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'https://localhost:8443/',
rootElement: 'body',
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
}
};
你好
我设法使代理与你们在这里所做的工作一起工作,因此感谢我,现在我想添加noProxy变量,以便可以将内部服务排除在代理之外。 我已经尝试了以下方法,但是noProxy部分没有被使用。 我正在使用PhantomJs。
'proxy': {
'proxyType': 'manual',
'httpProxy': 'http://proxy.blah.co.uk:8080'
'httpsProxy': 'http://proxy.blah.co.uk:8080'
'noProxy': 'blah.blah.co.uk,*blah.blah.co.uk,.blah.blah.co.uk'
}
},
你好
我无法使其与经过身份验证的代理一起使用。 我试过了:
'proxy': {
'proxyType': 'manual',
'httpProxy': 'user:[email protected]:3128'
'sslProxy': 'user:[email protected]:3128'
}
和
'proxy': {
'proxyType': 'manual',
'httpProxy': 'http://user:[email protected]:3128'
'sslProxy': 'http://user:[email protected]:3128'
}
我正在尝试使用浏览器Chrome来完成https://docs.angularjs.org/tutorial/step_03 。
也不对我有用-我必须提供host:port以及用户名/密码,并且我尝试了上述所有建议,但似乎没有任何效果。 但是,当我离开公司的互联网并尝试不使用代理服务器时,一切正常。 有什么帮助吗?
实际上,我的问题是通过设置系统变量解决的
http_proxy http://user:password<strong i="6">@proxy_url</strong>:port
https_proxy http://user:password<strong i="7">@proxy_url</strong>:port
需要重新打开它,在GE Software,这里在配置中设置http_proxy和https_proxy仍然不允许Protractor向Saucelabs发送测试结果的最终退出代码,从而使Saucelabs由于不活动而无法通过测试。
@jonniespratley protractor config --proxy=http://user:password<strong i="6">@proxy_url</strong>:port
对您不起作用吗?
我尝试在酱料实验室运行量角器测试,但它收到ETIMEDOUT错误。 我在公司防火墙后面,并且已在量角器配置文件和环境变量中配置了代理。 配置似乎不起作用。 以下是我遇到的错误
Error: ETIMEDOUT connect ETIMEDOUT 151.444.33.22:80
at ClientRequest.<anonymous> (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:174:16)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at doNTCallback2 (node.js:439:9)
at process._tickCallback (node.js:353:17)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at [object Object].Builder.build (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
at [object Object].DriverProvider.getNewDriver (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/driverProviders/driverProvider.js:42:27)
at [object Object].Runner.createBrowser (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/runner.js:190:37)
at /Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/runner.js:280:21
at _fulfilled (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:796:13)
at /Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:556:49
[launcher] Process exited with error code 1
任何想法? 我将非常感谢您的帮助。
我收到类似的错误。 我在公司代理的支持下,无法向浏览器堆栈提交测试。
/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/promise.js:654
throw error;
^
Error: ETIMEDOUT connect ETIMEDOUT 208.52.180.201:80
at ClientRequest.<anonymous> (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/http/index.js:381:15)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at doNTCallback2 (node.js:441:9)
at process._tickCallback (node.js:355:17)
From: Task: WebDriver.createSession()
at Function.createSession (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/builder.js:458:24)
at Object.<anonymous> (/Users/Documents/coding/sublime/simpleboilerplate/bs.js:13:3)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
From: Task: WebDriver.navigate().to(http://www.google.com)
at WebDriver.schedule (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:377:17)
at Navigation.to (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:1027:25)
at WebDriver.get (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:795:28)
at Object.<anonymous> (/Users/Documents/coding/sublime/simpleboilerplate/bs.js:15:8)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
最终使我们摆脱企业代理并最终移至Perfecto Mobile的硒服务器的方法是使用webDriverProxy
配置:
exports.config = {
framework: 'jasmine',
seleniumAddress: 'https://yourCloudName.perfectomobile.com/nexperience/perfectomobile/wd/hub',
webDriverProxy: 'http://your.proxy.here:8080',
capabilities: { ... },
specs: ['myspec.js']
};
我正在企业代理后面尝试在conf.js中添加此代码
'代理': {
'proxyType':'manual',
'httpProxy':' user:[email protected] :8080'
'sslProxy':' user:[email protected] :8080'
}
它工作正常,但是应用程序执行时间增加了,导致失败,是的,我可以增加默认时间,但是我不希望我的应用程序花费更长的时间才能运行。
谁能帮我解决这个问题。
提前致谢。
@gregjacobs我也将webDriverProxy与perfecto一起使用。 一段时间以来,它为我工作。 升级到4.x或5.x后,我再也无法正常工作了。 升级后它仍然对您有用吗?
https://github.com/angular/protractor/blob/master/lib/config.ts上的所有代理选项都不适合我。 有人在v5中配置代理很幸运吗?
@ deli6z
建立具有这些功能的BrowserMob代理和量角器-工作正常
capabilities: {
'browserName': 'chrome',
'args': ['disable-web-security'],
'proxy': {
'proxyType': 'manual',
'httpProxy': '10.179.70.127:10801',
'sslProxy': '10.179.70.127:10801',
"autodetect": 'false'
}
}
@gregjacobs我需要为webDriverProxy
属性上使用的代理指定用户名/密码。 你知道如何?
@ luker2不幸的是,我不确定,但是webDriverProxy: 'http://username:[email protected]:8080'
不起作用吗? (其中8080
是您的代理的端口?)
@gregjacobs是的,我尚未跟进,但这就是最终的结果!
对于其他人,我还必须对用户名:密码部分进行网址编码,以转义特殊字符...
webDriverProxy: `http://${encodeURIComponent(username)}:${encodeURIComponent(password)}@your.proxy.here:8080`
@ luker2太棒了,很高兴听到您成功使用它! 感谢您发布关于uri编码用户名和密码的文章-不错!
最有用的评论