RuntimeError: Couldn't connect to selenium server
RuntimeError: Couldn't connect to selenium server
我有一个 Web 应用程序,我正尝试通过 Jasmine WebDriver IO 对其进行测试。目前,我已经这样设置我的测试:
'use strict';
var webdriverio = require('webdriverio');
var client = null;
var rootUrl = 'http://localhost:5000';
describe('Site', function() {
beforeEach(function(done) {
// Initialize the test client. Use PhantomJS
client = webdriverio.remote({ desiredCapabilities: { browserName: 'phantomjs' } });
client.init()
.url(rootUrl)
.then(done);
});
afterEach(function(done) {
client.end(done);
});
// Ensure that the page properly loads.
it('Should load', function(done) {
client
.getTitle()
.then(function(title) {
expect(title).toBe('Welcome');
done();
})
;
});
});
我正在 运行通过以下任务从 gulp 开始这个测试:
gulp.task('test', function() {
return gulp.src(input.tests)
.pipe(jasmine())
;
});
当我通过 gulp test
运行 此任务时,出现以下错误:
RuntimeError: Couldn't connect to selenium server
我不明白为什么会出现此错误。
我没有看到任何关于独立启动 selenium 服务器的信息。
您需要下载 jar 并 运行 它。
您可以通过执行
来做到这一点
$ curl -O http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar
然后
$ java -jar selenium-server-standalone-2.46.0.jar
然后你可以在你的测试中调用服务器
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();
我有一个 Web 应用程序,我正尝试通过 Jasmine WebDriver IO 对其进行测试。目前,我已经这样设置我的测试:
'use strict';
var webdriverio = require('webdriverio');
var client = null;
var rootUrl = 'http://localhost:5000';
describe('Site', function() {
beforeEach(function(done) {
// Initialize the test client. Use PhantomJS
client = webdriverio.remote({ desiredCapabilities: { browserName: 'phantomjs' } });
client.init()
.url(rootUrl)
.then(done);
});
afterEach(function(done) {
client.end(done);
});
// Ensure that the page properly loads.
it('Should load', function(done) {
client
.getTitle()
.then(function(title) {
expect(title).toBe('Welcome');
done();
})
;
});
});
我正在 运行通过以下任务从 gulp 开始这个测试:
gulp.task('test', function() {
return gulp.src(input.tests)
.pipe(jasmine())
;
});
当我通过 gulp test
运行 此任务时,出现以下错误:
RuntimeError: Couldn't connect to selenium server
我不明白为什么会出现此错误。
我没有看到任何关于独立启动 selenium 服务器的信息。 您需要下载 jar 并 运行 它。
您可以通过执行
来做到这一点$ curl -O http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar
然后
$ java -jar selenium-server-standalone-2.46.0.jar
然后你可以在你的测试中调用服务器
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();