我想用量角器和browserstack运行测试。 我跟着this post 我支持代理。我已经安装了browserstack local,我用这个命令运行它:
BrowserStackLocal.exe -v -proxyHost proxy -proxyPort port QgNaPBMSMoZ5s5dx1WFH localhost,9000,0
一切似乎都有效,因为我有这样的信息:
BrowserStackLocal v4.3
Setting up proxy connection to cornillon:8000
Proxy is configured
Connecting to BrowserStack using WebSocket protocol...
Platform supports WebSocket connections.
You can now access your local server(s) in our remote browser.
***
Please ensure your browser is configured to bypass proxy for "bs-local.com".
***
Press Ctrl-C to exit
然后我运行我的gulp任务量角器,我有这个错误:
C:\Users\toto\Desktop\myapp3>gulp protractor
[16:11:44] Using gulpfile ~\Desktop\myapp3\gulpfile.js
[16:11:44] Starting 'protractor'...
[16:11:44] Finished 'protractor' after 6.9 ms
Using the selenium server at http://hub.browserstack.com/wd/hub
[launcher] Running 1 instances of WebDriver
C:\Users\toto\Desktop\myapp3\node_modules\selenium-webdriver\http\index.js:174
callback(new Error(message));
^
Error: ETIMEDOUT connect ETIMEDOUT 208.52.180.201:80
at ClientRequest.<anonymous> (C:\Users\toto\Desktop\myapp3\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:441:9)
at process._tickCallback (node.js:355:17)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Users\toto\Desktop\myapp3\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (C:\Users\toto\Desktop\myapp3\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:131:30)
at [object Object].Builder.build (C:\Users\toto\Desktop\myapp3\node_modules\selenium-webdriver\builder.js:445:22)
at [object Object].DriverProvider.getNewDriver (C:\Users\toto\Desktop\myapp3\node_modules\protractor\lib\driverProviders\driverProvider.js:38:7)
at [object Object].Runner.createBrowser (C:\Users\toto\Desktop\myapp3\node_modules\protractor\lib\runner.js:186:37)
at C:\Users\toto\Desktop\myapp3\node_modules\protractor\lib\runner.js:276:21
at _fulfilled (C:\Users\toto\Desktop\myapp3\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (C:\Users\toto\Desktop\myapp3\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (C:\Users\toto\Desktop\myapp3\node_modules\protractor\node_modules\q\q.js:759:13)
at C:\Users\toto\Desktop\myapp3\node_modules\protractor\node_modules\q\q.js:525:49
[launcher] Process exited with error code 1
C:\Users\toto\Desktop\myapp3\gulpfile.js:352
.on('error', function(e) { throw e; });
^
Error: protractor exited with code 1
这是我的protractor.conf.js文件:
var proxy = 'http://proxy:port';
exports.config = {
capabilities: {
proxy: {
proxyType: 'manual',
httpProxy: proxy,
sslProxy: proxy,
noProxy: 'bs-local.com'
},
'browserstack.user': 'toto',
'browserstack.key': 'key', // show on BrowserStack
// Needed for testing localhost
'browserstack.local' : 'true',
// Settings for the browser you want to test
// (check docs for difference between `browser` and `browserName`
'browserName' : 'chrome',
'version' : '43.0',
'os' : 'OS X',
'os_version' : 'Yosemite',
'resolution' : '1024x768'
},
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
specs: ['./src/app/**/*.spec.e2e.js']
};
这似乎是一个网络问题,因此可能代理配置不当。
请帮助我吗?
由于
答案 0 :(得分:0)
由于您希望通过本地代理在BrowserStack上运行测试,因此通过功能设置代理参数无济于事,因为它在远程VM上设置了代理。根据您共享的conf文件,我相信您只希望配置代理主机和代理端口参数。我建议您使用global-tunnel节点模块在Protractor测试中设置代理。这应该可以帮助您通过网络中的代理在BrowserStack上运行Protractor测试。