BrowserStack + Nightwatch.js How to set up proxy which is password protected (ERROR: httpProxy was not of the form host[:port]
BrowserStack + Nightwatch.js How to set up proxy which is password protected (ERROR: httpProxy was not of the form host[:port]
BrowserStack + Nightwatch.js 如何设置受密码保护的代理
common_capabilities: {
'browserstack.user': 'user',
'browserstack.key': 'key',
'browserstack.debug': true,
},
test_settings: {
default: {
desiredCapabilities: {
'os': 'OS X',
'os_version': 'Sierra',
'browser': 'Firefox',
'browser_version': '53.0',
'resolution': '1280x960',
"acceptSslCerts": 'false',
'proxy': {
'httpProxy': 'user:password@server:80',
'protocol': 'http',
'proxyType': 'manual',
//'httpProxy': 'server:80',
//'user': 'user',
//'pass': 'password'
}
},
我遇到了错误:
从 selenium 服务器检索新会话时出错
连接被拒绝! selenium 服务器启动了吗?
消息:'无法启动浏览器/模拟器
原因:httpProxy 不是 host[:port]
的形式
BrowserStack 支持要求我根据我的设置细节提供我的解决方案:
我不得不使用 BrowserStack.local
"scripts": {
"test": "./bin/BrowserStackLocal --key ACCESS_KEY --local-proxy-host PROXY_HOST --local-proxy-port PROXY_PORT --local-proxy-user PROXY_USER --local-proxy-pass PROXY_PASS --local-identifier Test123 & ./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests",
"local": "./bin/BrowserStackLocal --key ACCESS_KEY --local-identifier Test123 && ./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests",
"nightwatch": "./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests"
},
第一步:通过代理启动 BrowserStackLocal(在一个终端 window
第 2 步:运行 在 "tests" 文件夹
中测试
我找到了更好的解决方案,使用 nightwatch-browserstack
并自定义 local.runner.js:
#!/usr/bin/env node
process.env.NODE_ENV = 'testing';
const access = require('../conf/browserStackAccess.js').access; //{'USERNAME':'', 'ACCESS_KEY': ''}
const bsLocalOptions = {
'key': access.ACCESS_KEY,
'local-proxy-host': PROXY_HOST,
'local-proxy-port': PROXY_PORT,
'local-proxy-user': PROXY_USER,
'local-proxy-pass': ROXY_PASS,
'local-identifier': LOCAL_ID //'Test123'
}
var Nightwatch = require('nightwatch');
var browserstack = require('browserstack-local');
var bs_local;
try {
process.mainModule.filename = "./node_modules/nightwatch/bin/nightwatch"
// Code to start browserstack local before start of test
console.log("Connecting local");
Nightwatch.bs_local = bs_local = new browserstack.Local();
bs_local.start(bsLocalOptions, function (error) {
if (error) throw error;
console.log('Connected. Now testing...');
Nightwatch.cli(function (argv) {
Nightwatch.CliRunner(argv)
.setup(null, function () {
// Code to stop browserstack local after end of parallel test
bs_local.stop(function () { });
})
.runTests(function () {
// Code to stop browserstack local after end of single test
bs_local.stop(function () { });
});
});
});
} catch (ex) {
console.log('There was an error while starting the test runner:\n\n');
process.stderr.write(ex.stack + '\n');
process.exit(2);
}
BrowserStack + Nightwatch.js 如何设置受密码保护的代理
common_capabilities: {
'browserstack.user': 'user',
'browserstack.key': 'key',
'browserstack.debug': true,
},
test_settings: {
default: {
desiredCapabilities: {
'os': 'OS X',
'os_version': 'Sierra',
'browser': 'Firefox',
'browser_version': '53.0',
'resolution': '1280x960',
"acceptSslCerts": 'false',
'proxy': {
'httpProxy': 'user:password@server:80',
'protocol': 'http',
'proxyType': 'manual',
//'httpProxy': 'server:80',
//'user': 'user',
//'pass': 'password'
}
},
我遇到了错误:
从 selenium 服务器检索新会话时出错
连接被拒绝! selenium 服务器启动了吗?
消息:'无法启动浏览器/模拟器
原因:httpProxy 不是 host[:port]
BrowserStack 支持要求我根据我的设置细节提供我的解决方案: 我不得不使用 BrowserStack.local
"scripts": {
"test": "./bin/BrowserStackLocal --key ACCESS_KEY --local-proxy-host PROXY_HOST --local-proxy-port PROXY_PORT --local-proxy-user PROXY_USER --local-proxy-pass PROXY_PASS --local-identifier Test123 & ./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests",
"local": "./bin/BrowserStackLocal --key ACCESS_KEY --local-identifier Test123 && ./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests",
"nightwatch": "./node_modules/nightwatch/bin/nightwatch -c conf/local.conf.js tests"
},
第一步:通过代理启动 BrowserStackLocal(在一个终端 window 第 2 步:运行 在 "tests" 文件夹
中测试我找到了更好的解决方案,使用 nightwatch-browserstack 并自定义 local.runner.js:
#!/usr/bin/env node
process.env.NODE_ENV = 'testing';
const access = require('../conf/browserStackAccess.js').access; //{'USERNAME':'', 'ACCESS_KEY': ''}
const bsLocalOptions = {
'key': access.ACCESS_KEY,
'local-proxy-host': PROXY_HOST,
'local-proxy-port': PROXY_PORT,
'local-proxy-user': PROXY_USER,
'local-proxy-pass': ROXY_PASS,
'local-identifier': LOCAL_ID //'Test123'
}
var Nightwatch = require('nightwatch');
var browserstack = require('browserstack-local');
var bs_local;
try {
process.mainModule.filename = "./node_modules/nightwatch/bin/nightwatch"
// Code to start browserstack local before start of test
console.log("Connecting local");
Nightwatch.bs_local = bs_local = new browserstack.Local();
bs_local.start(bsLocalOptions, function (error) {
if (error) throw error;
console.log('Connected. Now testing...');
Nightwatch.cli(function (argv) {
Nightwatch.CliRunner(argv)
.setup(null, function () {
// Code to stop browserstack local after end of parallel test
bs_local.stop(function () { });
})
.runTests(function () {
// Code to stop browserstack local after end of single test
bs_local.stop(function () { });
});
});
});
} catch (ex) {
console.log('There was an error while starting the test runner:\n\n');
process.stderr.write(ex.stack + '\n');
process.exit(2);
}