在 Sauce 实验室的公司防火墙后面进行 运行 Angular Protractor 测试有问题吗?
Having issue with running Angular Protractor test behind corporate firewall on Sauce lab?
我无法 运行 Sauce Lab 上的量角器测试。我在公司防火墙后面,我有使用 Sauce Connect 到 Sauce Lab 的活跃隧道。下面是我的量角器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
通过 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,
在量角器上,你不能只定义一个 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;
}
}
},
...
我无法 运行 Sauce Lab 上的量角器测试。我在公司防火墙后面,我有使用 Sauce Connect 到 Sauce Lab 的活跃隧道。下面是我的量角器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
通过 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,
在量角器上,你不能只定义一个 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;
}
}
},
...