我无法在Sauce Lab上进行量角器测试。我是公司防火墙的后面,我有使用Sauce Connect的活动隧道到酱汁实验室。以下是我的量角器conf.js
var HttpsProxyAgent = require("https-proxy-agent");
var agent = new HttpsProxyAgent('http://userName:password@proxy.example.com:8099');
// An example configuration file.
exports.config = {
agent: agent,
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
directConnect: false,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
'proxy': {
'proxyType': 'manual',
'httpProxy': 'http://userName:password@proxy.example.com:8099'
}
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['tests/specs/*-spec.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
当我运行node_modules / protractor / bin / protractor conf.js时,我得到以下错误
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
答案 0 :(得分:2)
通过Protractor将代理传递到Sauce Labs的关键字是sauceAgent。尝试以下方法,看看你是否有更好的运气。
var HttpsProxyAgent = require("https-proxy-agent");
var agent = new HttpsProxyAgent('http://userName:password@proxy.example.com:8099');
// An example configuration file.
exports.config = {
sauceAgent: agent,
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
答案 1 :(得分:0)
在量角器上,你不能只定义一个 qa-proxy.config.js
然后像这样运行你的测试:
ng e2e --configuration=qa-proxy --protractor-config=./e2e/qa-protractor.conf.js
然后定义如下规则:
const PROXY_CONFIG = {
"/assets/my-uri/log-response.json": {
"target": "",
"methods": [ "POST" ],
"secure": false,
"bypass": function (req,res, proxyOptions) {
if(req.url == "/assets/my-uri/log-response.json"){
res.end('');
return true;
}
}
},
...