【发布时间】:2016-09-05 13:27:51
【问题描述】:
所以我有一个 nodejs 服务器,我想开始使用 nightwatch 进行一些功能测试。
如果我手动启动 selenium 并使用 mocha 运行它(命令:mocha ./test/functional/*.spec.js --compilers js:babel-register)它会启动节点服务器并在 firefox 中运行良好(默认- 顺便说一下,使用标准 mocha 如何将它从默认的 firefox 更改为其他浏览器?):
import nightwatch from 'nightwatch';
require('../../server');
describe('Functional', function wrapIt() {
const client = nightwatch.initClient({
silent: true,
});
const browser = client.api();
this.timeout(99999999);
beforeEach((done) => {
client.start(done);
});
it('should login', (done) => {
browser
.url('http://localhost:8441/')
.waitForElementVisible('button[name=login]', 1000)
.click('button[name=login]')
.pause(1000);
browser.expect.element('button').to.have.attribute('class').which.contains('theme__button');
browser.end();
client.start(done);
});
after((done) => {
browser.end();
client.start(done);
});
});
现在我想把它放在 Bamboo 上并使用 phantomjs,selenium 服务器启动,nodejs 服务器启动但没有执行测试。 我有 nightwatch.json:
{
"src_folders" : ["test/night"],
"output_folder": "reports",
"test_runner" : "mocha",
"selenium" : {
"start_process": true,
"server_path": ".//bin/selenium-server-standalone-2.53.1.jar",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4444
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName": "phantomjs",
"phantomjs.cli.args" : ["--ignore-ssl-errors=true"],
"version":"latest",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
,nightwatch.conf.js 是:
require('babel-core/register');
module.exports = require('./nightwatch.json');
以及夜间文件夹中的测试脚本:
require('../../server');
describe('Functional', function wrapIt() {
const client = this.client;
const browser = client.api();
this.timeout(99999999);
beforeEach((done) => {
client.start(done);
});
it('should login', (done) => {
browser
.url('http://localhost:8441/')
.waitForElementVisible('button[name=login]', 1000)
.click('button[name=login]')
.pause(1000);
browser.expect.element('button').to.have.attribute('class').which.contains('theme__button');
browser.end();
client.start(done);
});
after((done) => {
browser.end();
client.start(done);
});
});
所以用 nightwatch 运行它会启动 selenium 服务器,nodejs 服务器也启动正常,但没有任何反应。
【问题讨论】:
-
那个 selenium 服务器路径对吗?另外,你有 Bamboo 的日志吗?他们可能会帮助您指出问题所在。
标签: phantomjs mocha.js nightwatch.js