我试图让Protractor通过根据this github issue设置seleniumServerJar路径来启动独立的Selenium Server,但它启动selenium服务器的地址和端口不同于使用java启动它的情况 - jar或./node_modules/protractor/bin/webdrivermanager start。
从java -jar / path / to / jar输出开始:
$ java -jar selenium-server-standalone-2.42.2.jar 2014年6月23日 10:28:25 PM org.openqa.grid.selenium.GridLauncher主要信息:启动 独立服务器22:28:25.082 INFO - Java:Apple Inc. 20.65-b04-462 22:28:25.082 INFO - 操作系统:Mac OS X 10.9.3 x86_64 22:28:25.092信息 - v2.42.2,Core v2.42.2。根据修订版6a6995d 22:28:25.146建造 信息 - 默认驱动程序org.openqa.selenium.ie.InternetExplorerDriver 注册被跳过:注册功能能力 [{platform = WINDOWS,ensureCleanSession = true,browserName = internet explorer,version =}]与当前平台不匹配:MAC 22:28:25.197 INFO - RemoteWebDriver实例应该连接到:
http://127.0.0.1:4444/wd/hub
22:28:25.198 INFO - 版本Jetty / 5.1.x. 22:28:25.199信息 - 开始 HttpContext的[/硒 - 服务器/驱动器,/硒 - 服务器/驱动器] 22:28:25.199信息 - 开始 HttpContext [/ selenium-server,/ selenium-server] 22:28:25.199 INFO - 启动HttpContext [/,/] 22:28:25.235 INFO - 已启动 org.openqa.jetty.jetty.servlet.ServletHandler@7786df0f 22:28:25.235 信息 - 已启动HttpContext [/ wd,/ wd] 22:28:25.240信息 - 已启动 SocketListener on 0.0.0.0:4444 22:28:25.240 INFO - 已启动 org.openqa.jetty.jetty.Server@42698403
通过指定seleniumServerJar来启动Protractor:
$ ./node_modules/protractor/bin/protractor protractor_conf.js开始 selenium独立服务器... Selenium独立服务器开始于
http://192.168.0.20:59959/wd/hub
然后它会挂起并超时。
在指定seleniumServerJar时如何正确启动独立的selenium服务器?
附注:我已将selenium-server.jar文件放在我的项目中,以便根据前面提到的github问题轻松使用相对路径。
我的protractor_conf.js:
exports.config = {
// Do not start a Selenium Standalone sever - only run this using chrome.
//chromeOnly: true,
//chromeDriver: '../node_modules/protractor/selenium/chromedriver',
//we are using a standalone selenium server so give it the local address
//seleniumAddress: 'http://0.0.0.0:4444/wd/hub',
seleniumServerJar: './selenium-server-standalone-2.42.2.jar',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'phantomjs'
},
baseUrl: 'http://localhost:8000',
onPrepare: function () {
require('jasmine-reporters');
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
var browserName = caps.caps_.browserName.toUpperCase();
var browserVersion = caps.caps_.version;
var prePendStr = browserName + '-' + browserVersion + '-';
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('test-results/protractor/', true, true, prePendStr));
});
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['test/protractor/**/*_spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
isVerbose: true,
defaultTimeoutInterval: 30000
},
params: {
env: 'test'
}
};
答案 0 :(得分:2)
192.168.0.20是您的本地IP地址,默认情况下端口应为4444,您可以使用
更改端口 seleniumPort: 1234
在 protractor_conf.js 内(btw:protractor.conf.js是量角器的默认配置文件名)