【发布时间】:2015-05-07 22:07:21
【问题描述】:
我正在尝试解决在尝试使用 phantomJS 运行量角器测试时遇到的错误。
Exception thrown: Keeping the Selenium server alive
ERROR - Unable to start a WebDriver session.
/Users/test/projects/test/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
var template = new Error(this.message);
^
UnknownError: org.openqa.selenium.browserlaunchers.Proxies
我使用的版本是:
{
'phantomsjs': '1.9.16',
'selenium-server-standalone': '2.44.0',
'protractor': '1.7.0',
'jasmine-reporters': '2.0.4',
'grunt-protractor-webdriver:'0.2.0'
}
我的量角器配置文件是:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'http://localhost:9000/',
"capabilities": {
"browserName": "phantomjs",
"phantomjs.binary.path": require("phantomjs").path,
"phantomjs.ghostdriver.cli.args": ["--loglevel=DEBUG"]
},
specs: ['../test/e2e/**/*.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
//onComplete: false,//use function to teardown database and rebuild etc....
isVerbose: false,
showColors: true,
includeStackTrace: true
}
};
我的 grunt 任务配置如下:
protractor: {
e2e: {
configFile: "config/protractor.conf.test.js"
},
run: {}
},
我将任务注册为:
grunt.registerTask('test', function () {
grunt.task.run([
'build',
'browserify:spec',
'karma:unit',
'protractor_webdriver:start',
'protractor:e2e'
]);
});
我能够使用 chrome 运行配置,但 phantomjs 一直失败。
【问题讨论】:
-
我读到了一位 Angular 团队成员的评论,他说 Phantom 并不完全适合 Protractor 测试。 DOM 渲染存在太多不规则和问题,无法完全依赖它。尽管我确实使用 PhantomJS 进行单元测试,但我只将 Chrome 用于 Protractor。
标签: selenium-webdriver gruntjs jasmine phantomjs protractor